Add mode to EndCatch
[hiphop-php.git] / hphp / runtime / vm / as-shared.h
blob2c8c08ee9a184c6db4d95dea5f75efa56edb7436
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 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_AS_SHARED_H_
17 #define incl_HPHP_AS_SHARED_H_
19 #include <string>
20 #include <folly/Optional.h>
22 #include "hphp/runtime/base/attr.h"
23 #include "hphp/runtime/vm/type-constraint.h"
25 namespace HPHP {
27 //////////////////////////////////////////////////////////////////////
30 * This header contains routines shared between as.cpp and disas.cpp.
31 * It shouldn't be included by anything else.
34 //////////////////////////////////////////////////////////////////////
37 * Attribute bits mean different things depending on context. This
38 * just enumerates the contexts the (dis)assembler cares about.
40 enum class AttrContext {
41 Class = 0x1,
42 Func = 0x2,
43 Prop = 0x4,
44 TraitImport = 0x8,
45 Alias = 0x10,
46 Parameter = 0x20,
50 * Convert an attr to a vector of attribute names, for a given context.
52 std::vector<std::string> attrs_to_vec(AttrContext, Attr);
55 * Convert an attr to a string of space-separated attribute names, for
56 * a given context.
58 std::string attrs_to_string(AttrContext, Attr);
61 * Convert a string containing a single attribute name into an Attr,
62 * for a given context.
64 * Returns folly::none if the string doesn't name a known attribute.
66 folly::Optional<Attr> string_to_attr(AttrContext, const std::string&);
69 * Convert TypeConstraint flags to a string of space-separated flag names.
71 std::string type_flags_to_string(TypeConstraint::Flags flags);
74 * Convert a string containing a single type flag name into a
75 * TypeConstraint::Flag.
77 * Returns folly::none if the string doesn't name a known attribute.
79 folly::Optional<TypeConstraint::Flags> string_to_type_flag(
80 const std::string& name);
81 //////////////////////////////////////////////////////////////////////
82 struct is_bareword {
83 bool operator()(int i) const {
84 return isalnum(i) || i == '_' || i == '.' || i == '$' || i == '\\';
89 #endif