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 +----------------------------------------------------------------------+
18 #include "hphp/hhbbc/context.h"
19 #include "hphp/hhbbc/misc.h"
20 #include "hphp/hhbbc/type-system.h"
22 namespace HPHP::HHBBC
{
24 //////////////////////////////////////////////////////////////////////
36 //////////////////////////////////////////////////////////////////////
39 * Result of resolve_type_structure
41 struct TypeStructureResolution
{
42 Type type
; // Best known type of the *resolved* type-structure. If
43 // the type-structure can be statically pre-resolved,
44 // this will be a static array.
45 bool mightFail
; // Whether the resolution can possibly fail
46 bool contextSensitive
{false}; // If the resolution involved context
47 // sensitive information. If so, only
48 // the declaring class can safely use
51 // If the resolution results in a static array with no possibility
52 // of failure, return it.
53 SArray
sarray() const {
54 if (mightFail
) return nullptr;
55 auto const v
= tv(type
);
56 if (!v
) return nullptr;
57 assertx(tvIsDict(*v
));
58 assertx(val(*v
).parr
->isStatic());
62 TypeStructureResolution
& operator|=(const TypeStructureResolution
& o
) {
64 mightFail
|= o
.mightFail
;
65 contextSensitive
|= o
.contextSensitive
;
71 * Attempt to resolve the given type-structure, either "anonymous",
72 * from a class constant, or from a type-alias.
74 TypeStructureResolution
resolve_type_structure(const ISS
&, SArray
);
75 TypeStructureResolution
resolve_type_structure(const IIndex
&,
76 const php::Const
& cns
,
77 const php::Class
& thiz
);
78 TypeStructureResolution
resolve_type_structure(const IIndex
&,
80 const php::TypeAlias
&);
82 //////////////////////////////////////////////////////////////////////
85 * If the type-structure represents a class or an unresolved type,
86 * retrieve the associated name of the class.
88 SString
type_structure_name(SArray
);
90 //////////////////////////////////////////////////////////////////////