2 +----------------------------------------------------------------------+
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 #include "hphp/runtime/vm/as-base.h"
18 #include "hphp/runtime/vm/as-base-hhas.h"
20 #if defined(FOLLY_PACKAGE_VERSION)
21 // This file is included in the hackc binary build where we can't easily include
23 #error Folly not allowed in this source file.
29 std::string
join_with_spaces(const std::vector
<std::string
> &input
) {
31 for (const auto& piece
: input
) {
32 len
+= piece
.length() + 1;
38 for (const auto& piece
: input
) {
39 if (!result
.empty()) {
40 result
.push_back(' ');
47 } // anonymous namespace
49 std::vector
<std::string
> attrs_to_vec(AttrContext ctx
, Attr attrs
) {
50 std::vector
<std::string
> vec
;
52 #define X(attr, mask, str) \
53 if (supported(mask, ctx) && (attrs & attr)) vec.push_back(str);
60 std::string
attrs_to_string(AttrContext ctx
, Attr attrs
) {
61 return join_with_spaces(attrs_to_vec(ctx
, attrs
));
64 std::string
type_flags_to_string(TypeConstraintFlags flags
) {
65 std::vector
<std::string
> vec
;
67 #define X(flag, str) \
68 if (contains(flags, TypeConstraintFlags::flag)) vec.push_back(str);
72 return join_with_spaces(vec
);
75 std::string
fcall_flags_to_string(FCallArgsFlags flags
) {
76 std::vector
<std::string
> vec
;
78 #define X(flag, str) \
79 if (flags & FCallArgsFlags::flag) vec.push_back(str);
83 return join_with_spaces(vec
);
86 std::string
iter_args_flags_to_string(IterArgsFlags flags
) {
87 std::vector
<std::string
> vec
;
89 #define X(flag, str) \
90 if (has_flag(flags, IterArgsFlags::flag)) vec.push_back(str);
94 return join_with_spaces(vec
);