| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 #define AST_NODE_LIST(V) \ | 97 #define AST_NODE_LIST(V) \ |
| 98 V(Declaration) \ | 98 V(Declaration) \ |
| 99 STATEMENT_NODE_LIST(V) \ | 99 STATEMENT_NODE_LIST(V) \ |
| 100 EXPRESSION_NODE_LIST(V) | 100 EXPRESSION_NODE_LIST(V) |
| 101 | 101 |
| 102 // Forward declarations | 102 // Forward declarations |
| 103 class TargetCollector; | 103 class TargetCollector; |
| 104 class MaterializedLiteral; | 104 class MaterializedLiteral; |
| 105 class DefinitionInfo; | 105 class DefinitionInfo; |
| 106 class BitVector; |
| 106 | 107 |
| 107 #define DEF_FORWARD_DECLARATION(type) class type; | 108 #define DEF_FORWARD_DECLARATION(type) class type; |
| 108 AST_NODE_LIST(DEF_FORWARD_DECLARATION) | 109 AST_NODE_LIST(DEF_FORWARD_DECLARATION) |
| 109 #undef DEF_FORWARD_DECLARATION | 110 #undef DEF_FORWARD_DECLARATION |
| 110 | 111 |
| 111 | 112 |
| 112 // Typedef only introduced to avoid unreadable code. | 113 // Typedef only introduced to avoid unreadable code. |
| 113 // Please do appreciate the required space in "> >". | 114 // Please do appreciate the required space in "> >". |
| 114 typedef ZoneList<Handle<String> > ZoneStringList; | 115 typedef ZoneList<Handle<String> > ZoneStringList; |
| 115 typedef ZoneList<Handle<Object> > ZoneObjectList; | 116 typedef ZoneList<Handle<Object> > ZoneObjectList; |
| 116 | 117 |
| 117 | 118 |
| 118 class AstNode: public ZoneObject { | 119 class AstNode: public ZoneObject { |
| 119 public: | 120 public: |
| 120 static const int kNoNumber = -1; | 121 static const int kNoNumber = -1; |
| 121 | 122 |
| 122 AstNode() : num_(kNoNumber) {} | 123 AstNode() : num_(kNoNumber) {} |
| 124 |
| 125 explicit AstNode(AstNode* other); |
| 126 |
| 123 virtual ~AstNode() { } | 127 virtual ~AstNode() { } |
| 124 virtual void Accept(AstVisitor* v) = 0; | 128 virtual void Accept(AstVisitor* v) = 0; |
| 125 | 129 |
| 126 // Type testing & conversion. | 130 // Type testing & conversion. |
| 127 virtual Statement* AsStatement() { return NULL; } | 131 virtual Statement* AsStatement() { return NULL; } |
| 132 virtual Block* AsBlock() { return NULL; } |
| 128 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } | 133 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } |
| 129 virtual EmptyStatement* AsEmptyStatement() { return NULL; } | 134 virtual EmptyStatement* AsEmptyStatement() { return NULL; } |
| 130 virtual Expression* AsExpression() { return NULL; } | 135 virtual Expression* AsExpression() { return NULL; } |
| 131 virtual Literal* AsLiteral() { return NULL; } | 136 virtual Literal* AsLiteral() { return NULL; } |
| 132 virtual Slot* AsSlot() { return NULL; } | 137 virtual Slot* AsSlot() { return NULL; } |
| 133 virtual VariableProxy* AsVariableProxy() { return NULL; } | 138 virtual VariableProxy* AsVariableProxy() { return NULL; } |
| 134 virtual Property* AsProperty() { return NULL; } | 139 virtual Property* AsProperty() { return NULL; } |
| 135 virtual Call* AsCall() { return NULL; } | 140 virtual Call* AsCall() { return NULL; } |
| 136 virtual TargetCollector* AsTargetCollector() { return NULL; } | 141 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 137 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 142 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 138 virtual IterationStatement* AsIterationStatement() { return NULL; } | 143 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 144 virtual ForStatement* AsForStatement() { return NULL; } |
| 139 virtual UnaryOperation* AsUnaryOperation() { return NULL; } | 145 virtual UnaryOperation* AsUnaryOperation() { return NULL; } |
| 146 virtual CountOperation* AsCountOperation() { return NULL; } |
| 140 virtual BinaryOperation* AsBinaryOperation() { return NULL; } | 147 virtual BinaryOperation* AsBinaryOperation() { return NULL; } |
| 141 virtual Assignment* AsAssignment() { return NULL; } | 148 virtual Assignment* AsAssignment() { return NULL; } |
| 142 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } | 149 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } |
| 143 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | 150 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } |
| 144 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } | 151 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } |
| 145 virtual ArrayLiteral* AsArrayLiteral() { return NULL; } | 152 virtual ArrayLiteral* AsArrayLiteral() { return NULL; } |
| 146 virtual CompareOperation* AsCompareOperation() { return NULL; } | 153 virtual CompareOperation* AsCompareOperation() { return NULL; } |
| 147 | 154 |
| 148 int num() { return num_; } | 155 int num() { return num_; } |
| 149 void set_num(int n) { num_ = n; } | 156 void set_num(int n) { num_ = n; } |
| 150 | 157 |
| 151 private: | 158 private: |
| 152 // Support for ast node numbering. | 159 // Support for ast node numbering. |
| 153 int num_; | 160 int num_; |
| 154 }; | 161 }; |
| 155 | 162 |
| 156 | 163 |
| 157 class Statement: public AstNode { | 164 class Statement: public AstNode { |
| 158 public: | 165 public: |
| 159 Statement() : statement_pos_(RelocInfo::kNoPosition) {} | 166 Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
| 160 | 167 |
| 168 explicit Statement(Statement* other); |
| 169 |
| 161 virtual Statement* AsStatement() { return this; } | 170 virtual Statement* AsStatement() { return this; } |
| 162 virtual ReturnStatement* AsReturnStatement() { return NULL; } | 171 virtual ReturnStatement* AsReturnStatement() { return NULL; } |
| 163 | 172 |
| 173 virtual Assignment* StatementAsSimpleAssignment() { return NULL; } |
| 174 virtual CountOperation* StatementAsCountOperation() { return NULL; } |
| 175 |
| 164 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 176 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
| 165 | 177 |
| 166 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 178 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
| 167 int statement_pos() const { return statement_pos_; } | 179 int statement_pos() const { return statement_pos_; } |
| 168 | 180 |
| 169 private: | 181 private: |
| 170 int statement_pos_; | 182 int statement_pos_; |
| 171 }; | 183 }; |
| 172 | 184 |
| 173 | 185 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 184 // Evaluated for control flow (and side effects). | 196 // Evaluated for control flow (and side effects). |
| 185 kTest, | 197 kTest, |
| 186 // Evaluated for control flow and side effects. Value is also | 198 // Evaluated for control flow and side effects. Value is also |
| 187 // needed if true. | 199 // needed if true. |
| 188 kValueTest, | 200 kValueTest, |
| 189 // Evaluated for control flow and side effects. Value is also | 201 // Evaluated for control flow and side effects. Value is also |
| 190 // needed if false. | 202 // needed if false. |
| 191 kTestValue | 203 kTestValue |
| 192 }; | 204 }; |
| 193 | 205 |
| 194 Expression() | 206 Expression() : bitfields_(0) {} |
| 195 : bitfields_(0), | 207 |
| 196 def_(NULL), | 208 explicit Expression(Expression* other); |
| 197 defined_vars_(NULL) {} | |
| 198 | 209 |
| 199 virtual Expression* AsExpression() { return this; } | 210 virtual Expression* AsExpression() { return this; } |
| 200 | 211 |
| 201 virtual bool IsValidLeftHandSide() { return false; } | 212 virtual bool IsValidLeftHandSide() { return false; } |
| 202 | 213 |
| 214 virtual Variable* AssignedVar() { return NULL; } |
| 215 |
| 203 // Symbols that cannot be parsed as array indices are considered property | 216 // Symbols that cannot be parsed as array indices are considered property |
| 204 // names. We do not treat symbols that can be array indexes as property | 217 // names. We do not treat symbols that can be array indexes as property |
| 205 // names because [] for string objects is handled only by keyed ICs. | 218 // names because [] for string objects is handled only by keyed ICs. |
| 206 virtual bool IsPropertyName() { return false; } | 219 virtual bool IsPropertyName() { return false; } |
| 207 | 220 |
| 208 // True if the expression does not have (evaluated) subexpressions. | 221 // True if the expression does not have (evaluated) subexpressions. |
| 209 // Function literals are leaves because their subexpressions are not | 222 // Function literals are leaves because their subexpressions are not |
| 210 // evaluated. | 223 // evaluated. |
| 211 virtual bool IsLeaf() { return false; } | 224 virtual bool IsLeaf() { return false; } |
| 212 | 225 |
| 213 // True if the expression has no side effects and is safe to | 226 // True if the expression has no side effects and is safe to |
| 214 // evaluate out of order. | 227 // evaluate out of order. |
| 215 virtual bool IsTrivial() { return false; } | 228 virtual bool IsTrivial() { return false; } |
| 216 | 229 |
| 230 // True if the expression always has one of the non-Object JS types |
| 231 // (Undefined, Null, Boolean, String, or Number). |
| 232 virtual bool IsPrimitive() = 0; |
| 233 |
| 217 // Mark the expression as being compiled as an expression | 234 // Mark the expression as being compiled as an expression |
| 218 // statement. This is used to transform postfix increments to | 235 // statement. This is used to transform postfix increments to |
| 219 // (faster) prefix increments. | 236 // (faster) prefix increments. |
| 220 virtual void MarkAsStatement() { /* do nothing */ } | 237 virtual void MarkAsStatement() { /* do nothing */ } |
| 221 | 238 |
| 222 // Static type information for this expression. | 239 // Static type information for this expression. |
| 223 StaticType* type() { return &type_; } | 240 StaticType* type() { return &type_; } |
| 224 | 241 |
| 225 // Data flow information. | |
| 226 DefinitionInfo* var_def() { return def_; } | |
| 227 void set_var_def(DefinitionInfo* def) { def_ = def; } | |
| 228 | |
| 229 ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; } | |
| 230 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) { | |
| 231 defined_vars_ = defined_vars; | |
| 232 } | |
| 233 | |
| 234 // AST analysis results | 242 // AST analysis results |
| 235 | 243 |
| 236 // True if the expression rooted at this node can be compiled by the | 244 // True if the expression rooted at this node can be compiled by the |
| 237 // side-effect free compiler. | 245 // side-effect free compiler. |
| 238 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); } | 246 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); } |
| 239 void set_side_effect_free(bool is_side_effect_free) { | 247 void set_side_effect_free(bool is_side_effect_free) { |
| 240 bitfields_ &= ~SideEffectFreeField::mask(); | 248 bitfields_ &= ~SideEffectFreeField::mask(); |
| 241 bitfields_ |= SideEffectFreeField::encode(is_side_effect_free); | 249 bitfields_ |= SideEffectFreeField::encode(is_side_effect_free); |
| 242 } | 250 } |
| 243 | 251 |
| 252 // Will the use of this expression treat -0 the same as 0 in all cases? |
| 253 // If so, we can return 0 instead of -0 if we want to, to optimize code. |
| 254 bool no_negative_zero() { return NoNegativeZeroField::decode(bitfields_); } |
| 255 void set_no_negative_zero(bool no_negative_zero) { |
| 256 bitfields_ &= ~NoNegativeZeroField::mask(); |
| 257 bitfields_ |= NoNegativeZeroField::encode(no_negative_zero); |
| 258 } |
| 259 |
| 244 // Will ToInt32 (ECMA 262-3 9.5) or ToUint32 (ECMA 262-3 9.6) | 260 // Will ToInt32 (ECMA 262-3 9.5) or ToUint32 (ECMA 262-3 9.6) |
| 245 // be applied to the value of this expression? | 261 // be applied to the value of this expression? |
| 246 // If so, we may be able to optimize the calculation of the value. | 262 // If so, we may be able to optimize the calculation of the value. |
| 247 bool to_int32() { return ToInt32Field::decode(bitfields_); } | 263 bool to_int32() { return ToInt32Field::decode(bitfields_); } |
| 248 void set_to_int32(bool to_int32) { | 264 void set_to_int32(bool to_int32) { |
| 249 bitfields_ &= ~ToInt32Field::mask(); | 265 bitfields_ &= ~ToInt32Field::mask(); |
| 250 bitfields_ |= ToInt32Field::encode(to_int32); | 266 bitfields_ |= ToInt32Field::encode(to_int32); |
| 251 } | 267 } |
| 252 | 268 |
| 269 // How many bitwise logical or shift operators are used in this expression? |
| 270 int num_bit_ops() { return NumBitOpsField::decode(bitfields_); } |
| 271 void set_num_bit_ops(int num_bit_ops) { |
| 272 bitfields_ &= ~NumBitOpsField::mask(); |
| 273 num_bit_ops = Min(num_bit_ops, kMaxNumBitOps); |
| 274 bitfields_ |= NumBitOpsField::encode(num_bit_ops); |
| 275 } |
| 253 | 276 |
| 254 private: | 277 private: |
| 278 static const int kMaxNumBitOps = (1 << 5) - 1; |
| 279 |
| 255 uint32_t bitfields_; | 280 uint32_t bitfields_; |
| 256 StaticType type_; | 281 StaticType type_; |
| 257 | 282 |
| 258 DefinitionInfo* def_; | |
| 259 ZoneList<DefinitionInfo*>* defined_vars_; | |
| 260 | |
| 261 // Using template BitField<type, start, size>. | 283 // Using template BitField<type, start, size>. |
| 262 class SideEffectFreeField : public BitField<bool, 0, 1> {}; | 284 class SideEffectFreeField : public BitField<bool, 0, 1> {}; |
| 263 class ToInt32Field : public BitField<bool, 1, 1> {}; | 285 class NoNegativeZeroField : public BitField<bool, 1, 1> {}; |
| 286 class ToInt32Field : public BitField<bool, 2, 1> {}; |
| 287 class NumBitOpsField : public BitField<int, 3, 5> {}; |
| 264 }; | 288 }; |
| 265 | 289 |
| 266 | 290 |
| 267 /** | 291 /** |
| 268 * A sentinel used during pre parsing that represents some expression | 292 * A sentinel used during pre parsing that represents some expression |
| 269 * that is a valid left hand side without having to actually build | 293 * that is a valid left hand side without having to actually build |
| 270 * the expression. | 294 * the expression. |
| 271 */ | 295 */ |
| 272 class ValidLeftHandSideSentinel: public Expression { | 296 class ValidLeftHandSideSentinel: public Expression { |
| 273 public: | 297 public: |
| 274 virtual bool IsValidLeftHandSide() { return true; } | 298 virtual bool IsValidLeftHandSide() { return true; } |
| 275 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } | 299 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 276 static ValidLeftHandSideSentinel* instance() { return &instance_; } | 300 static ValidLeftHandSideSentinel* instance() { return &instance_; } |
| 301 |
| 302 virtual bool IsPrimitive() { |
| 303 UNREACHABLE(); |
| 304 return false; |
| 305 } |
| 306 |
| 277 private: | 307 private: |
| 278 static ValidLeftHandSideSentinel instance_; | 308 static ValidLeftHandSideSentinel instance_; |
| 279 }; | 309 }; |
| 280 | 310 |
| 281 | 311 |
| 282 class BreakableStatement: public Statement { | 312 class BreakableStatement: public Statement { |
| 283 public: | 313 public: |
| 284 enum Type { | 314 enum Type { |
| 285 TARGET_FOR_ANONYMOUS, | 315 TARGET_FOR_ANONYMOUS, |
| 286 TARGET_FOR_NAMED_ONLY | 316 TARGET_FOR_NAMED_ONLY |
| (...skipping 11 matching lines...) Expand all Loading... |
| 298 | 328 |
| 299 // Testers. | 329 // Testers. |
| 300 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } | 330 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } |
| 301 | 331 |
| 302 protected: | 332 protected: |
| 303 BreakableStatement(ZoneStringList* labels, Type type) | 333 BreakableStatement(ZoneStringList* labels, Type type) |
| 304 : labels_(labels), type_(type) { | 334 : labels_(labels), type_(type) { |
| 305 ASSERT(labels == NULL || labels->length() > 0); | 335 ASSERT(labels == NULL || labels->length() > 0); |
| 306 } | 336 } |
| 307 | 337 |
| 338 explicit BreakableStatement(BreakableStatement* other); |
| 339 |
| 308 private: | 340 private: |
| 309 ZoneStringList* labels_; | 341 ZoneStringList* labels_; |
| 310 Type type_; | 342 Type type_; |
| 311 BreakTarget break_target_; | 343 BreakTarget break_target_; |
| 312 }; | 344 }; |
| 313 | 345 |
| 314 | 346 |
| 315 class Block: public BreakableStatement { | 347 class Block: public BreakableStatement { |
| 316 public: | 348 public: |
| 317 Block(ZoneStringList* labels, int capacity, bool is_initializer_block) | 349 Block(ZoneStringList* labels, int capacity, bool is_initializer_block) |
| 318 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), | 350 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), |
| 319 statements_(capacity), | 351 statements_(capacity), |
| 320 is_initializer_block_(is_initializer_block) { } | 352 is_initializer_block_(is_initializer_block) { } |
| 321 | 353 |
| 354 // Construct a clone initialized from the original block and |
| 355 // a deep copy of all statements of the original block. |
| 356 Block(Block* other, ZoneList<Statement*>* statements); |
| 357 |
| 322 virtual void Accept(AstVisitor* v); | 358 virtual void Accept(AstVisitor* v); |
| 323 | 359 |
| 360 virtual Block* AsBlock() { return this; } |
| 361 |
| 362 virtual Assignment* StatementAsSimpleAssignment() { |
| 363 if (statements_.length() != 1) return NULL; |
| 364 return statements_[0]->StatementAsSimpleAssignment(); |
| 365 } |
| 366 |
| 367 virtual CountOperation* StatementAsCountOperation() { |
| 368 if (statements_.length() != 1) return NULL; |
| 369 return statements_[0]->StatementAsCountOperation(); |
| 370 } |
| 371 |
| 324 void AddStatement(Statement* statement) { statements_.Add(statement); } | 372 void AddStatement(Statement* statement) { statements_.Add(statement); } |
| 325 | 373 |
| 326 ZoneList<Statement*>* statements() { return &statements_; } | 374 ZoneList<Statement*>* statements() { return &statements_; } |
| 327 bool is_initializer_block() const { return is_initializer_block_; } | 375 bool is_initializer_block() const { return is_initializer_block_; } |
| 328 | 376 |
| 329 private: | 377 private: |
| 330 ZoneList<Statement*> statements_; | 378 ZoneList<Statement*> statements_; |
| 331 bool is_initializer_block_; | 379 bool is_initializer_block_; |
| 332 }; | 380 }; |
| 333 | 381 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 355 FunctionLiteral* fun_; | 403 FunctionLiteral* fun_; |
| 356 }; | 404 }; |
| 357 | 405 |
| 358 | 406 |
| 359 class IterationStatement: public BreakableStatement { | 407 class IterationStatement: public BreakableStatement { |
| 360 public: | 408 public: |
| 361 // Type testing & conversion. | 409 // Type testing & conversion. |
| 362 virtual IterationStatement* AsIterationStatement() { return this; } | 410 virtual IterationStatement* AsIterationStatement() { return this; } |
| 363 | 411 |
| 364 Statement* body() const { return body_; } | 412 Statement* body() const { return body_; } |
| 413 void set_body(Statement* stmt) { body_ = stmt; } |
| 365 | 414 |
| 366 // Code generation | 415 // Code generation |
| 367 BreakTarget* continue_target() { return &continue_target_; } | 416 BreakTarget* continue_target() { return &continue_target_; } |
| 368 | 417 |
| 369 protected: | 418 protected: |
| 370 explicit IterationStatement(ZoneStringList* labels) | 419 explicit IterationStatement(ZoneStringList* labels) |
| 371 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), body_(NULL) { } | 420 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), body_(NULL) { } |
| 372 | 421 |
| 422 // Construct a clone initialized from original and |
| 423 // a deep copy of the original body. |
| 424 IterationStatement(IterationStatement* other, Statement* body); |
| 425 |
| 373 void Initialize(Statement* body) { | 426 void Initialize(Statement* body) { |
| 374 body_ = body; | 427 body_ = body; |
| 375 } | 428 } |
| 376 | 429 |
| 377 private: | 430 private: |
| 378 Statement* body_; | 431 Statement* body_; |
| 379 BreakTarget continue_target_; | 432 BreakTarget continue_target_; |
| 380 }; | 433 }; |
| 381 | 434 |
| 382 | 435 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 }; | 488 }; |
| 436 | 489 |
| 437 | 490 |
| 438 class ForStatement: public IterationStatement { | 491 class ForStatement: public IterationStatement { |
| 439 public: | 492 public: |
| 440 explicit ForStatement(ZoneStringList* labels) | 493 explicit ForStatement(ZoneStringList* labels) |
| 441 : IterationStatement(labels), | 494 : IterationStatement(labels), |
| 442 init_(NULL), | 495 init_(NULL), |
| 443 cond_(NULL), | 496 cond_(NULL), |
| 444 next_(NULL), | 497 next_(NULL), |
| 445 may_have_function_literal_(true) { | 498 may_have_function_literal_(true), |
| 446 } | 499 loop_variable_(NULL), |
| 500 peel_this_loop_(false) {} |
| 501 |
| 502 // Construct a for-statement initialized from another for-statement |
| 503 // and deep copies of all parts of the original statement. |
| 504 ForStatement(ForStatement* other, |
| 505 Statement* init, |
| 506 Expression* cond, |
| 507 Statement* next, |
| 508 Statement* body); |
| 509 |
| 510 virtual ForStatement* AsForStatement() { return this; } |
| 447 | 511 |
| 448 void Initialize(Statement* init, | 512 void Initialize(Statement* init, |
| 449 Expression* cond, | 513 Expression* cond, |
| 450 Statement* next, | 514 Statement* next, |
| 451 Statement* body) { | 515 Statement* body) { |
| 452 IterationStatement::Initialize(body); | 516 IterationStatement::Initialize(body); |
| 453 init_ = init; | 517 init_ = init; |
| 454 cond_ = cond; | 518 cond_ = cond; |
| 455 next_ = next; | 519 next_ = next; |
| 456 } | 520 } |
| 457 | 521 |
| 458 virtual void Accept(AstVisitor* v); | 522 virtual void Accept(AstVisitor* v); |
| 459 | 523 |
| 460 Statement* init() const { return init_; } | 524 Statement* init() const { return init_; } |
| 525 void set_init(Statement* stmt) { init_ = stmt; } |
| 461 Expression* cond() const { return cond_; } | 526 Expression* cond() const { return cond_; } |
| 527 void set_cond(Expression* expr) { cond_ = expr; } |
| 462 Statement* next() const { return next_; } | 528 Statement* next() const { return next_; } |
| 529 void set_next(Statement* stmt) { next_ = stmt; } |
| 463 bool may_have_function_literal() const { | 530 bool may_have_function_literal() const { |
| 464 return may_have_function_literal_; | 531 return may_have_function_literal_; |
| 465 } | 532 } |
| 466 | 533 |
| 534 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 535 Variable* loop_variable() { return loop_variable_; } |
| 536 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 537 |
| 538 bool peel_this_loop() { return peel_this_loop_; } |
| 539 void set_peel_this_loop(bool b) { peel_this_loop_ = b; } |
| 540 |
| 467 private: | 541 private: |
| 468 Statement* init_; | 542 Statement* init_; |
| 469 Expression* cond_; | 543 Expression* cond_; |
| 470 Statement* next_; | 544 Statement* next_; |
| 471 // True if there is a function literal subexpression in the condition. | 545 // True if there is a function literal subexpression in the condition. |
| 472 bool may_have_function_literal_; | 546 bool may_have_function_literal_; |
| 547 Variable* loop_variable_; |
| 548 bool peel_this_loop_; |
| 473 | 549 |
| 474 friend class AstOptimizer; | 550 friend class AstOptimizer; |
| 475 }; | 551 }; |
| 476 | 552 |
| 477 | 553 |
| 478 class ForInStatement: public IterationStatement { | 554 class ForInStatement: public IterationStatement { |
| 479 public: | 555 public: |
| 480 explicit ForInStatement(ZoneStringList* labels) | 556 explicit ForInStatement(ZoneStringList* labels) |
| 481 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } | 557 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } |
| 482 | 558 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 495 Expression* each_; | 571 Expression* each_; |
| 496 Expression* enumerable_; | 572 Expression* enumerable_; |
| 497 }; | 573 }; |
| 498 | 574 |
| 499 | 575 |
| 500 class ExpressionStatement: public Statement { | 576 class ExpressionStatement: public Statement { |
| 501 public: | 577 public: |
| 502 explicit ExpressionStatement(Expression* expression) | 578 explicit ExpressionStatement(Expression* expression) |
| 503 : expression_(expression) { } | 579 : expression_(expression) { } |
| 504 | 580 |
| 581 // Construct an expression statement initialized from another |
| 582 // expression statement and a deep copy of the original expression. |
| 583 ExpressionStatement(ExpressionStatement* other, Expression* expression); |
| 584 |
| 505 virtual void Accept(AstVisitor* v); | 585 virtual void Accept(AstVisitor* v); |
| 506 | 586 |
| 507 // Type testing & conversion. | 587 // Type testing & conversion. |
| 508 virtual ExpressionStatement* AsExpressionStatement() { return this; } | 588 virtual ExpressionStatement* AsExpressionStatement() { return this; } |
| 509 | 589 |
| 590 virtual Assignment* StatementAsSimpleAssignment(); |
| 591 virtual CountOperation* StatementAsCountOperation(); |
| 592 |
| 510 void set_expression(Expression* e) { expression_ = e; } | 593 void set_expression(Expression* e) { expression_ = e; } |
| 511 Expression* expression() { return expression_; } | 594 Expression* expression() { return expression_; } |
| 512 | 595 |
| 513 private: | 596 private: |
| 514 Expression* expression_; | 597 Expression* expression_; |
| 515 }; | 598 }; |
| 516 | 599 |
| 517 | 600 |
| 518 class ContinueStatement: public Statement { | 601 class ContinueStatement: public Statement { |
| 519 public: | 602 public: |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 // given if-statement has a then- or an else-part containing code. | 717 // given if-statement has a then- or an else-part containing code. |
| 635 class IfStatement: public Statement { | 718 class IfStatement: public Statement { |
| 636 public: | 719 public: |
| 637 IfStatement(Expression* condition, | 720 IfStatement(Expression* condition, |
| 638 Statement* then_statement, | 721 Statement* then_statement, |
| 639 Statement* else_statement) | 722 Statement* else_statement) |
| 640 : condition_(condition), | 723 : condition_(condition), |
| 641 then_statement_(then_statement), | 724 then_statement_(then_statement), |
| 642 else_statement_(else_statement) { } | 725 else_statement_(else_statement) { } |
| 643 | 726 |
| 727 // Construct an if-statement initialized from another if-statement |
| 728 // and deep copies of all parts of the original. |
| 729 IfStatement(IfStatement* other, |
| 730 Expression* condition, |
| 731 Statement* then_statement, |
| 732 Statement* else_statement); |
| 733 |
| 644 virtual void Accept(AstVisitor* v); | 734 virtual void Accept(AstVisitor* v); |
| 645 | 735 |
| 646 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 736 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
| 647 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 737 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
| 648 | 738 |
| 649 Expression* condition() const { return condition_; } | 739 Expression* condition() const { return condition_; } |
| 650 Statement* then_statement() const { return then_statement_; } | 740 Statement* then_statement() const { return then_statement_; } |
| 741 void set_then_statement(Statement* stmt) { then_statement_ = stmt; } |
| 651 Statement* else_statement() const { return else_statement_; } | 742 Statement* else_statement() const { return else_statement_; } |
| 743 void set_else_statement(Statement* stmt) { else_statement_ = stmt; } |
| 652 | 744 |
| 653 private: | 745 private: |
| 654 Expression* condition_; | 746 Expression* condition_; |
| 655 Statement* then_statement_; | 747 Statement* then_statement_; |
| 656 Statement* else_statement_; | 748 Statement* else_statement_; |
| 657 }; | 749 }; |
| 658 | 750 |
| 659 | 751 |
| 660 // NOTE: TargetCollectors are represented as nodes to fit in the target | 752 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 661 // stack in the compiler; this should probably be reworked. | 753 // stack in the compiler; this should probably be reworked. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 | 828 |
| 737 | 829 |
| 738 class DebuggerStatement: public Statement { | 830 class DebuggerStatement: public Statement { |
| 739 public: | 831 public: |
| 740 virtual void Accept(AstVisitor* v); | 832 virtual void Accept(AstVisitor* v); |
| 741 }; | 833 }; |
| 742 | 834 |
| 743 | 835 |
| 744 class EmptyStatement: public Statement { | 836 class EmptyStatement: public Statement { |
| 745 public: | 837 public: |
| 838 EmptyStatement() {} |
| 839 |
| 840 explicit EmptyStatement(EmptyStatement* other); |
| 841 |
| 746 virtual void Accept(AstVisitor* v); | 842 virtual void Accept(AstVisitor* v); |
| 747 | 843 |
| 748 // Type testing & conversion. | 844 // Type testing & conversion. |
| 749 virtual EmptyStatement* AsEmptyStatement() { return this; } | 845 virtual EmptyStatement* AsEmptyStatement() { return this; } |
| 750 }; | 846 }; |
| 751 | 847 |
| 752 | 848 |
| 753 class Literal: public Expression { | 849 class Literal: public Expression { |
| 754 public: | 850 public: |
| 755 explicit Literal(Handle<Object> handle) : handle_(handle) { } | 851 explicit Literal(Handle<Object> handle) : handle_(handle) { } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 767 virtual bool IsPropertyName() { | 863 virtual bool IsPropertyName() { |
| 768 if (handle_->IsSymbol()) { | 864 if (handle_->IsSymbol()) { |
| 769 uint32_t ignored; | 865 uint32_t ignored; |
| 770 return !String::cast(*handle_)->AsArrayIndex(&ignored); | 866 return !String::cast(*handle_)->AsArrayIndex(&ignored); |
| 771 } | 867 } |
| 772 return false; | 868 return false; |
| 773 } | 869 } |
| 774 | 870 |
| 775 virtual bool IsLeaf() { return true; } | 871 virtual bool IsLeaf() { return true; } |
| 776 virtual bool IsTrivial() { return true; } | 872 virtual bool IsTrivial() { return true; } |
| 873 virtual bool IsPrimitive(); |
| 777 | 874 |
| 778 // Identity testers. | 875 // Identity testers. |
| 779 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); } | 876 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); } |
| 780 bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); } | 877 bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); } |
| 781 bool IsFalse() const { | 878 bool IsFalse() const { |
| 782 return handle_.is_identical_to(Factory::false_value()); | 879 return handle_.is_identical_to(Factory::false_value()); |
| 783 } | 880 } |
| 784 | 881 |
| 785 Handle<Object> handle() const { return handle_; } | 882 Handle<Object> handle() const { return handle_; } |
| 786 | 883 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 private: | 939 private: |
| 843 Literal* key_; | 940 Literal* key_; |
| 844 Expression* value_; | 941 Expression* value_; |
| 845 Kind kind_; | 942 Kind kind_; |
| 846 }; | 943 }; |
| 847 | 944 |
| 848 ObjectLiteral(Handle<FixedArray> constant_properties, | 945 ObjectLiteral(Handle<FixedArray> constant_properties, |
| 849 ZoneList<Property*>* properties, | 946 ZoneList<Property*>* properties, |
| 850 int literal_index, | 947 int literal_index, |
| 851 bool is_simple, | 948 bool is_simple, |
| 949 bool fast_elements, |
| 852 int depth) | 950 int depth) |
| 853 : MaterializedLiteral(literal_index, is_simple, depth), | 951 : MaterializedLiteral(literal_index, is_simple, depth), |
| 854 constant_properties_(constant_properties), | 952 constant_properties_(constant_properties), |
| 855 properties_(properties) {} | 953 properties_(properties), |
| 954 fast_elements_(fast_elements) {} |
| 856 | 955 |
| 857 virtual ObjectLiteral* AsObjectLiteral() { return this; } | 956 virtual ObjectLiteral* AsObjectLiteral() { return this; } |
| 858 virtual void Accept(AstVisitor* v); | 957 virtual void Accept(AstVisitor* v); |
| 859 | 958 |
| 860 virtual bool IsLeaf() { return properties()->is_empty(); } | 959 virtual bool IsLeaf() { return properties()->is_empty(); } |
| 861 | 960 |
| 961 virtual bool IsPrimitive(); |
| 962 |
| 862 Handle<FixedArray> constant_properties() const { | 963 Handle<FixedArray> constant_properties() const { |
| 863 return constant_properties_; | 964 return constant_properties_; |
| 864 } | 965 } |
| 865 ZoneList<Property*>* properties() const { return properties_; } | 966 ZoneList<Property*>* properties() const { return properties_; } |
| 866 | 967 |
| 968 bool fast_elements() const { return fast_elements_; } |
| 969 |
| 867 private: | 970 private: |
| 868 Handle<FixedArray> constant_properties_; | 971 Handle<FixedArray> constant_properties_; |
| 869 ZoneList<Property*>* properties_; | 972 ZoneList<Property*>* properties_; |
| 973 bool fast_elements_; |
| 870 }; | 974 }; |
| 871 | 975 |
| 872 | 976 |
| 873 // Node for capturing a regexp literal. | 977 // Node for capturing a regexp literal. |
| 874 class RegExpLiteral: public MaterializedLiteral { | 978 class RegExpLiteral: public MaterializedLiteral { |
| 875 public: | 979 public: |
| 876 RegExpLiteral(Handle<String> pattern, | 980 RegExpLiteral(Handle<String> pattern, |
| 877 Handle<String> flags, | 981 Handle<String> flags, |
| 878 int literal_index) | 982 int literal_index) |
| 879 : MaterializedLiteral(literal_index, false, 1), | 983 : MaterializedLiteral(literal_index, false, 1), |
| 880 pattern_(pattern), | 984 pattern_(pattern), |
| 881 flags_(flags) {} | 985 flags_(flags) {} |
| 882 | 986 |
| 883 virtual void Accept(AstVisitor* v); | 987 virtual void Accept(AstVisitor* v); |
| 884 | 988 |
| 885 virtual bool IsLeaf() { return true; } | 989 virtual bool IsLeaf() { return true; } |
| 886 | 990 |
| 991 virtual bool IsPrimitive(); |
| 992 |
| 887 Handle<String> pattern() const { return pattern_; } | 993 Handle<String> pattern() const { return pattern_; } |
| 888 Handle<String> flags() const { return flags_; } | 994 Handle<String> flags() const { return flags_; } |
| 889 | 995 |
| 890 private: | 996 private: |
| 891 Handle<String> pattern_; | 997 Handle<String> pattern_; |
| 892 Handle<String> flags_; | 998 Handle<String> flags_; |
| 893 }; | 999 }; |
| 894 | 1000 |
| 895 // An array literal has a literals object that is used | 1001 // An array literal has a literals object that is used |
| 896 // for minimizing the work when constructing it at runtime. | 1002 // for minimizing the work when constructing it at runtime. |
| 897 class ArrayLiteral: public MaterializedLiteral { | 1003 class ArrayLiteral: public MaterializedLiteral { |
| 898 public: | 1004 public: |
| 899 ArrayLiteral(Handle<FixedArray> constant_elements, | 1005 ArrayLiteral(Handle<FixedArray> constant_elements, |
| 900 ZoneList<Expression*>* values, | 1006 ZoneList<Expression*>* values, |
| 901 int literal_index, | 1007 int literal_index, |
| 902 bool is_simple, | 1008 bool is_simple, |
| 903 int depth) | 1009 int depth) |
| 904 : MaterializedLiteral(literal_index, is_simple, depth), | 1010 : MaterializedLiteral(literal_index, is_simple, depth), |
| 905 constant_elements_(constant_elements), | 1011 constant_elements_(constant_elements), |
| 906 values_(values) {} | 1012 values_(values) {} |
| 907 | 1013 |
| 908 virtual void Accept(AstVisitor* v); | 1014 virtual void Accept(AstVisitor* v); |
| 909 virtual ArrayLiteral* AsArrayLiteral() { return this; } | 1015 virtual ArrayLiteral* AsArrayLiteral() { return this; } |
| 910 | 1016 |
| 911 virtual bool IsLeaf() { return values()->is_empty(); } | 1017 virtual bool IsLeaf() { return values()->is_empty(); } |
| 912 | 1018 |
| 1019 virtual bool IsPrimitive(); |
| 1020 |
| 913 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1021 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
| 914 ZoneList<Expression*>* values() const { return values_; } | 1022 ZoneList<Expression*>* values() const { return values_; } |
| 915 | 1023 |
| 916 private: | 1024 private: |
| 917 Handle<FixedArray> constant_elements_; | 1025 Handle<FixedArray> constant_elements_; |
| 918 ZoneList<Expression*>* values_; | 1026 ZoneList<Expression*>* values_; |
| 919 }; | 1027 }; |
| 920 | 1028 |
| 921 | 1029 |
| 922 // Node for constructing a context extension object for a catch block. | 1030 // Node for constructing a context extension object for a catch block. |
| 923 // The catch context extension object has one property, the catch | 1031 // The catch context extension object has one property, the catch |
| 924 // variable, which should be DontDelete. | 1032 // variable, which should be DontDelete. |
| 925 class CatchExtensionObject: public Expression { | 1033 class CatchExtensionObject: public Expression { |
| 926 public: | 1034 public: |
| 927 CatchExtensionObject(Literal* key, VariableProxy* value) | 1035 CatchExtensionObject(Literal* key, VariableProxy* value) |
| 928 : key_(key), value_(value) { | 1036 : key_(key), value_(value) { |
| 929 } | 1037 } |
| 930 | 1038 |
| 931 virtual void Accept(AstVisitor* v); | 1039 virtual void Accept(AstVisitor* v); |
| 932 | 1040 |
| 1041 virtual bool IsPrimitive(); |
| 1042 |
| 933 Literal* key() const { return key_; } | 1043 Literal* key() const { return key_; } |
| 934 VariableProxy* value() const { return value_; } | 1044 VariableProxy* value() const { return value_; } |
| 935 | 1045 |
| 936 private: | 1046 private: |
| 937 Literal* key_; | 1047 Literal* key_; |
| 938 VariableProxy* value_; | 1048 VariableProxy* value_; |
| 939 }; | 1049 }; |
| 940 | 1050 |
| 941 | 1051 |
| 942 class VariableProxy: public Expression { | 1052 class VariableProxy: public Expression { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 957 return var_ == NULL ? true : var_->IsValidLeftHandSide(); | 1067 return var_ == NULL ? true : var_->IsValidLeftHandSide(); |
| 958 } | 1068 } |
| 959 | 1069 |
| 960 virtual bool IsLeaf() { | 1070 virtual bool IsLeaf() { |
| 961 ASSERT(var_ != NULL); // Variable must be resolved. | 1071 ASSERT(var_ != NULL); // Variable must be resolved. |
| 962 return var()->is_global() || var()->rewrite()->IsLeaf(); | 1072 return var()->is_global() || var()->rewrite()->IsLeaf(); |
| 963 } | 1073 } |
| 964 | 1074 |
| 965 // Reading from a mutable variable is a side effect, but 'this' is | 1075 // Reading from a mutable variable is a side effect, but 'this' is |
| 966 // immutable. | 1076 // immutable. |
| 967 virtual bool IsTrivial() { return is_this(); } | 1077 virtual bool IsTrivial() { return is_trivial_; } |
| 1078 |
| 1079 virtual bool IsPrimitive(); |
| 968 | 1080 |
| 969 bool IsVariable(Handle<String> n) { | 1081 bool IsVariable(Handle<String> n) { |
| 970 return !is_this() && name().is_identical_to(n); | 1082 return !is_this() && name().is_identical_to(n); |
| 971 } | 1083 } |
| 972 | 1084 |
| 973 bool IsArguments() { | 1085 bool IsArguments() { |
| 974 Variable* variable = AsVariable(); | 1086 Variable* variable = AsVariable(); |
| 975 return (variable == NULL) ? false : variable->is_arguments(); | 1087 return (variable == NULL) ? false : variable->is_arguments(); |
| 976 } | 1088 } |
| 977 | 1089 |
| 978 Handle<String> name() const { return name_; } | 1090 Handle<String> name() const { return name_; } |
| 979 Variable* var() const { return var_; } | 1091 Variable* var() const { return var_; } |
| 980 bool is_this() const { return is_this_; } | 1092 bool is_this() const { return is_this_; } |
| 981 bool inside_with() const { return inside_with_; } | 1093 bool inside_with() const { return inside_with_; } |
| 1094 bool is_trivial() { return is_trivial_; } |
| 1095 void set_is_trivial(bool b) { is_trivial_ = b; } |
| 1096 |
| 1097 BitVector* reaching_definitions() { return reaching_definitions_; } |
| 1098 void set_reaching_definitions(BitVector* rd) { reaching_definitions_ = rd; } |
| 982 | 1099 |
| 983 // Bind this proxy to the variable var. | 1100 // Bind this proxy to the variable var. |
| 984 void BindTo(Variable* var); | 1101 void BindTo(Variable* var); |
| 985 | 1102 |
| 986 protected: | 1103 protected: |
| 987 Handle<String> name_; | 1104 Handle<String> name_; |
| 988 Variable* var_; // resolved variable, or NULL | 1105 Variable* var_; // resolved variable, or NULL |
| 989 bool is_this_; | 1106 bool is_this_; |
| 990 bool inside_with_; | 1107 bool inside_with_; |
| 1108 bool is_trivial_; |
| 1109 BitVector* reaching_definitions_; |
| 991 | 1110 |
| 992 VariableProxy(Handle<String> name, bool is_this, bool inside_with); | 1111 VariableProxy(Handle<String> name, bool is_this, bool inside_with); |
| 993 explicit VariableProxy(bool is_this); | 1112 explicit VariableProxy(bool is_this); |
| 994 | 1113 |
| 995 friend class Scope; | 1114 friend class Scope; |
| 996 }; | 1115 }; |
| 997 | 1116 |
| 998 | 1117 |
| 999 class VariableProxySentinel: public VariableProxy { | 1118 class VariableProxySentinel: public VariableProxy { |
| 1000 public: | 1119 public: |
| 1001 virtual bool IsValidLeftHandSide() { return !is_this(); } | 1120 virtual bool IsValidLeftHandSide() { return !is_this(); } |
| 1002 static VariableProxySentinel* this_proxy() { return &this_proxy_; } | 1121 static VariableProxySentinel* this_proxy() { return &this_proxy_; } |
| 1003 static VariableProxySentinel* identifier_proxy() { | 1122 static VariableProxySentinel* identifier_proxy() { |
| 1004 return &identifier_proxy_; | 1123 return &identifier_proxy_; |
| 1005 } | 1124 } |
| 1006 | 1125 |
| 1126 virtual bool IsPrimitive() { |
| 1127 UNREACHABLE(); |
| 1128 return false; |
| 1129 } |
| 1130 |
| 1007 private: | 1131 private: |
| 1008 explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { } | 1132 explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { } |
| 1009 static VariableProxySentinel this_proxy_; | 1133 static VariableProxySentinel this_proxy_; |
| 1010 static VariableProxySentinel identifier_proxy_; | 1134 static VariableProxySentinel identifier_proxy_; |
| 1011 }; | 1135 }; |
| 1012 | 1136 |
| 1013 | 1137 |
| 1014 class Slot: public Expression { | 1138 class Slot: public Expression { |
| 1015 public: | 1139 public: |
| 1016 enum Type { | 1140 enum Type { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1040 ASSERT(var != NULL); | 1164 ASSERT(var != NULL); |
| 1041 } | 1165 } |
| 1042 | 1166 |
| 1043 virtual void Accept(AstVisitor* v); | 1167 virtual void Accept(AstVisitor* v); |
| 1044 | 1168 |
| 1045 // Type testing & conversion | 1169 // Type testing & conversion |
| 1046 virtual Slot* AsSlot() { return this; } | 1170 virtual Slot* AsSlot() { return this; } |
| 1047 | 1171 |
| 1048 virtual bool IsLeaf() { return true; } | 1172 virtual bool IsLeaf() { return true; } |
| 1049 | 1173 |
| 1174 virtual bool IsPrimitive() { |
| 1175 UNREACHABLE(); |
| 1176 return false; |
| 1177 } |
| 1178 |
| 1050 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; } | 1179 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; } |
| 1051 | 1180 |
| 1052 // Accessors | 1181 // Accessors |
| 1053 Variable* var() const { return var_; } | 1182 Variable* var() const { return var_; } |
| 1054 Type type() const { return type_; } | 1183 Type type() const { return type_; } |
| 1055 int index() const { return index_; } | 1184 int index() const { return index_; } |
| 1056 bool is_arguments() const { return var_->is_arguments(); } | 1185 bool is_arguments() const { return var_->is_arguments(); } |
| 1057 | 1186 |
| 1058 private: | 1187 private: |
| 1059 Variable* var_; | 1188 Variable* var_; |
| 1060 Type type_; | 1189 Type type_; |
| 1061 int index_; | 1190 int index_; |
| 1062 }; | 1191 }; |
| 1063 | 1192 |
| 1064 | 1193 |
| 1065 class Property: public Expression { | 1194 class Property: public Expression { |
| 1066 public: | 1195 public: |
| 1067 // Synthetic properties are property lookups introduced by the system, | 1196 // Synthetic properties are property lookups introduced by the system, |
| 1068 // to objects that aren't visible to the user. Function calls to synthetic | 1197 // to objects that aren't visible to the user. Function calls to synthetic |
| 1069 // properties should use the global object as receiver, not the base object | 1198 // properties should use the global object as receiver, not the base object |
| 1070 // of the resolved Reference. | 1199 // of the resolved Reference. |
| 1071 enum Type { NORMAL, SYNTHETIC }; | 1200 enum Type { NORMAL, SYNTHETIC }; |
| 1072 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) | 1201 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) |
| 1073 : obj_(obj), key_(key), pos_(pos), type_(type) { } | 1202 : obj_(obj), key_(key), pos_(pos), type_(type) { } |
| 1074 | 1203 |
| 1204 Property(Property* other, Expression* obj, Expression* key); |
| 1205 |
| 1075 virtual void Accept(AstVisitor* v); | 1206 virtual void Accept(AstVisitor* v); |
| 1076 | 1207 |
| 1077 // Type testing & conversion | 1208 // Type testing & conversion |
| 1078 virtual Property* AsProperty() { return this; } | 1209 virtual Property* AsProperty() { return this; } |
| 1079 | 1210 |
| 1080 virtual bool IsValidLeftHandSide() { return true; } | 1211 virtual bool IsValidLeftHandSide() { return true; } |
| 1081 | 1212 |
| 1213 virtual bool IsPrimitive(); |
| 1214 |
| 1082 Expression* obj() const { return obj_; } | 1215 Expression* obj() const { return obj_; } |
| 1083 Expression* key() const { return key_; } | 1216 Expression* key() const { return key_; } |
| 1084 int position() const { return pos_; } | 1217 int position() const { return pos_; } |
| 1085 bool is_synthetic() const { return type_ == SYNTHETIC; } | 1218 bool is_synthetic() const { return type_ == SYNTHETIC; } |
| 1086 | 1219 |
| 1087 // Returns a property singleton property access on 'this'. Used | 1220 // Returns a property singleton property access on 'this'. Used |
| 1088 // during preparsing. | 1221 // during preparsing. |
| 1089 static Property* this_property() { return &this_property_; } | 1222 static Property* this_property() { return &this_property_; } |
| 1090 | 1223 |
| 1091 private: | 1224 private: |
| 1092 Expression* obj_; | 1225 Expression* obj_; |
| 1093 Expression* key_; | 1226 Expression* key_; |
| 1094 int pos_; | 1227 int pos_; |
| 1095 Type type_; | 1228 Type type_; |
| 1096 | 1229 |
| 1097 // Dummy property used during preparsing. | 1230 // Dummy property used during preparsing. |
| 1098 static Property this_property_; | 1231 static Property this_property_; |
| 1099 }; | 1232 }; |
| 1100 | 1233 |
| 1101 | 1234 |
| 1102 class Call: public Expression { | 1235 class Call: public Expression { |
| 1103 public: | 1236 public: |
| 1104 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1237 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 1105 : expression_(expression), arguments_(arguments), pos_(pos) { } | 1238 : expression_(expression), arguments_(arguments), pos_(pos) { } |
| 1106 | 1239 |
| 1240 Call(Call* other, Expression* expression, ZoneList<Expression*>* arguments); |
| 1241 |
| 1107 virtual void Accept(AstVisitor* v); | 1242 virtual void Accept(AstVisitor* v); |
| 1108 | 1243 |
| 1109 // Type testing and conversion. | 1244 // Type testing and conversion. |
| 1110 virtual Call* AsCall() { return this; } | 1245 virtual Call* AsCall() { return this; } |
| 1111 | 1246 |
| 1247 virtual bool IsPrimitive(); |
| 1248 |
| 1112 Expression* expression() const { return expression_; } | 1249 Expression* expression() const { return expression_; } |
| 1113 ZoneList<Expression*>* arguments() const { return arguments_; } | 1250 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1114 int position() { return pos_; } | 1251 int position() { return pos_; } |
| 1115 | 1252 |
| 1116 static Call* sentinel() { return &sentinel_; } | 1253 static Call* sentinel() { return &sentinel_; } |
| 1117 | 1254 |
| 1118 private: | 1255 private: |
| 1119 Expression* expression_; | 1256 Expression* expression_; |
| 1120 ZoneList<Expression*>* arguments_; | 1257 ZoneList<Expression*>* arguments_; |
| 1121 int pos_; | 1258 int pos_; |
| 1122 | 1259 |
| 1123 static Call sentinel_; | 1260 static Call sentinel_; |
| 1124 }; | 1261 }; |
| 1125 | 1262 |
| 1126 | 1263 |
| 1127 class CallNew: public Expression { | 1264 class CallNew: public Expression { |
| 1128 public: | 1265 public: |
| 1129 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1266 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 1130 : expression_(expression), arguments_(arguments), pos_(pos) { } | 1267 : expression_(expression), arguments_(arguments), pos_(pos) { } |
| 1131 | 1268 |
| 1132 virtual void Accept(AstVisitor* v); | 1269 virtual void Accept(AstVisitor* v); |
| 1133 | 1270 |
| 1271 virtual bool IsPrimitive(); |
| 1272 |
| 1134 Expression* expression() const { return expression_; } | 1273 Expression* expression() const { return expression_; } |
| 1135 ZoneList<Expression*>* arguments() const { return arguments_; } | 1274 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1136 int position() { return pos_; } | 1275 int position() { return pos_; } |
| 1137 | 1276 |
| 1138 private: | 1277 private: |
| 1139 Expression* expression_; | 1278 Expression* expression_; |
| 1140 ZoneList<Expression*>* arguments_; | 1279 ZoneList<Expression*>* arguments_; |
| 1141 int pos_; | 1280 int pos_; |
| 1142 }; | 1281 }; |
| 1143 | 1282 |
| 1144 | 1283 |
| 1145 // The CallRuntime class does not represent any official JavaScript | 1284 // The CallRuntime class does not represent any official JavaScript |
| 1146 // language construct. Instead it is used to call a C or JS function | 1285 // language construct. Instead it is used to call a C or JS function |
| 1147 // with a set of arguments. This is used from the builtins that are | 1286 // with a set of arguments. This is used from the builtins that are |
| 1148 // implemented in JavaScript (see "v8natives.js"). | 1287 // implemented in JavaScript (see "v8natives.js"). |
| 1149 class CallRuntime: public Expression { | 1288 class CallRuntime: public Expression { |
| 1150 public: | 1289 public: |
| 1151 CallRuntime(Handle<String> name, | 1290 CallRuntime(Handle<String> name, |
| 1152 Runtime::Function* function, | 1291 Runtime::Function* function, |
| 1153 ZoneList<Expression*>* arguments) | 1292 ZoneList<Expression*>* arguments) |
| 1154 : name_(name), function_(function), arguments_(arguments) { } | 1293 : name_(name), function_(function), arguments_(arguments) { } |
| 1155 | 1294 |
| 1156 virtual void Accept(AstVisitor* v); | 1295 virtual void Accept(AstVisitor* v); |
| 1157 | 1296 |
| 1297 virtual bool IsPrimitive(); |
| 1298 |
| 1158 Handle<String> name() const { return name_; } | 1299 Handle<String> name() const { return name_; } |
| 1159 Runtime::Function* function() const { return function_; } | 1300 Runtime::Function* function() const { return function_; } |
| 1160 ZoneList<Expression*>* arguments() const { return arguments_; } | 1301 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1161 bool is_jsruntime() const { return function_ == NULL; } | 1302 bool is_jsruntime() const { return function_ == NULL; } |
| 1162 | 1303 |
| 1163 private: | 1304 private: |
| 1164 Handle<String> name_; | 1305 Handle<String> name_; |
| 1165 Runtime::Function* function_; | 1306 Runtime::Function* function_; |
| 1166 ZoneList<Expression*>* arguments_; | 1307 ZoneList<Expression*>* arguments_; |
| 1167 }; | 1308 }; |
| 1168 | 1309 |
| 1169 | 1310 |
| 1170 class UnaryOperation: public Expression { | 1311 class UnaryOperation: public Expression { |
| 1171 public: | 1312 public: |
| 1172 UnaryOperation(Token::Value op, Expression* expression) | 1313 UnaryOperation(Token::Value op, Expression* expression) |
| 1173 : op_(op), expression_(expression) { | 1314 : op_(op), expression_(expression) { |
| 1174 ASSERT(Token::IsUnaryOp(op)); | 1315 ASSERT(Token::IsUnaryOp(op)); |
| 1175 } | 1316 } |
| 1176 | 1317 |
| 1318 UnaryOperation(UnaryOperation* other, Expression* expression); |
| 1319 |
| 1177 virtual void Accept(AstVisitor* v); | 1320 virtual void Accept(AstVisitor* v); |
| 1178 | 1321 |
| 1179 // Type testing & conversion | 1322 // Type testing & conversion |
| 1180 virtual UnaryOperation* AsUnaryOperation() { return this; } | 1323 virtual UnaryOperation* AsUnaryOperation() { return this; } |
| 1181 | 1324 |
| 1325 virtual bool IsPrimitive(); |
| 1326 |
| 1182 Token::Value op() const { return op_; } | 1327 Token::Value op() const { return op_; } |
| 1183 Expression* expression() const { return expression_; } | 1328 Expression* expression() const { return expression_; } |
| 1184 | 1329 |
| 1185 private: | 1330 private: |
| 1186 Token::Value op_; | 1331 Token::Value op_; |
| 1187 Expression* expression_; | 1332 Expression* expression_; |
| 1188 }; | 1333 }; |
| 1189 | 1334 |
| 1190 | 1335 |
| 1191 class BinaryOperation: public Expression { | 1336 class BinaryOperation: public Expression { |
| 1192 public: | 1337 public: |
| 1193 BinaryOperation(Token::Value op, Expression* left, Expression* right) | 1338 BinaryOperation(Token::Value op, Expression* left, Expression* right) |
| 1194 : op_(op), left_(left), right_(right) { | 1339 : op_(op), left_(left), right_(right) { |
| 1195 ASSERT(Token::IsBinaryOp(op)); | 1340 ASSERT(Token::IsBinaryOp(op)); |
| 1196 } | 1341 } |
| 1197 | 1342 |
| 1343 BinaryOperation(BinaryOperation* other, Expression* left, Expression* right); |
| 1344 |
| 1198 virtual void Accept(AstVisitor* v); | 1345 virtual void Accept(AstVisitor* v); |
| 1199 | 1346 |
| 1200 // Type testing & conversion | 1347 // Type testing & conversion |
| 1201 virtual BinaryOperation* AsBinaryOperation() { return this; } | 1348 virtual BinaryOperation* AsBinaryOperation() { return this; } |
| 1202 | 1349 |
| 1350 virtual bool IsPrimitive(); |
| 1351 |
| 1203 // True iff the result can be safely overwritten (to avoid allocation). | 1352 // True iff the result can be safely overwritten (to avoid allocation). |
| 1204 // False for operations that can return one of their operands. | 1353 // False for operations that can return one of their operands. |
| 1205 bool ResultOverwriteAllowed() { | 1354 bool ResultOverwriteAllowed() { |
| 1206 switch (op_) { | 1355 switch (op_) { |
| 1207 case Token::COMMA: | 1356 case Token::COMMA: |
| 1208 case Token::OR: | 1357 case Token::OR: |
| 1209 case Token::AND: | 1358 case Token::AND: |
| 1210 return false; | 1359 return false; |
| 1211 case Token::BIT_OR: | 1360 case Token::BIT_OR: |
| 1212 case Token::BIT_XOR: | 1361 case Token::BIT_XOR: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1237 }; | 1386 }; |
| 1238 | 1387 |
| 1239 | 1388 |
| 1240 class CountOperation: public Expression { | 1389 class CountOperation: public Expression { |
| 1241 public: | 1390 public: |
| 1242 CountOperation(bool is_prefix, Token::Value op, Expression* expression) | 1391 CountOperation(bool is_prefix, Token::Value op, Expression* expression) |
| 1243 : is_prefix_(is_prefix), op_(op), expression_(expression) { | 1392 : is_prefix_(is_prefix), op_(op), expression_(expression) { |
| 1244 ASSERT(Token::IsCountOp(op)); | 1393 ASSERT(Token::IsCountOp(op)); |
| 1245 } | 1394 } |
| 1246 | 1395 |
| 1396 CountOperation(CountOperation* other, Expression* expression); |
| 1397 |
| 1247 virtual void Accept(AstVisitor* v); | 1398 virtual void Accept(AstVisitor* v); |
| 1248 | 1399 |
| 1400 virtual CountOperation* AsCountOperation() { return this; } |
| 1401 |
| 1402 virtual Variable* AssignedVar() { |
| 1403 return expression()->AsVariableProxy()->AsVariable(); |
| 1404 } |
| 1405 |
| 1406 virtual bool IsPrimitive(); |
| 1407 |
| 1249 bool is_prefix() const { return is_prefix_; } | 1408 bool is_prefix() const { return is_prefix_; } |
| 1250 bool is_postfix() const { return !is_prefix_; } | 1409 bool is_postfix() const { return !is_prefix_; } |
| 1251 Token::Value op() const { return op_; } | 1410 Token::Value op() const { return op_; } |
| 1252 Token::Value binary_op() { | 1411 Token::Value binary_op() { |
| 1253 return op_ == Token::INC ? Token::ADD : Token::SUB; | 1412 return op_ == Token::INC ? Token::ADD : Token::SUB; |
| 1254 } | 1413 } |
| 1255 Expression* expression() const { return expression_; } | 1414 Expression* expression() const { return expression_; } |
| 1256 | 1415 |
| 1257 virtual void MarkAsStatement() { is_prefix_ = true; } | 1416 virtual void MarkAsStatement() { is_prefix_ = true; } |
| 1258 | 1417 |
| 1259 private: | 1418 private: |
| 1260 bool is_prefix_; | 1419 bool is_prefix_; |
| 1261 Token::Value op_; | 1420 Token::Value op_; |
| 1262 Expression* expression_; | 1421 Expression* expression_; |
| 1263 }; | 1422 }; |
| 1264 | 1423 |
| 1265 | 1424 |
| 1266 class CompareOperation: public Expression { | 1425 class CompareOperation: public Expression { |
| 1267 public: | 1426 public: |
| 1268 CompareOperation(Token::Value op, Expression* left, Expression* right) | 1427 CompareOperation(Token::Value op, Expression* left, Expression* right) |
| 1269 : op_(op), left_(left), right_(right), is_for_loop_condition_(false) { | 1428 : op_(op), left_(left), right_(right), is_for_loop_condition_(false) { |
| 1270 ASSERT(Token::IsCompareOp(op)); | 1429 ASSERT(Token::IsCompareOp(op)); |
| 1271 } | 1430 } |
| 1272 | 1431 |
| 1432 CompareOperation(CompareOperation* other, |
| 1433 Expression* left, |
| 1434 Expression* right); |
| 1435 |
| 1273 virtual void Accept(AstVisitor* v); | 1436 virtual void Accept(AstVisitor* v); |
| 1274 | 1437 |
| 1438 virtual bool IsPrimitive(); |
| 1439 |
| 1275 Token::Value op() const { return op_; } | 1440 Token::Value op() const { return op_; } |
| 1276 Expression* left() const { return left_; } | 1441 Expression* left() const { return left_; } |
| 1277 Expression* right() const { return right_; } | 1442 Expression* right() const { return right_; } |
| 1278 | 1443 |
| 1279 // Accessors for flag whether this compare operation is hanging of a for loop. | 1444 // Accessors for flag whether this compare operation is hanging of a for loop. |
| 1280 bool is_for_loop_condition() const { return is_for_loop_condition_; } | 1445 bool is_for_loop_condition() const { return is_for_loop_condition_; } |
| 1281 void set_is_for_loop_condition() { is_for_loop_condition_ = true; } | 1446 void set_is_for_loop_condition() { is_for_loop_condition_ = true; } |
| 1282 | 1447 |
| 1283 // Type testing & conversion | 1448 // Type testing & conversion |
| 1284 virtual CompareOperation* AsCompareOperation() { return this; } | 1449 virtual CompareOperation* AsCompareOperation() { return this; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1295 public: | 1460 public: |
| 1296 Conditional(Expression* condition, | 1461 Conditional(Expression* condition, |
| 1297 Expression* then_expression, | 1462 Expression* then_expression, |
| 1298 Expression* else_expression) | 1463 Expression* else_expression) |
| 1299 : condition_(condition), | 1464 : condition_(condition), |
| 1300 then_expression_(then_expression), | 1465 then_expression_(then_expression), |
| 1301 else_expression_(else_expression) { } | 1466 else_expression_(else_expression) { } |
| 1302 | 1467 |
| 1303 virtual void Accept(AstVisitor* v); | 1468 virtual void Accept(AstVisitor* v); |
| 1304 | 1469 |
| 1470 virtual bool IsPrimitive(); |
| 1471 |
| 1305 Expression* condition() const { return condition_; } | 1472 Expression* condition() const { return condition_; } |
| 1306 Expression* then_expression() const { return then_expression_; } | 1473 Expression* then_expression() const { return then_expression_; } |
| 1307 Expression* else_expression() const { return else_expression_; } | 1474 Expression* else_expression() const { return else_expression_; } |
| 1308 | 1475 |
| 1309 private: | 1476 private: |
| 1310 Expression* condition_; | 1477 Expression* condition_; |
| 1311 Expression* then_expression_; | 1478 Expression* then_expression_; |
| 1312 Expression* else_expression_; | 1479 Expression* else_expression_; |
| 1313 }; | 1480 }; |
| 1314 | 1481 |
| 1315 | 1482 |
| 1316 class Assignment: public Expression { | 1483 class Assignment: public Expression { |
| 1317 public: | 1484 public: |
| 1318 Assignment(Token::Value op, Expression* target, Expression* value, int pos) | 1485 Assignment(Token::Value op, Expression* target, Expression* value, int pos) |
| 1319 : op_(op), target_(target), value_(value), pos_(pos), | 1486 : op_(op), target_(target), value_(value), pos_(pos), |
| 1320 block_start_(false), block_end_(false) { | 1487 block_start_(false), block_end_(false) { |
| 1321 ASSERT(Token::IsAssignmentOp(op)); | 1488 ASSERT(Token::IsAssignmentOp(op)); |
| 1322 } | 1489 } |
| 1323 | 1490 |
| 1491 Assignment(Assignment* other, Expression* target, Expression* value); |
| 1492 |
| 1324 virtual void Accept(AstVisitor* v); | 1493 virtual void Accept(AstVisitor* v); |
| 1325 virtual Assignment* AsAssignment() { return this; } | 1494 virtual Assignment* AsAssignment() { return this; } |
| 1326 | 1495 |
| 1496 virtual bool IsPrimitive(); |
| 1497 |
| 1498 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
| 1499 |
| 1500 virtual Variable* AssignedVar() { |
| 1501 return target()->AsVariableProxy()->AsVariable(); |
| 1502 } |
| 1503 |
| 1327 Token::Value binary_op() const; | 1504 Token::Value binary_op() const; |
| 1328 | 1505 |
| 1329 Token::Value op() const { return op_; } | 1506 Token::Value op() const { return op_; } |
| 1330 Expression* target() const { return target_; } | 1507 Expression* target() const { return target_; } |
| 1331 Expression* value() const { return value_; } | 1508 Expression* value() const { return value_; } |
| 1332 int position() { return pos_; } | 1509 int position() { return pos_; } |
| 1333 // This check relies on the definition order of token in token.h. | 1510 // This check relies on the definition order of token in token.h. |
| 1334 bool is_compound() const { return op() > Token::ASSIGN; } | 1511 bool is_compound() const { return op() > Token::ASSIGN; } |
| 1335 | 1512 |
| 1336 // An initialization block is a series of statments of the form | 1513 // An initialization block is a series of statments of the form |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1351 bool block_end_; | 1528 bool block_end_; |
| 1352 }; | 1529 }; |
| 1353 | 1530 |
| 1354 | 1531 |
| 1355 class Throw: public Expression { | 1532 class Throw: public Expression { |
| 1356 public: | 1533 public: |
| 1357 Throw(Expression* exception, int pos) | 1534 Throw(Expression* exception, int pos) |
| 1358 : exception_(exception), pos_(pos) {} | 1535 : exception_(exception), pos_(pos) {} |
| 1359 | 1536 |
| 1360 virtual void Accept(AstVisitor* v); | 1537 virtual void Accept(AstVisitor* v); |
| 1538 |
| 1539 virtual bool IsPrimitive(); |
| 1540 |
| 1361 Expression* exception() const { return exception_; } | 1541 Expression* exception() const { return exception_; } |
| 1362 int position() const { return pos_; } | 1542 int position() const { return pos_; } |
| 1363 | 1543 |
| 1364 private: | 1544 private: |
| 1365 Expression* exception_; | 1545 Expression* exception_; |
| 1366 int pos_; | 1546 int pos_; |
| 1367 }; | 1547 }; |
| 1368 | 1548 |
| 1369 | 1549 |
| 1370 class FunctionLiteral: public Expression { | 1550 class FunctionLiteral: public Expression { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1400 #endif | 1580 #endif |
| 1401 } | 1581 } |
| 1402 | 1582 |
| 1403 virtual void Accept(AstVisitor* v); | 1583 virtual void Accept(AstVisitor* v); |
| 1404 | 1584 |
| 1405 // Type testing & conversion | 1585 // Type testing & conversion |
| 1406 virtual FunctionLiteral* AsFunctionLiteral() { return this; } | 1586 virtual FunctionLiteral* AsFunctionLiteral() { return this; } |
| 1407 | 1587 |
| 1408 virtual bool IsLeaf() { return true; } | 1588 virtual bool IsLeaf() { return true; } |
| 1409 | 1589 |
| 1590 virtual bool IsPrimitive(); |
| 1591 |
| 1410 Handle<String> name() const { return name_; } | 1592 Handle<String> name() const { return name_; } |
| 1411 Scope* scope() const { return scope_; } | 1593 Scope* scope() const { return scope_; } |
| 1412 ZoneList<Statement*>* body() const { return body_; } | 1594 ZoneList<Statement*>* body() const { return body_; } |
| 1413 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1595 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1414 int function_token_position() const { return function_token_position_; } | 1596 int function_token_position() const { return function_token_position_; } |
| 1415 int start_position() const { return start_position_; } | 1597 int start_position() const { return start_position_; } |
| 1416 int end_position() const { return end_position_; } | 1598 int end_position() const { return end_position_; } |
| 1417 bool is_expression() const { return is_expression_; } | 1599 bool is_expression() const { return is_expression_; } |
| 1418 | 1600 |
| 1419 int materialized_literal_count() { return materialized_literal_count_; } | 1601 int materialized_literal_count() { return materialized_literal_count_; } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 : boilerplate_(boilerplate) { | 1652 : boilerplate_(boilerplate) { |
| 1471 ASSERT(boilerplate->IsBoilerplate()); | 1653 ASSERT(boilerplate->IsBoilerplate()); |
| 1472 } | 1654 } |
| 1473 | 1655 |
| 1474 Handle<JSFunction> boilerplate() const { return boilerplate_; } | 1656 Handle<JSFunction> boilerplate() const { return boilerplate_; } |
| 1475 | 1657 |
| 1476 virtual bool IsLeaf() { return true; } | 1658 virtual bool IsLeaf() { return true; } |
| 1477 | 1659 |
| 1478 virtual void Accept(AstVisitor* v); | 1660 virtual void Accept(AstVisitor* v); |
| 1479 | 1661 |
| 1662 virtual bool IsPrimitive(); |
| 1663 |
| 1480 private: | 1664 private: |
| 1481 Handle<JSFunction> boilerplate_; | 1665 Handle<JSFunction> boilerplate_; |
| 1482 }; | 1666 }; |
| 1483 | 1667 |
| 1484 | 1668 |
| 1485 class ThisFunction: public Expression { | 1669 class ThisFunction: public Expression { |
| 1486 public: | 1670 public: |
| 1487 virtual void Accept(AstVisitor* v); | 1671 virtual void Accept(AstVisitor* v); |
| 1488 virtual bool IsLeaf() { return true; } | 1672 virtual bool IsLeaf() { return true; } |
| 1673 virtual bool IsPrimitive(); |
| 1489 }; | 1674 }; |
| 1490 | 1675 |
| 1491 | 1676 |
| 1492 // ---------------------------------------------------------------------------- | 1677 // ---------------------------------------------------------------------------- |
| 1493 // Regular expressions | 1678 // Regular expressions |
| 1494 | 1679 |
| 1495 | 1680 |
| 1496 class RegExpVisitor BASE_EMBEDDED { | 1681 class RegExpVisitor BASE_EMBEDDED { |
| 1497 public: | 1682 public: |
| 1498 virtual ~RegExpVisitor() { } | 1683 virtual ~RegExpVisitor() { } |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 #define DEF_VISIT(type) \ | 2058 #define DEF_VISIT(type) \ |
| 1874 virtual void Visit##type(type* node) = 0; | 2059 virtual void Visit##type(type* node) = 0; |
| 1875 AST_NODE_LIST(DEF_VISIT) | 2060 AST_NODE_LIST(DEF_VISIT) |
| 1876 #undef DEF_VISIT | 2061 #undef DEF_VISIT |
| 1877 | 2062 |
| 1878 private: | 2063 private: |
| 1879 bool stack_overflow_; | 2064 bool stack_overflow_; |
| 1880 }; | 2065 }; |
| 1881 | 2066 |
| 1882 | 2067 |
| 2068 class CopyAstVisitor : public AstVisitor { |
| 2069 public: |
| 2070 Expression* DeepCopyExpr(Expression* expr); |
| 2071 |
| 2072 Statement* DeepCopyStmt(Statement* stmt); |
| 2073 |
| 2074 private: |
| 2075 ZoneList<Expression*>* DeepCopyExprList(ZoneList<Expression*>* expressions); |
| 2076 |
| 2077 ZoneList<Statement*>* DeepCopyStmtList(ZoneList<Statement*>* statements); |
| 2078 |
| 2079 // AST node visit functions. |
| 2080 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 2081 AST_NODE_LIST(DECLARE_VISIT) |
| 2082 #undef DECLARE_VISIT |
| 2083 |
| 2084 // Holds the result of copying an expression. |
| 2085 Expression* expr_; |
| 2086 // Holds the result of copying a statement. |
| 2087 Statement* stmt_; |
| 2088 }; |
| 2089 |
| 1883 } } // namespace v8::internal | 2090 } } // namespace v8::internal |
| 1884 | 2091 |
| 1885 #endif // V8_AST_H_ | 2092 #endif // V8_AST_H_ |
| OLD | NEW |