OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ast.h" | 5 #include "src/ast.h" |
6 | 6 |
7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
8 #include "src/builtins.h" | 8 #include "src/builtins.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const VariableProxy* var_proxy = AsVariableProxy(); | 52 const VariableProxy* var_proxy = AsVariableProxy(); |
53 if (var_proxy == NULL) return false; | 53 if (var_proxy == NULL) return false; |
54 Variable* var = var_proxy->var(); | 54 Variable* var = var_proxy->var(); |
55 // The global identifier "undefined" is immutable. Everything | 55 // The global identifier "undefined" is immutable. Everything |
56 // else could be reassigned. | 56 // else could be reassigned. |
57 return var != NULL && var->IsUnallocatedOrGlobalSlot() && | 57 return var != NULL && var->IsUnallocatedOrGlobalSlot() && |
58 var_proxy->raw_name()->IsOneByteEqualTo("undefined"); | 58 var_proxy->raw_name()->IsOneByteEqualTo("undefined"); |
59 } | 59 } |
60 | 60 |
61 | 61 |
| 62 bool Expression::IsValidReferenceExpressionOrThis() const { |
| 63 return IsValidReferenceExpression() || |
| 64 (IsVariableProxy() && AsVariableProxy()->is_this()); |
| 65 } |
| 66 |
| 67 |
62 VariableProxy::VariableProxy(Zone* zone, Variable* var, int start_position, | 68 VariableProxy::VariableProxy(Zone* zone, Variable* var, int start_position, |
63 int end_position) | 69 int end_position) |
64 : Expression(zone, start_position), | 70 : Expression(zone, start_position), |
65 bit_field_(IsThisField::encode(var->is_this()) | | 71 bit_field_(IsThisField::encode(var->is_this()) | |
66 IsAssignedField::encode(false) | | 72 IsAssignedField::encode(false) | |
67 IsResolvedField::encode(false)), | 73 IsResolvedField::encode(false)), |
68 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), | 74 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
69 raw_name_(var->raw_name()), | 75 raw_name_(var->raw_name()), |
70 end_position_(end_position) { | 76 end_position_(end_position) { |
71 BindTo(var); | 77 BindTo(var); |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 bool Literal::Match(void* literal1, void* literal2) { | 1151 bool Literal::Match(void* literal1, void* literal2) { |
1146 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1152 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1147 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1153 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1148 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1154 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1149 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1155 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1150 } | 1156 } |
1151 | 1157 |
1152 | 1158 |
1153 } // namespace internal | 1159 } // namespace internal |
1154 } // namespace v8 | 1160 } // namespace v8 |
OLD | NEW |