| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 IdGen* id_gen) | 63 IdGen* id_gen) |
| 64 : Expression(zone, position, id_gen), | 64 : Expression(zone, position, 0, id_gen), |
| 65 raw_name_(var->raw_name()), | 65 raw_name_(var->raw_name()), |
| 66 interface_(var->interface()), | 66 interface_(var->interface()), |
| 67 variable_feedback_slot_(kInvalidFeedbackSlot), | 67 variable_feedback_slot_(kInvalidFeedbackSlot), |
| 68 is_this_(var->is_this()), | 68 is_this_(var->is_this()), |
| 69 is_assigned_(false), | 69 is_assigned_(false), |
| 70 is_resolved_(false) { | 70 is_resolved_(false) { |
| 71 BindTo(var); | 71 BindTo(var); |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 75 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
| 76 Interface* interface, int position, IdGen* id_gen) | 76 Interface* interface, int position, IdGen* id_gen) |
| 77 : Expression(zone, position, id_gen), | 77 : Expression(zone, position, 0, id_gen), |
| 78 raw_name_(name), | 78 raw_name_(name), |
| 79 interface_(interface), | 79 interface_(interface), |
| 80 variable_feedback_slot_(kInvalidFeedbackSlot), | 80 variable_feedback_slot_(kInvalidFeedbackSlot), |
| 81 is_this_(is_this), | 81 is_this_(is_this), |
| 82 is_assigned_(false), | 82 is_assigned_(false), |
| 83 is_resolved_(false) {} | 83 is_resolved_(false) {} |
| 84 | 84 |
| 85 | 85 |
| 86 void VariableProxy::BindTo(Variable* var) { | 86 void VariableProxy::BindTo(Variable* var) { |
| 87 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); | 87 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); |
| 88 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); | 88 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); |
| 89 // 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 |
| 90 // 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 |
| 91 // non-const) multiple variable declarations, const vars introduced via | 91 // non-const) multiple variable declarations, const vars introduced via |
| 92 // eval() etc. Const-ness and variable declarations are a complete mess | 92 // eval() etc. Const-ness and variable declarations are a complete mess |
| 93 // in JS. Sigh... | 93 // in JS. Sigh... |
| 94 set_var(var); | 94 set_var(var); |
| 95 set_is_resolved(); | 95 set_is_resolved(); |
| 96 var->set_is_used(); | 96 var->set_is_used(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, | 100 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, |
| 101 Expression* value, int pos, IdGen* id_gen) | 101 Expression* value, int pos, IdGen* id_gen) |
| 102 : Expression(zone, pos, id_gen), | 102 : Expression(zone, pos, num_ids(), id_gen), |
| 103 op_(op), | 103 op_(op), |
| 104 target_(target), | 104 target_(target), |
| 105 value_(value), | 105 value_(value), |
| 106 binary_operation_(NULL), | 106 binary_operation_(NULL), |
| 107 assignment_id_(id_gen->GetNextId()), | |
| 108 is_uninitialized_(false), | 107 is_uninitialized_(false), |
| 109 store_mode_(STANDARD_STORE) {} | 108 store_mode_(STANDARD_STORE) {} |
| 110 | 109 |
| 111 | 110 |
| 112 Token::Value Assignment::binary_op() const { | 111 Token::Value Assignment::binary_op() const { |
| 113 switch (op_) { | 112 switch (op_) { |
| 114 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 113 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
| 115 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 114 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
| 116 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 115 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
| 117 case Token::ASSIGN_SHL: return Token::SHL; | 116 case Token::ASSIGN_SHL: return Token::SHL; |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 int node_min_match = node->min_match(); | 981 int node_min_match = node->min_match(); |
| 983 min_match_ = IncreaseBy(min_match_, node_min_match); | 982 min_match_ = IncreaseBy(min_match_, node_min_match); |
| 984 int node_max_match = node->max_match(); | 983 int node_max_match = node->max_match(); |
| 985 max_match_ = IncreaseBy(max_match_, node_max_match); | 984 max_match_ = IncreaseBy(max_match_, node_max_match); |
| 986 } | 985 } |
| 987 } | 986 } |
| 988 | 987 |
| 989 | 988 |
| 990 CaseClause::CaseClause(Zone* zone, Expression* label, | 989 CaseClause::CaseClause(Zone* zone, Expression* label, |
| 991 ZoneList<Statement*>* statements, int pos, IdGen* id_gen) | 990 ZoneList<Statement*>* statements, int pos, IdGen* id_gen) |
| 992 : Expression(zone, pos, id_gen), | 991 : Expression(zone, pos, num_ids(), id_gen), |
| 993 label_(label), | 992 label_(label), |
| 994 statements_(statements), | 993 statements_(statements), |
| 995 compare_type_(Type::None(zone)), | 994 compare_type_(Type::None(zone)) {} |
| 996 compare_id_(id_gen->GetNextId()), | |
| 997 entry_id_(id_gen->GetNextId()) {} | |
| 998 | 995 |
| 999 | 996 |
| 1000 #define REGULAR_NODE(NodeType) \ | 997 #define REGULAR_NODE(NodeType) \ |
| 1001 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 998 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1002 increase_node_count(); \ | 999 increase_node_count(); \ |
| 1003 } | 1000 } |
| 1004 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1001 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
| 1005 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1002 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1006 increase_node_count(); \ | 1003 increase_node_count(); \ |
| 1007 add_slot_node(node); \ | 1004 add_slot_node(node); \ |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 // static | 1142 // static |
| 1146 bool Literal::Match(void* literal1, void* literal2) { | 1143 bool Literal::Match(void* literal1, void* literal2) { |
| 1147 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1144 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 1148 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1145 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 1149 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1146 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
| 1150 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1147 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 1151 } | 1148 } |
| 1152 | 1149 |
| 1153 | 1150 |
| 1154 } } // namespace v8::internal | 1151 } } // namespace v8::internal |
| OLD | NEW |