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->location() == Variable::UNALLOCATED && | 57 return var != NULL && var->location() == Variable::UNALLOCATED && |
58 var_proxy->raw_name()->IsOneByteEqualTo("undefined"); | 58 var_proxy->raw_name()->IsOneByteEqualTo("undefined"); |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) | 62 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position, |
63 : Expression(zone, position), | 63 IdGen* id_gen) |
| 64 : Expression(zone, position, 0, id_gen), |
64 is_this_(var->is_this()), | 65 is_this_(var->is_this()), |
65 is_assigned_(false), | 66 is_assigned_(false), |
66 is_resolved_(false), | 67 is_resolved_(false), |
67 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), | 68 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
68 raw_name_(var->raw_name()), | 69 raw_name_(var->raw_name()), |
69 interface_(var->interface()) { | 70 interface_(var->interface()) { |
70 BindTo(var); | 71 BindTo(var); |
71 } | 72 } |
72 | 73 |
73 | 74 |
74 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 75 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
75 Interface* interface, int position) | 76 Interface* interface, int position, IdGen* id_gen) |
76 : Expression(zone, position), | 77 : Expression(zone, position, 0, id_gen), |
77 is_this_(is_this), | 78 is_this_(is_this), |
78 is_assigned_(false), | 79 is_assigned_(false), |
79 is_resolved_(false), | 80 is_resolved_(false), |
80 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), | 81 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
81 raw_name_(name), | 82 raw_name_(name), |
82 interface_(interface) {} | 83 interface_(interface) {} |
83 | 84 |
84 | 85 |
85 void VariableProxy::BindTo(Variable* var) { | 86 void VariableProxy::BindTo(Variable* var) { |
86 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); | 87 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); |
87 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); | 88 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); |
88 // Ideally CONST-ness should match. However, this is very hard to achieve | 89 // Ideally CONST-ness should match. However, this is very hard to achieve |
89 // because we don't know the exact semantics of conflicting (const and | 90 // because we don't know the exact semantics of conflicting (const and |
90 // non-const) multiple variable declarations, const vars introduced via | 91 // non-const) multiple variable declarations, const vars introduced via |
91 // eval() etc. Const-ness and variable declarations are a complete mess | 92 // eval() etc. Const-ness and variable declarations are a complete mess |
92 // in JS. Sigh... | 93 // in JS. Sigh... |
93 set_var(var); | 94 set_var(var); |
94 set_is_resolved(); | 95 set_is_resolved(); |
95 var->set_is_used(); | 96 var->set_is_used(); |
96 } | 97 } |
97 | 98 |
98 | 99 |
99 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, | 100 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, |
100 Expression* value, int pos) | 101 Expression* value, int pos, IdGen* id_gen) |
101 : Expression(zone, pos), | 102 : Expression(zone, pos, num_ids(), id_gen), |
102 is_uninitialized_(false), | 103 is_uninitialized_(false), |
103 key_type_(ELEMENT), | 104 key_type_(ELEMENT), |
104 store_mode_(STANDARD_STORE), | 105 store_mode_(STANDARD_STORE), |
105 op_(op), | 106 op_(op), |
106 target_(target), | 107 target_(target), |
107 value_(value), | 108 value_(value), |
108 binary_operation_(NULL) {} | 109 binary_operation_(NULL) {} |
109 | 110 |
110 | 111 |
111 Token::Value Assignment::binary_op() const { | 112 Token::Value Assignment::binary_op() const { |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 RegExpTree* node = nodes->at(i); | 983 RegExpTree* node = nodes->at(i); |
983 int node_min_match = node->min_match(); | 984 int node_min_match = node->min_match(); |
984 min_match_ = IncreaseBy(min_match_, node_min_match); | 985 min_match_ = IncreaseBy(min_match_, node_min_match); |
985 int node_max_match = node->max_match(); | 986 int node_max_match = node->max_match(); |
986 max_match_ = IncreaseBy(max_match_, node_max_match); | 987 max_match_ = IncreaseBy(max_match_, node_max_match); |
987 } | 988 } |
988 } | 989 } |
989 | 990 |
990 | 991 |
991 CaseClause::CaseClause(Zone* zone, Expression* label, | 992 CaseClause::CaseClause(Zone* zone, Expression* label, |
992 ZoneList<Statement*>* statements, int pos) | 993 ZoneList<Statement*>* statements, int pos, IdGen* id_gen) |
993 : Expression(zone, pos), | 994 : Expression(zone, pos, num_ids(), id_gen), |
994 label_(label), | 995 label_(label), |
995 statements_(statements), | 996 statements_(statements), |
996 compare_type_(Type::None(zone)) {} | 997 compare_type_(Type::None(zone)) {} |
997 | 998 |
998 | 999 |
999 #define REGULAR_NODE(NodeType) \ | 1000 #define REGULAR_NODE(NodeType) \ |
1000 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1001 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
1001 increase_node_count(); \ | 1002 increase_node_count(); \ |
1002 } | 1003 } |
1003 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1004 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 // static | 1145 // static |
1145 bool Literal::Match(void* literal1, void* literal2) { | 1146 bool Literal::Match(void* literal1, void* literal2) { |
1146 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1147 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1147 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1148 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1148 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1149 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
1149 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1150 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1150 } | 1151 } |
1151 | 1152 |
1152 | 1153 |
1153 } } // namespace v8::internal | 1154 } } // namespace v8::internal |
OLD | NEW |