Add mode to EndCatch
[hiphop-php.git] / hphp / runtime / vm / rx-inl.h
blob3536b117d8027460e40155f708bc7dcfd3ba0ac9
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_VM_RX_INL_H_
18 #error "rx-inl.h should only be included by rx.h"
19 #endif
21 namespace HPHP {
22 ///////////////////////////////////////////////////////////////////////////////
24 inline Attr rxAttrsFromAttrString(const std::string& a) {
25 if (a == "conditional_rx_local") return rxMakeAttr(RxLevel::Local, true);
26 if (a == "conditional_rx_shallow") return rxMakeAttr(RxLevel::Shallow, true);
27 if (a == "conditional_rx") return rxMakeAttr(RxLevel::Rx, true);
28 if (a == "rx_local") return rxMakeAttr(RxLevel::Local, false);
29 if (a == "rx_shallow") return rxMakeAttr(RxLevel::Shallow, false);
30 if (a == "rx") return rxMakeAttr(RxLevel::Rx, false);
31 return static_cast<Attr>(0);
34 inline const char* rxAttrsToAttrString(Attr attrs) {
35 auto const c = rxConditionalFromAttr(attrs);
36 switch (rxLevelFromAttr(attrs)) {
37 case RxLevel::None: return nullptr;
38 case RxLevel::Local: return c ? "conditional_rx_local" : "rx_local";
39 case RxLevel::Shallow: return c ? "conditional_rx_shallow" : "rx_shallow";
40 case RxLevel::Rx: return c ? "conditional_rx" : "rx";
42 not_reached();
45 inline const char* rxLevelToString(RxLevel level) {
46 switch (level) {
47 case RxLevel::None: return "non-reactive";
48 case RxLevel::Local: return "local reactive";
49 case RxLevel::Shallow: return "shallow reactive";
50 case RxLevel::Rx: return "reactive";
52 not_reached();
55 inline bool rxEnforceCallsInLevel(RxLevel level) {
56 return level >= RxLevel::Shallow;
59 inline RxLevel rxRequiredCalleeLevel(RxLevel level) {
60 assertx(rxEnforceCallsInLevel(level));
61 switch (level) {
62 case RxLevel::None:
63 case RxLevel::Local: not_reached();
64 case RxLevel::Shallow: return RxLevel::Local;
65 case RxLevel::Rx: return RxLevel::Rx;
67 not_reached();
70 ///////////////////////////////////////////////////////////////////////////////