| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 String::Equals(var_proxy->name(), | 58 String::Equals(var_proxy->name(), |
| 59 isolate->factory()->undefined_string()); | 59 isolate->factory()->undefined_string()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) | 63 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) |
| 64 : Expression(zone, position), | 64 : Expression(zone, position), |
| 65 name_(var->name()), | 65 name_(var->name()), |
| 66 var_(NULL), // Will be set by the call to BindTo. | 66 var_(NULL), // Will be set by the call to BindTo. |
| 67 is_this_(var->is_this()), | 67 is_this_(var->is_this()), |
| 68 is_trivial_(false), | 68 is_assigned_(false), |
| 69 is_lvalue_(false), | |
| 70 interface_(var->interface()) { | 69 interface_(var->interface()) { |
| 71 BindTo(var); | 70 BindTo(var); |
| 72 } | 71 } |
| 73 | 72 |
| 74 | 73 |
| 75 VariableProxy::VariableProxy(Zone* zone, | 74 VariableProxy::VariableProxy(Zone* zone, |
| 76 Handle<String> name, | 75 Handle<String> name, |
| 77 bool is_this, | 76 bool is_this, |
| 78 Interface* interface, | 77 Interface* interface, |
| 79 int position) | 78 int position) |
| 80 : Expression(zone, position), | 79 : Expression(zone, position), |
| 81 name_(name), | 80 name_(name), |
| 82 var_(NULL), | 81 var_(NULL), |
| 83 is_this_(is_this), | 82 is_this_(is_this), |
| 84 is_trivial_(false), | 83 is_assigned_(false), |
| 85 is_lvalue_(false), | |
| 86 interface_(interface) { | 84 interface_(interface) { |
| 87 // Names must be canonicalized for fast equality checks. | 85 // Names must be canonicalized for fast equality checks. |
| 88 ASSERT(name->IsInternalizedString()); | 86 ASSERT(name->IsInternalizedString()); |
| 89 } | 87 } |
| 90 | 88 |
| 91 | 89 |
| 92 void VariableProxy::BindTo(Variable* var) { | 90 void VariableProxy::BindTo(Variable* var) { |
| 93 ASSERT(var_ == NULL); // must be bound only once | 91 ASSERT(var_ == NULL); // must be bound only once |
| 94 ASSERT(var != NULL); // must bind | 92 ASSERT(var != NULL); // must bind |
| 95 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); | 93 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); |
| 96 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); | 94 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); |
| 97 // Ideally CONST-ness should match. However, this is very hard to achieve | 95 // Ideally CONST-ness should match. However, this is very hard to achieve |
| 98 // because we don't know the exact semantics of conflicting (const and | 96 // because we don't know the exact semantics of conflicting (const and |
| 99 // non-const) multiple variable declarations, const vars introduced via | 97 // non-const) multiple variable declarations, const vars introduced via |
| 100 // eval() etc. Const-ness and variable declarations are a complete mess | 98 // eval() etc. Const-ness and variable declarations are a complete mess |
| 101 // in JS. Sigh... | 99 // in JS. Sigh... |
| 102 var_ = var; | 100 var_ = var; |
| 103 var->set_is_used(true); | 101 var->set_is_used(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 | 104 |
| 107 Assignment::Assignment(Zone* zone, | 105 Assignment::Assignment(Zone* zone, |
| 108 Token::Value op, | 106 Token::Value op, |
| 109 Expression* target, | 107 Expression* target, |
| 110 Expression* value, | 108 Expression* value, |
| 111 int pos) | 109 int pos) |
| 112 : Expression(zone, pos), | 110 : Expression(zone, pos), |
| 113 op_(op), | 111 op_(op), |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); | 1147 SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); |
| 1150 str = arr; | 1148 str = arr; |
| 1151 } else { | 1149 } else { |
| 1152 str = DoubleToCString(value_->Number(), buffer); | 1150 str = DoubleToCString(value_->Number(), buffer); |
| 1153 } | 1151 } |
| 1154 return isolate_->factory()->NewStringFromAsciiChecked(str); | 1152 return isolate_->factory()->NewStringFromAsciiChecked(str); |
| 1155 } | 1153 } |
| 1156 | 1154 |
| 1157 | 1155 |
| 1158 } } // namespace v8::internal | 1156 } } // namespace v8::internal |
| OLD | NEW |