| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 19 matching lines...) Expand all Loading... |
| 30 #include "ast.h" | 30 #include "ast.h" |
| 31 #include "parser.h" | 31 #include "parser.h" |
| 32 #include "scopes.h" | 32 #include "scopes.h" |
| 33 #include "string-stream.h" | 33 #include "string-stream.h" |
| 34 #include "type-info.h" | 34 #include "type-info.h" |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 AstSentinels::AstSentinels() | 39 AstSentinels::AstSentinels() |
| 40 : this_proxy_(true), | 40 : this_proxy_(Isolate::Current(), true), |
| 41 identifier_proxy_(false), | 41 identifier_proxy_(Isolate::Current(), false), |
| 42 valid_left_hand_side_sentinel_(), | 42 valid_left_hand_side_sentinel_(Isolate::Current()), |
| 43 this_property_(&this_proxy_, NULL, 0), | 43 this_property_(Isolate::Current(), &this_proxy_, NULL, 0), |
| 44 call_sentinel_(NULL, NULL, 0) { | 44 call_sentinel_(Isolate::Current(), NULL, NULL, 0) { |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 // ---------------------------------------------------------------------------- | 48 // ---------------------------------------------------------------------------- |
| 49 // All the Accept member functions for each syntax tree node type. | 49 // All the Accept member functions for each syntax tree node type. |
| 50 | 50 |
| 51 void Slot::Accept(AstVisitor* v) { v->VisitSlot(this); } | 51 void Slot::Accept(AstVisitor* v) { v->VisitSlot(this); } |
| 52 | 52 |
| 53 #define DECL_ACCEPT(type) \ | 53 #define DECL_ACCEPT(type) \ |
| 54 void type::Accept(AstVisitor* v) { v->Visit##type(this); } | 54 void type::Accept(AstVisitor* v) { v->Visit##type(this); } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 65 ? expression()->AsAssignment() | 65 ? expression()->AsAssignment() |
| 66 : NULL; | 66 : NULL; |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 CountOperation* ExpressionStatement::StatementAsCountOperation() { | 70 CountOperation* ExpressionStatement::StatementAsCountOperation() { |
| 71 return expression()->AsCountOperation(); | 71 return expression()->AsCountOperation(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 VariableProxy::VariableProxy(Variable* var) | 75 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) |
| 76 : name_(var->name()), | 76 : Expression(isolate), |
| 77 name_(var->name()), |
| 77 var_(NULL), // Will be set by the call to BindTo. | 78 var_(NULL), // Will be set by the call to BindTo. |
| 78 is_this_(var->is_this()), | 79 is_this_(var->is_this()), |
| 79 inside_with_(false), | 80 inside_with_(false), |
| 80 is_trivial_(false), | 81 is_trivial_(false), |
| 81 position_(RelocInfo::kNoPosition) { | 82 position_(RelocInfo::kNoPosition) { |
| 82 BindTo(var); | 83 BindTo(var); |
| 83 } | 84 } |
| 84 | 85 |
| 85 | 86 |
| 86 VariableProxy::VariableProxy(Handle<String> name, | 87 VariableProxy::VariableProxy(Isolate* isolate, |
| 88 Handle<String> name, |
| 87 bool is_this, | 89 bool is_this, |
| 88 bool inside_with, | 90 bool inside_with, |
| 89 int position) | 91 int position) |
| 90 : name_(name), | 92 : Expression(isolate), |
| 91 var_(NULL), | 93 name_(name), |
| 92 is_this_(is_this), | 94 var_(NULL), |
| 93 inside_with_(inside_with), | 95 is_this_(is_this), |
| 94 is_trivial_(false), | 96 inside_with_(inside_with), |
| 95 position_(position) { | 97 is_trivial_(false), |
| 98 position_(position) { |
| 96 // Names must be canonicalized for fast equality checks. | 99 // Names must be canonicalized for fast equality checks. |
| 97 ASSERT(name->IsSymbol()); | 100 ASSERT(name->IsSymbol()); |
| 98 } | 101 } |
| 99 | 102 |
| 100 | 103 |
| 101 VariableProxy::VariableProxy(bool is_this) | 104 VariableProxy::VariableProxy(Isolate* isolate, bool is_this) |
| 102 : var_(NULL), | 105 : Expression(isolate), |
| 103 is_this_(is_this), | 106 var_(NULL), |
| 104 inside_with_(false), | 107 is_this_(is_this), |
| 105 is_trivial_(false) { | 108 inside_with_(false), |
| 109 is_trivial_(false) { |
| 106 } | 110 } |
| 107 | 111 |
| 108 | 112 |
| 109 void VariableProxy::BindTo(Variable* var) { | 113 void VariableProxy::BindTo(Variable* var) { |
| 110 ASSERT(var_ == NULL); // must be bound only once | 114 ASSERT(var_ == NULL); // must be bound only once |
| 111 ASSERT(var != NULL); // must bind | 115 ASSERT(var != NULL); // must bind |
| 112 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); | 116 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); |
| 113 // Ideally CONST-ness should match. However, this is very hard to achieve | 117 // Ideally CONST-ness should match. However, this is very hard to achieve |
| 114 // because we don't know the exact semantics of conflicting (const and | 118 // because we don't know the exact semantics of conflicting (const and |
| 115 // non-const) multiple variable declarations, const vars introduced via | 119 // non-const) multiple variable declarations, const vars introduced via |
| 116 // eval() etc. Const-ness and variable declarations are a complete mess | 120 // eval() etc. Const-ness and variable declarations are a complete mess |
| 117 // in JS. Sigh... | 121 // in JS. Sigh... |
| 118 var_ = var; | 122 var_ = var; |
| 119 var->set_is_used(true); | 123 var->set_is_used(true); |
| 120 } | 124 } |
| 121 | 125 |
| 122 | 126 |
| 123 Assignment::Assignment(Token::Value op, | 127 Assignment::Assignment(Isolate* isolate, |
| 128 Token::Value op, |
| 124 Expression* target, | 129 Expression* target, |
| 125 Expression* value, | 130 Expression* value, |
| 126 int pos) | 131 int pos) |
| 127 : op_(op), | 132 : Expression(isolate), |
| 133 op_(op), |
| 128 target_(target), | 134 target_(target), |
| 129 value_(value), | 135 value_(value), |
| 130 pos_(pos), | 136 pos_(pos), |
| 131 binary_operation_(NULL), | 137 binary_operation_(NULL), |
| 132 compound_load_id_(kNoNumber), | 138 compound_load_id_(kNoNumber), |
| 133 assignment_id_(GetNextId()), | 139 assignment_id_(GetNextId(isolate)), |
| 134 block_start_(false), | 140 block_start_(false), |
| 135 block_end_(false), | 141 block_end_(false), |
| 136 is_monomorphic_(false), | 142 is_monomorphic_(false), |
| 137 receiver_types_(NULL) { | 143 receiver_types_(NULL) { |
| 138 ASSERT(Token::IsAssignmentOp(op)); | 144 ASSERT(Token::IsAssignmentOp(op)); |
| 139 if (is_compound()) { | 145 if (is_compound()) { |
| 140 binary_operation_ = | 146 binary_operation_ = |
| 141 new(ZONE) BinaryOperation(binary_op(), target, value, pos + 1); | 147 new(isolate->zone()) BinaryOperation(isolate, |
| 142 compound_load_id_ = GetNextId(); | 148 binary_op(), |
| 149 target, |
| 150 value, |
| 151 pos + 1); |
| 152 compound_load_id_ = GetNextId(isolate); |
| 143 } | 153 } |
| 144 } | 154 } |
| 145 | 155 |
| 146 | 156 |
| 147 Token::Value Assignment::binary_op() const { | 157 Token::Value Assignment::binary_op() const { |
| 148 switch (op_) { | 158 switch (op_) { |
| 149 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 159 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
| 150 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 160 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
| 151 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 161 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
| 152 case Token::ASSIGN_SHL: return Token::SHL; | 162 case Token::ASSIGN_SHL: return Token::SHL; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 179 kind_ = MATERIALIZED_LITERAL; | 189 kind_ = MATERIALIZED_LITERAL; |
| 180 } else if (value_->AsLiteral() != NULL) { | 190 } else if (value_->AsLiteral() != NULL) { |
| 181 kind_ = CONSTANT; | 191 kind_ = CONSTANT; |
| 182 } else { | 192 } else { |
| 183 kind_ = COMPUTED; | 193 kind_ = COMPUTED; |
| 184 } | 194 } |
| 185 } | 195 } |
| 186 | 196 |
| 187 | 197 |
| 188 ObjectLiteral::Property::Property(bool is_getter, FunctionLiteral* value) { | 198 ObjectLiteral::Property::Property(bool is_getter, FunctionLiteral* value) { |
| 199 Isolate* isolate = Isolate::Current(); |
| 189 emit_store_ = true; | 200 emit_store_ = true; |
| 190 key_ = new(ZONE) Literal(value->name()); | 201 key_ = new(isolate->zone()) Literal(isolate, value->name()); |
| 191 value_ = value; | 202 value_ = value; |
| 192 kind_ = is_getter ? GETTER : SETTER; | 203 kind_ = is_getter ? GETTER : SETTER; |
| 193 } | 204 } |
| 194 | 205 |
| 195 | 206 |
| 196 bool ObjectLiteral::Property::IsCompileTimeValue() { | 207 bool ObjectLiteral::Property::IsCompileTimeValue() { |
| 197 return kind_ == CONSTANT || | 208 return kind_ == CONSTANT || |
| 198 (kind_ == MATERIALIZED_LITERAL && | 209 (kind_ == MATERIALIZED_LITERAL && |
| 199 CompileTimeValue::IsCompileTimeValue(value_)); | 210 CompileTimeValue::IsCompileTimeValue(value_)); |
| 200 } | 211 } |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 int node_max_match = node->max_match(); | 1194 int node_max_match = node->max_match(); |
| 1184 if (kInfinity - max_match_ < node_max_match) { | 1195 if (kInfinity - max_match_ < node_max_match) { |
| 1185 max_match_ = kInfinity; | 1196 max_match_ = kInfinity; |
| 1186 } else { | 1197 } else { |
| 1187 max_match_ += node->max_match(); | 1198 max_match_ += node->max_match(); |
| 1188 } | 1199 } |
| 1189 } | 1200 } |
| 1190 } | 1201 } |
| 1191 | 1202 |
| 1192 | 1203 |
| 1193 CaseClause::CaseClause(Expression* label, | 1204 CaseClause::CaseClause(Isolate* isolate, |
| 1205 Expression* label, |
| 1194 ZoneList<Statement*>* statements, | 1206 ZoneList<Statement*>* statements, |
| 1195 int pos) | 1207 int pos) |
| 1196 : label_(label), | 1208 : label_(label), |
| 1197 statements_(statements), | 1209 statements_(statements), |
| 1198 position_(pos), | 1210 position_(pos), |
| 1199 compare_type_(NONE), | 1211 compare_type_(NONE), |
| 1200 compare_id_(AstNode::GetNextId()), | 1212 compare_id_(AstNode::GetNextId(isolate)), |
| 1201 entry_id_(AstNode::GetNextId()) { | 1213 entry_id_(AstNode::GetNextId(isolate)) { |
| 1202 } | 1214 } |
| 1203 | 1215 |
| 1204 } } // namespace v8::internal | 1216 } } // namespace v8::internal |
| OLD | NEW |