2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 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_TYPE_ALIAS_H_
18 #define incl_HPHP_TYPE_ALIAS_H_
20 #include "hphp/runtime/base/types.h"
21 #include "hphp/runtime/base/attr.h"
22 #include "hphp/runtime/base/datatype.h"
25 ///////////////////////////////////////////////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////////////////
33 * This is the runtime representation of a type alias. Type aliases are only
34 * allowed when HipHop extensions are enabled.
36 * The m_kind field is KindOfObject whenever the type alias is basically just a
37 * name. At runtime we still might resolve this name to another type alias,
38 * becoming a type alias for KindOfArray or something in that request.
40 * For the per-request struct, see TypeAliasReq below.
46 bool any
; // overrides `kind' for mixed aliases
47 bool nullable
; // null is allowed; for ?Foo aliases
50 template<class SerDe
> void serde(SerDe
& sd
) {
62 ///////////////////////////////////////////////////////////////////////////////
65 * In a given request, a defined type alias is turned into a TypeAliasReq
66 * struct. This contains the information needed to validate parameter type
67 * hints for a type alias at runtime.
71 /////////////////////////////////////////////////////////////////////////////
72 // Static constructors.
74 static TypeAliasReq
Invalid();
75 static TypeAliasReq
From(const TypeAlias
& alias
);
76 static TypeAliasReq
From(TypeAliasReq req
, const TypeAlias
& alias
);
79 /////////////////////////////////////////////////////////////////////////////
82 bool same(const TypeAliasReq
& req
) const;
83 bool compat(const TypeAlias
& alias
) const;
86 /////////////////////////////////////////////////////////////////////////////
90 DataType kind
{KindOfUninit
};
91 // Overrides `kind' if the alias is invalid (e.g., for a nonexistent class).
93 // Overrides `kind' for "HH\\mixed".
95 // For option types, like ?Foo.
97 // Aliased Class; nullptr if kind != KindOfObject.
98 LowClassPtr klass
{nullptr};
99 // Needed for error messages; nullptr if not defined.
100 LowStringPtr name
{nullptr};
103 bool operator==(const TypeAliasReq
& l
, const TypeAliasReq
& r
);
104 bool operator!=(const TypeAliasReq
& l
, const TypeAliasReq
& r
);
106 ///////////////////////////////////////////////////////////////////////////////
109 #define incl_HPHP_TYPE_ALIAS_INL_H_
110 #include "hphp/runtime/vm/type-alias-inl.h"
111 #undef incl_HPHP_TYPE_ALIAS_INL_H_