OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 return AsLiteral() != NULL && AsLiteral()->value()->IsString(); | 65 return AsLiteral() != NULL && AsLiteral()->value()->IsString(); |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 bool Expression::IsNullLiteral() { | 69 bool Expression::IsNullLiteral() { |
70 return AsLiteral() != NULL && AsLiteral()->value()->IsNull(); | 70 return AsLiteral() != NULL && AsLiteral()->value()->IsNull(); |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 bool Expression::IsUndefinedLiteral() { | 74 bool Expression::IsUndefinedLiteral() { |
75 return AsLiteral() != NULL && AsLiteral()->value()->IsUndefined(); | 75 if (!IsVariableProxy()) return false; |
76 VariableProxy* var_proxy = static_cast<VariableProxy*>(this); | |
rossberg
2013/07/12 13:40:32
Instead of these two lines, use AsVariableProxy()
| |
77 Variable* var = var_proxy->var(); | |
78 // The global identifier "undefined" is immutable. Everything | |
79 // else could be reassigned. | |
80 return var != NULL && var->location() == Variable::UNALLOCATED && | |
81 strncmp(*var_proxy->name()->ToCString(), "undefined", 10) == 0; | |
rossberg
2013/07/12 13:40:32
You should be able to say
var->name()->Equals(i
| |
76 } | 82 } |
77 | 83 |
78 | 84 |
79 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) | 85 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) |
80 : Expression(isolate), | 86 : Expression(isolate), |
81 name_(var->name()), | 87 name_(var->name()), |
82 var_(NULL), // Will be set by the call to BindTo. | 88 var_(NULL), // Will be set by the call to BindTo. |
83 is_this_(var->is_this()), | 89 is_this_(var->is_this()), |
84 is_trivial_(false), | 90 is_trivial_(false), |
85 is_lvalue_(false), | 91 is_lvalue_(false), |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1187 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); | 1193 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); |
1188 str = arr; | 1194 str = arr; |
1189 } else { | 1195 } else { |
1190 str = DoubleToCString(value_->Number(), buffer); | 1196 str = DoubleToCString(value_->Number(), buffer); |
1191 } | 1197 } |
1192 return factory->NewStringFromAscii(CStrVector(str)); | 1198 return factory->NewStringFromAscii(CStrVector(str)); |
1193 } | 1199 } |
1194 | 1200 |
1195 | 1201 |
1196 } } // namespace v8::internal | 1202 } } // namespace v8::internal |
OLD | NEW |