Remove .hh_file from hhas
[hiphop-php.git] / hphp / runtime / vm / as-shared.h
blobb7e14ca185e497a80dcbb52b9c0a861659e1dbcf
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,
47 Constant = 0x40,
51 * Convert an attr to a vector of attribute names, for a given context.
53 std::vector<std::string> attrs_to_vec(AttrContext, Attr);
56 * Convert an attr to a string of space-separated attribute names, for
57 * a given context.
59 std::string attrs_to_string(AttrContext, Attr);
62 * Convert a string containing a single attribute name into an Attr,
63 * for a given context.
65 * Returns folly::none if the string doesn't name a known attribute.
67 folly::Optional<Attr> string_to_attr(AttrContext, const std::string&);
70 * Convert TypeConstraint flags to a string of space-separated flag names.
72 std::string type_flags_to_string(TypeConstraint::Flags flags);
75 * Convert a string containing a single type flag name into a
76 * TypeConstraint::Flag.
78 * Returns folly::none if the string doesn't name a known attribute.
80 folly::Optional<TypeConstraint::Flags> string_to_type_flag(
81 const std::string& name);
82 //////////////////////////////////////////////////////////////////////
83 struct is_bareword {
84 bool operator()(int i) const {
85 return isalnum(i) || i == '_' || i == '.' || i == '$' || i == '\\';
90 #endif