2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010 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 #include <runtime/eval/ast/name.h>
18 #include <runtime/eval/ast/expression.h>
19 #include <runtime/base/complex_types.h>
20 #include <util/util.h>
25 ///////////////////////////////////////////////////////////////////////////////
27 Name::Name(CONSTRUCT_ARGS
) : Construct(CONSTRUCT_PASS
) {}
29 int64
Name::hash() const {
32 int64
Name::hashLwr() const {
36 bool Name::isSp() const { return false; }
38 NamePtr
Name::fromString(CONSTRUCT_ARGS
, const string
&name
,
39 bool isSp
/* = false */) {
40 return NamePtr(new StringName(CONSTRUCT_PASS
, name
, isSp
));
43 NamePtr
Name::fromExp(CONSTRUCT_ARGS
, ExpressionPtr e
) {
44 return NamePtr(new ExprName(CONSTRUCT_PASS
, e
));
46 NamePtr
Name::fromStaticClassExp(CONSTRUCT_ARGS
, ExpressionPtr e
) {
47 return NamePtr(new StaticClassExprName(CONSTRUCT_PASS
, e
));
49 NamePtr
Name::LateStatic(CONSTRUCT_ARGS
) {
50 return NamePtr(new LateStaticName(CONSTRUCT_PASS
));
53 StringName::StringName(CONSTRUCT_ARGS
, const string
&name
,
54 bool isSp
/* = false */)
55 : Name(CONSTRUCT_PASS
), m_hash(hash_string(name
.c_str(), name
.size())),
56 m_hashLwr(hash_string_i(name
.c_str(), name
.size())),
57 m_name(name
), m_isSp(isSp
) {
60 String
StringName::get(VariableEnvironment
&env
) const {
64 String
StringName::getStatic() const {
65 return String(m_name
.c_str(), m_name
.size(), AttachLiteral
);
68 int64
StringName::hash() const {
71 int64
StringName::hashLwr() const {
75 bool StringName::isSp() const { return m_isSp
; }
77 void StringName::dump(std::ostream
&out
) const {
81 ExprName::ExprName(CONSTRUCT_ARGS
, ExpressionPtr name
)
82 : Name(CONSTRUCT_PASS
), m_name(name
) {}
84 String
ExprName::get(VariableEnvironment
&env
) const {
85 return m_name
->eval(env
).toString();
88 void ExprName::dump(std::ostream
&out
) const {
94 ExpressionPtr
ExprName::getExp() {
98 void ExprName::setExp(ExpressionPtr name
) {
102 StaticClassExprName::StaticClassExprName(CONSTRUCT_ARGS
, ExpressionPtr name
)
103 : ExprName(CONSTRUCT_PASS
, name
) {}
105 String
StaticClassExprName::get(VariableEnvironment
&env
) const {
106 return get_static_class_name(m_name
->eval(env
));
109 LateStaticName::LateStaticName(CONSTRUCT_ARGS
) : Name(CONSTRUCT_PASS
) {}
111 String
LateStaticName::get(VariableEnvironment
&env
) const {
112 return FrameInjection::GetStaticClassName(ThreadInfo::s_threadInfo
.get());
115 void LateStaticName::dump(std::ostream
&out
) const {
119 ///////////////////////////////////////////////////////////////////////////////