| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef V8_AST_H_ | 28 #ifndef V8_AST_H_ |
| 29 #define V8_AST_H_ | 29 #define V8_AST_H_ |
| 30 | 30 |
| 31 #include "execution.h" | 31 #include "execution.h" |
| 32 #include "factory.h" | 32 #include "factory.h" |
| 33 #include "runtime.h" | 33 #include "runtime.h" |
| 34 #include "token.h" | 34 #include "token.h" |
| 35 #include "variables.h" | 35 #include "variables.h" |
| 36 #include "macro-assembler.h" | 36 #include "macro-assembler.h" |
| 37 #include "jsregexp.h" |
| 37 #include "jump-target.h" | 38 #include "jump-target.h" |
| 38 | 39 |
| 39 namespace v8 { namespace internal { | 40 namespace v8 { namespace internal { |
| 40 | 41 |
| 41 // The abstract syntax tree is an intermediate, light-weight | 42 // The abstract syntax tree is an intermediate, light-weight |
| 42 // representation of the parsed JavaScript code suitable for | 43 // representation of the parsed JavaScript code suitable for |
| 43 // compilation to native code. | 44 // compilation to native code. |
| 44 | 45 |
| 45 // Nodes are allocated in a separate zone, which allows faster | 46 // Nodes are allocated in a separate zone, which allows faster |
| 46 // allocation and constant-time deallocation of the entire syntax | 47 // allocation and constant-time deallocation of the entire syntax |
| (...skipping 27 matching lines...) Expand all Loading... |
| 74 V(Slot) \ | 75 V(Slot) \ |
| 75 V(VariableProxy) \ | 76 V(VariableProxy) \ |
| 76 V(Literal) \ | 77 V(Literal) \ |
| 77 V(RegExpLiteral) \ | 78 V(RegExpLiteral) \ |
| 78 V(ObjectLiteral) \ | 79 V(ObjectLiteral) \ |
| 79 V(ArrayLiteral) \ | 80 V(ArrayLiteral) \ |
| 80 V(Assignment) \ | 81 V(Assignment) \ |
| 81 V(Throw) \ | 82 V(Throw) \ |
| 82 V(Property) \ | 83 V(Property) \ |
| 83 V(Call) \ | 84 V(Call) \ |
| 85 V(CallEval) \ |
| 84 V(CallNew) \ | 86 V(CallNew) \ |
| 85 V(CallRuntime) \ | 87 V(CallRuntime) \ |
| 86 V(UnaryOperation) \ | 88 V(UnaryOperation) \ |
| 87 V(CountOperation) \ | 89 V(CountOperation) \ |
| 88 V(BinaryOperation) \ | 90 V(BinaryOperation) \ |
| 89 V(CompareOperation) \ | 91 V(CompareOperation) \ |
| 90 V(ThisFunction) | 92 V(ThisFunction) |
| 91 | 93 |
| 92 | 94 |
| 93 // Forward declarations | 95 // Forward declarations |
| 94 class TargetCollector; | 96 class TargetCollector; |
| 95 | 97 |
| 96 #define DEF_FORWARD_DECLARATION(type) class type; | 98 #define DEF_FORWARD_DECLARATION(type) class type; |
| 97 NODE_LIST(DEF_FORWARD_DECLARATION) | 99 NODE_LIST(DEF_FORWARD_DECLARATION) |
| 98 #undef DEF_FORWARD_DECLARATION | 100 #undef DEF_FORWARD_DECLARATION |
| 99 | 101 |
| 100 | 102 |
| 101 // Typedef only introduced to avoid unreadable code. | 103 // Typedef only introduced to avoid unreadable code. |
| 102 // Please do appreciate the required space in "> >". | 104 // Please do appreciate the required space in "> >". |
| 103 typedef ZoneList<Handle<String> > ZoneStringList; | 105 typedef ZoneList<Handle<String> > ZoneStringList; |
| 104 | 106 |
| 105 | 107 |
| 106 class Node: public ZoneObject { | 108 class Node: public ZoneObject { |
| 107 public: | 109 public: |
| 108 Node(): statement_pos_(RelocInfo::kNoPosition) { } | 110 Node(): statement_pos_(RelocInfo::kNoPosition) { } |
| 109 virtual ~Node() { } | 111 virtual ~Node() { } |
| 110 virtual void Accept(Visitor* v) = 0; | 112 virtual void Accept(AstVisitor* v) = 0; |
| 111 | 113 |
| 112 // Type testing & conversion. | 114 // Type testing & conversion. |
| 113 virtual Statement* AsStatement() { return NULL; } | 115 virtual Statement* AsStatement() { return NULL; } |
| 114 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } | 116 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } |
| 115 virtual EmptyStatement* AsEmptyStatement() { return NULL; } | 117 virtual EmptyStatement* AsEmptyStatement() { return NULL; } |
| 116 virtual Expression* AsExpression() { return NULL; } | 118 virtual Expression* AsExpression() { return NULL; } |
| 117 virtual Literal* AsLiteral() { return NULL; } | 119 virtual Literal* AsLiteral() { return NULL; } |
| 118 virtual Slot* AsSlot() { return NULL; } | 120 virtual Slot* AsSlot() { return NULL; } |
| 119 virtual VariableProxy* AsVariableProxy() { return NULL; } | 121 virtual VariableProxy* AsVariableProxy() { return NULL; } |
| 120 virtual Property* AsProperty() { return NULL; } | 122 virtual Property* AsProperty() { return NULL; } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 166 |
| 165 | 167 |
| 166 /** | 168 /** |
| 167 * A sentinel used during pre parsing that represents some expression | 169 * A sentinel used during pre parsing that represents some expression |
| 168 * that is a valid left hand side without having to actually build | 170 * that is a valid left hand side without having to actually build |
| 169 * the expression. | 171 * the expression. |
| 170 */ | 172 */ |
| 171 class ValidLeftHandSideSentinel: public Expression { | 173 class ValidLeftHandSideSentinel: public Expression { |
| 172 public: | 174 public: |
| 173 virtual bool IsValidLeftHandSide() { return true; } | 175 virtual bool IsValidLeftHandSide() { return true; } |
| 174 virtual void Accept(Visitor* v) { UNREACHABLE(); } | 176 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 175 static ValidLeftHandSideSentinel* instance() { return &instance_; } | 177 static ValidLeftHandSideSentinel* instance() { return &instance_; } |
| 176 private: | 178 private: |
| 177 static ValidLeftHandSideSentinel instance_; | 179 static ValidLeftHandSideSentinel instance_; |
| 178 }; | 180 }; |
| 179 | 181 |
| 180 | 182 |
| 181 class BreakableStatement: public Statement { | 183 class BreakableStatement: public Statement { |
| 182 public: | 184 public: |
| 183 enum Type { | 185 enum Type { |
| 184 TARGET_FOR_ANONYMOUS, | 186 TARGET_FOR_ANONYMOUS, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 }; | 219 }; |
| 218 | 220 |
| 219 | 221 |
| 220 class Block: public BreakableStatement { | 222 class Block: public BreakableStatement { |
| 221 public: | 223 public: |
| 222 Block(ZoneStringList* labels, int capacity, bool is_initializer_block) | 224 Block(ZoneStringList* labels, int capacity, bool is_initializer_block) |
| 223 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), | 225 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), |
| 224 statements_(capacity), | 226 statements_(capacity), |
| 225 is_initializer_block_(is_initializer_block) { } | 227 is_initializer_block_(is_initializer_block) { } |
| 226 | 228 |
| 227 virtual void Accept(Visitor* v); | 229 virtual void Accept(AstVisitor* v); |
| 228 | 230 |
| 229 void AddStatement(Statement* statement) { statements_.Add(statement); } | 231 void AddStatement(Statement* statement) { statements_.Add(statement); } |
| 230 | 232 |
| 231 ZoneList<Statement*>* statements() { return &statements_; } | 233 ZoneList<Statement*>* statements() { return &statements_; } |
| 232 bool is_initializer_block() const { return is_initializer_block_; } | 234 bool is_initializer_block() const { return is_initializer_block_; } |
| 233 | 235 |
| 234 private: | 236 private: |
| 235 ZoneList<Statement*> statements_; | 237 ZoneList<Statement*> statements_; |
| 236 bool is_initializer_block_; | 238 bool is_initializer_block_; |
| 237 }; | 239 }; |
| 238 | 240 |
| 239 | 241 |
| 240 class Declaration: public Node { | 242 class Declaration: public Node { |
| 241 public: | 243 public: |
| 242 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) | 244 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) |
| 243 : proxy_(proxy), | 245 : proxy_(proxy), |
| 244 mode_(mode), | 246 mode_(mode), |
| 245 fun_(fun) { | 247 fun_(fun) { |
| 246 ASSERT(mode == Variable::VAR || mode == Variable::CONST); | 248 ASSERT(mode == Variable::VAR || mode == Variable::CONST); |
| 247 // At the moment there are no "const functions"'s in JavaScript... | 249 // At the moment there are no "const functions"'s in JavaScript... |
| 248 ASSERT(fun == NULL || mode == Variable::VAR); | 250 ASSERT(fun == NULL || mode == Variable::VAR); |
| 249 } | 251 } |
| 250 | 252 |
| 251 virtual void Accept(Visitor* v); | 253 virtual void Accept(AstVisitor* v); |
| 252 | 254 |
| 253 VariableProxy* proxy() const { return proxy_; } | 255 VariableProxy* proxy() const { return proxy_; } |
| 254 Variable::Mode mode() const { return mode_; } | 256 Variable::Mode mode() const { return mode_; } |
| 255 FunctionLiteral* fun() const { return fun_; } // may be NULL | 257 FunctionLiteral* fun() const { return fun_; } // may be NULL |
| 256 | 258 |
| 257 private: | 259 private: |
| 258 VariableProxy* proxy_; | 260 VariableProxy* proxy_; |
| 259 Variable::Mode mode_; | 261 Variable::Mode mode_; |
| 260 FunctionLiteral* fun_; | 262 FunctionLiteral* fun_; |
| 261 }; | 263 }; |
| 262 | 264 |
| 263 | 265 |
| 264 class IterationStatement: public BreakableStatement { | 266 class IterationStatement: public BreakableStatement { |
| 265 public: | 267 public: |
| 266 // Type testing & conversion. | 268 // Type testing & conversion. |
| 267 virtual IterationStatement* AsIterationStatement() { return this; } | 269 virtual IterationStatement* AsIterationStatement() { return this; } |
| 268 | 270 |
| 269 Statement* body() const { return body_; } | 271 Statement* body() const { return body_; } |
| 270 | 272 |
| 271 // Code generation | 273 // Code generation |
| 272 JumpTarget* continue_target() { return &continue_target_; } | 274 JumpTarget* continue_target() { return &continue_target_; } |
| 273 | 275 |
| 274 protected: | 276 protected: |
| 275 explicit IterationStatement(ZoneStringList* labels) | 277 explicit IterationStatement(ZoneStringList* labels) |
| 276 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), body_(NULL) { } | 278 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), body_(NULL) { } |
| 277 | 279 |
| 278 void Initialize(Statement* body) { | 280 void Initialize(Statement* body) { |
| 279 body_ = body; | 281 body_ = body; |
| 280 } | 282 } |
| 281 | 283 |
| 282 private: | 284 private: |
| 283 Statement* body_; | 285 Statement* body_; |
| 284 JumpTarget continue_target_; | 286 JumpTarget continue_target_; |
| 285 }; | 287 }; |
| 286 | 288 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 298 Statement* next, | 300 Statement* next, |
| 299 Statement* body) { | 301 Statement* body) { |
| 300 ASSERT(init == NULL || type_ == FOR_LOOP); | 302 ASSERT(init == NULL || type_ == FOR_LOOP); |
| 301 ASSERT(next == NULL || type_ == FOR_LOOP); | 303 ASSERT(next == NULL || type_ == FOR_LOOP); |
| 302 IterationStatement::Initialize(body); | 304 IterationStatement::Initialize(body); |
| 303 init_ = init; | 305 init_ = init; |
| 304 cond_ = cond; | 306 cond_ = cond; |
| 305 next_ = next; | 307 next_ = next; |
| 306 } | 308 } |
| 307 | 309 |
| 308 virtual void Accept(Visitor* v); | 310 virtual void Accept(AstVisitor* v); |
| 309 | 311 |
| 310 Type type() const { return type_; } | 312 Type type() const { return type_; } |
| 311 Statement* init() const { return init_; } | 313 Statement* init() const { return init_; } |
| 312 Expression* cond() const { return cond_; } | 314 Expression* cond() const { return cond_; } |
| 313 Statement* next() const { return next_; } | 315 Statement* next() const { return next_; } |
| 314 | 316 |
| 315 #ifdef DEBUG | 317 #ifdef DEBUG |
| 316 const char* OperatorString() const; | 318 const char* OperatorString() const; |
| 317 #endif | 319 #endif |
| 318 | 320 |
| 319 private: | 321 private: |
| 320 Type type_; | 322 Type type_; |
| 321 Statement* init_; | 323 Statement* init_; |
| 322 Expression* cond_; | 324 Expression* cond_; |
| 323 Statement* next_; | 325 Statement* next_; |
| 324 }; | 326 }; |
| 325 | 327 |
| 326 | 328 |
| 327 class ForInStatement: public IterationStatement { | 329 class ForInStatement: public IterationStatement { |
| 328 public: | 330 public: |
| 329 explicit ForInStatement(ZoneStringList* labels) | 331 explicit ForInStatement(ZoneStringList* labels) |
| 330 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } | 332 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } |
| 331 | 333 |
| 332 void Initialize(Expression* each, Expression* enumerable, Statement* body) { | 334 void Initialize(Expression* each, Expression* enumerable, Statement* body) { |
| 333 IterationStatement::Initialize(body); | 335 IterationStatement::Initialize(body); |
| 334 each_ = each; | 336 each_ = each; |
| 335 enumerable_ = enumerable; | 337 enumerable_ = enumerable; |
| 336 } | 338 } |
| 337 | 339 |
| 338 virtual void Accept(Visitor* v); | 340 virtual void Accept(AstVisitor* v); |
| 339 | 341 |
| 340 Expression* each() const { return each_; } | 342 Expression* each() const { return each_; } |
| 341 Expression* enumerable() const { return enumerable_; } | 343 Expression* enumerable() const { return enumerable_; } |
| 342 | 344 |
| 343 private: | 345 private: |
| 344 Expression* each_; | 346 Expression* each_; |
| 345 Expression* enumerable_; | 347 Expression* enumerable_; |
| 346 }; | 348 }; |
| 347 | 349 |
| 348 | 350 |
| 349 class ExpressionStatement: public Statement { | 351 class ExpressionStatement: public Statement { |
| 350 public: | 352 public: |
| 351 explicit ExpressionStatement(Expression* expression) | 353 explicit ExpressionStatement(Expression* expression) |
| 352 : expression_(expression) { } | 354 : expression_(expression) { } |
| 353 | 355 |
| 354 virtual void Accept(Visitor* v); | 356 virtual void Accept(AstVisitor* v); |
| 355 | 357 |
| 356 // Type testing & conversion. | 358 // Type testing & conversion. |
| 357 virtual ExpressionStatement* AsExpressionStatement() { return this; } | 359 virtual ExpressionStatement* AsExpressionStatement() { return this; } |
| 358 | 360 |
| 359 void set_expression(Expression* e) { expression_ = e; } | 361 void set_expression(Expression* e) { expression_ = e; } |
| 360 Expression* expression() { return expression_; } | 362 Expression* expression() { return expression_; } |
| 361 | 363 |
| 362 private: | 364 private: |
| 363 Expression* expression_; | 365 Expression* expression_; |
| 364 }; | 366 }; |
| 365 | 367 |
| 366 | 368 |
| 367 class ContinueStatement: public Statement { | 369 class ContinueStatement: public Statement { |
| 368 public: | 370 public: |
| 369 explicit ContinueStatement(IterationStatement* target) | 371 explicit ContinueStatement(IterationStatement* target) |
| 370 : target_(target) { } | 372 : target_(target) { } |
| 371 | 373 |
| 372 virtual void Accept(Visitor* v); | 374 virtual void Accept(AstVisitor* v); |
| 373 | 375 |
| 374 IterationStatement* target() const { return target_; } | 376 IterationStatement* target() const { return target_; } |
| 375 | 377 |
| 376 private: | 378 private: |
| 377 IterationStatement* target_; | 379 IterationStatement* target_; |
| 378 }; | 380 }; |
| 379 | 381 |
| 380 | 382 |
| 381 class BreakStatement: public Statement { | 383 class BreakStatement: public Statement { |
| 382 public: | 384 public: |
| 383 explicit BreakStatement(BreakableStatement* target) | 385 explicit BreakStatement(BreakableStatement* target) |
| 384 : target_(target) { } | 386 : target_(target) { } |
| 385 | 387 |
| 386 virtual void Accept(Visitor* v); | 388 virtual void Accept(AstVisitor* v); |
| 387 | 389 |
| 388 BreakableStatement* target() const { return target_; } | 390 BreakableStatement* target() const { return target_; } |
| 389 | 391 |
| 390 private: | 392 private: |
| 391 BreakableStatement* target_; | 393 BreakableStatement* target_; |
| 392 }; | 394 }; |
| 393 | 395 |
| 394 | 396 |
| 395 class ReturnStatement: public Statement { | 397 class ReturnStatement: public Statement { |
| 396 public: | 398 public: |
| 397 explicit ReturnStatement(Expression* expression) | 399 explicit ReturnStatement(Expression* expression) |
| 398 : expression_(expression) { } | 400 : expression_(expression) { } |
| 399 | 401 |
| 400 virtual void Accept(Visitor* v); | 402 virtual void Accept(AstVisitor* v); |
| 401 | 403 |
| 402 // Type testing & conversion. | 404 // Type testing & conversion. |
| 403 virtual ReturnStatement* AsReturnStatement() { return this; } | 405 virtual ReturnStatement* AsReturnStatement() { return this; } |
| 404 | 406 |
| 405 Expression* expression() { return expression_; } | 407 Expression* expression() { return expression_; } |
| 406 | 408 |
| 407 private: | 409 private: |
| 408 Expression* expression_; | 410 Expression* expression_; |
| 409 }; | 411 }; |
| 410 | 412 |
| 411 | 413 |
| 412 class WithEnterStatement: public Statement { | 414 class WithEnterStatement: public Statement { |
| 413 public: | 415 public: |
| 414 explicit WithEnterStatement(Expression* expression) | 416 explicit WithEnterStatement(Expression* expression) |
| 415 : expression_(expression) { } | 417 : expression_(expression) { } |
| 416 | 418 |
| 417 virtual void Accept(Visitor* v); | 419 virtual void Accept(AstVisitor* v); |
| 418 | 420 |
| 419 Expression* expression() const { return expression_; } | 421 Expression* expression() const { return expression_; } |
| 420 | 422 |
| 421 private: | 423 private: |
| 422 Expression* expression_; | 424 Expression* expression_; |
| 423 }; | 425 }; |
| 424 | 426 |
| 425 | 427 |
| 426 class WithExitStatement: public Statement { | 428 class WithExitStatement: public Statement { |
| 427 public: | 429 public: |
| 428 WithExitStatement() { } | 430 WithExitStatement() { } |
| 429 | 431 |
| 430 virtual void Accept(Visitor* v); | 432 virtual void Accept(AstVisitor* v); |
| 431 }; | 433 }; |
| 432 | 434 |
| 433 | 435 |
| 434 class CaseClause: public ZoneObject { | 436 class CaseClause: public ZoneObject { |
| 435 public: | 437 public: |
| 436 CaseClause(Expression* label, ZoneList<Statement*>* statements) | 438 CaseClause(Expression* label, ZoneList<Statement*>* statements) |
| 437 : label_(label), statements_(statements) { } | 439 : label_(label), statements_(statements) { } |
| 438 | 440 |
| 439 bool is_default() const { return label_ == NULL; } | 441 bool is_default() const { return label_ == NULL; } |
| 440 Expression* label() const { | 442 Expression* label() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 453 public: | 455 public: |
| 454 explicit SwitchStatement(ZoneStringList* labels) | 456 explicit SwitchStatement(ZoneStringList* labels) |
| 455 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), | 457 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), |
| 456 tag_(NULL), cases_(NULL) { } | 458 tag_(NULL), cases_(NULL) { } |
| 457 | 459 |
| 458 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 460 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 459 tag_ = tag; | 461 tag_ = tag; |
| 460 cases_ = cases; | 462 cases_ = cases; |
| 461 } | 463 } |
| 462 | 464 |
| 463 virtual void Accept(Visitor* v); | 465 virtual void Accept(AstVisitor* v); |
| 464 | 466 |
| 465 Expression* tag() const { return tag_; } | 467 Expression* tag() const { return tag_; } |
| 466 ZoneList<CaseClause*>* cases() const { return cases_; } | 468 ZoneList<CaseClause*>* cases() const { return cases_; } |
| 467 | 469 |
| 468 private: | 470 private: |
| 469 Expression* tag_; | 471 Expression* tag_; |
| 470 ZoneList<CaseClause*>* cases_; | 472 ZoneList<CaseClause*>* cases_; |
| 471 }; | 473 }; |
| 472 | 474 |
| 473 | 475 |
| 474 // If-statements always have non-null references to their then- and | 476 // If-statements always have non-null references to their then- and |
| 475 // else-parts. When parsing if-statements with no explicit else-part, | 477 // else-parts. When parsing if-statements with no explicit else-part, |
| 476 // the parser implicitly creates an empty statement. Use the | 478 // the parser implicitly creates an empty statement. Use the |
| 477 // HasThenStatement() and HasElseStatement() functions to check if a | 479 // HasThenStatement() and HasElseStatement() functions to check if a |
| 478 // given if-statement has a then- or an else-part containing code. | 480 // given if-statement has a then- or an else-part containing code. |
| 479 class IfStatement: public Statement { | 481 class IfStatement: public Statement { |
| 480 public: | 482 public: |
| 481 IfStatement(Expression* condition, | 483 IfStatement(Expression* condition, |
| 482 Statement* then_statement, | 484 Statement* then_statement, |
| 483 Statement* else_statement) | 485 Statement* else_statement) |
| 484 : condition_(condition), | 486 : condition_(condition), |
| 485 then_statement_(then_statement), | 487 then_statement_(then_statement), |
| 486 else_statement_(else_statement) { } | 488 else_statement_(else_statement) { } |
| 487 | 489 |
| 488 virtual void Accept(Visitor* v); | 490 virtual void Accept(AstVisitor* v); |
| 489 | 491 |
| 490 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 492 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
| 491 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 493 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
| 492 | 494 |
| 493 Expression* condition() const { return condition_; } | 495 Expression* condition() const { return condition_; } |
| 494 Statement* then_statement() const { return then_statement_; } | 496 Statement* then_statement() const { return then_statement_; } |
| 495 Statement* else_statement() const { return else_statement_; } | 497 Statement* else_statement() const { return else_statement_; } |
| 496 | 498 |
| 497 private: | 499 private: |
| 498 Expression* condition_; | 500 Expression* condition_; |
| 499 Statement* then_statement_; | 501 Statement* then_statement_; |
| 500 Statement* else_statement_; | 502 Statement* else_statement_; |
| 501 }; | 503 }; |
| 502 | 504 |
| 503 | 505 |
| 504 // NOTE: TargetCollectors are represented as nodes to fit in the target | 506 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 505 // stack in the compiler; this should probably be reworked. | 507 // stack in the compiler; this should probably be reworked. |
| 506 class TargetCollector: public Node { | 508 class TargetCollector: public Node { |
| 507 public: | 509 public: |
| 508 explicit TargetCollector(ZoneList<JumpTarget*>* targets) | 510 explicit TargetCollector(ZoneList<JumpTarget*>* targets) |
| 509 : targets_(targets) { | 511 : targets_(targets) { |
| 510 } | 512 } |
| 511 | 513 |
| 512 // Adds a jump target to the collector. The collector stores a pointer not | 514 // Adds a jump target to the collector. The collector stores a pointer not |
| 513 // a copy of the target to make binding work, so make sure not to pass in | 515 // a copy of the target to make binding work, so make sure not to pass in |
| 514 // references to something on the stack. | 516 // references to something on the stack. |
| 515 void AddTarget(JumpTarget* target); | 517 void AddTarget(JumpTarget* target); |
| 516 | 518 |
| 517 // Virtual behaviour. TargetCollectors are never part of the AST. | 519 // Virtual behaviour. TargetCollectors are never part of the AST. |
| 518 virtual void Accept(Visitor* v) { UNREACHABLE(); } | 520 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 519 virtual TargetCollector* AsTargetCollector() { return this; } | 521 virtual TargetCollector* AsTargetCollector() { return this; } |
| 520 | 522 |
| 521 ZoneList<JumpTarget*>* targets() { return targets_; } | 523 ZoneList<JumpTarget*>* targets() { return targets_; } |
| 522 | 524 |
| 523 private: | 525 private: |
| 524 ZoneList<JumpTarget*>* targets_; | 526 ZoneList<JumpTarget*>* targets_; |
| 525 }; | 527 }; |
| 526 | 528 |
| 527 | 529 |
| 528 class TryStatement: public Statement { | 530 class TryStatement: public Statement { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 545 | 547 |
| 546 class TryCatch: public TryStatement { | 548 class TryCatch: public TryStatement { |
| 547 public: | 549 public: |
| 548 TryCatch(Block* try_block, Expression* catch_var, Block* catch_block) | 550 TryCatch(Block* try_block, Expression* catch_var, Block* catch_block) |
| 549 : TryStatement(try_block), | 551 : TryStatement(try_block), |
| 550 catch_var_(catch_var), | 552 catch_var_(catch_var), |
| 551 catch_block_(catch_block) { | 553 catch_block_(catch_block) { |
| 552 ASSERT(catch_var->AsVariableProxy() != NULL); | 554 ASSERT(catch_var->AsVariableProxy() != NULL); |
| 553 } | 555 } |
| 554 | 556 |
| 555 virtual void Accept(Visitor* v); | 557 virtual void Accept(AstVisitor* v); |
| 556 | 558 |
| 557 Expression* catch_var() const { return catch_var_; } | 559 Expression* catch_var() const { return catch_var_; } |
| 558 Block* catch_block() const { return catch_block_; } | 560 Block* catch_block() const { return catch_block_; } |
| 559 | 561 |
| 560 private: | 562 private: |
| 561 Expression* catch_var_; | 563 Expression* catch_var_; |
| 562 Block* catch_block_; | 564 Block* catch_block_; |
| 563 }; | 565 }; |
| 564 | 566 |
| 565 | 567 |
| 566 class TryFinally: public TryStatement { | 568 class TryFinally: public TryStatement { |
| 567 public: | 569 public: |
| 568 TryFinally(Block* try_block, Block* finally_block) | 570 TryFinally(Block* try_block, Block* finally_block) |
| 569 : TryStatement(try_block), | 571 : TryStatement(try_block), |
| 570 finally_block_(finally_block) { } | 572 finally_block_(finally_block) { } |
| 571 | 573 |
| 572 virtual void Accept(Visitor* v); | 574 virtual void Accept(AstVisitor* v); |
| 573 | 575 |
| 574 Block* finally_block() const { return finally_block_; } | 576 Block* finally_block() const { return finally_block_; } |
| 575 | 577 |
| 576 private: | 578 private: |
| 577 Block* finally_block_; | 579 Block* finally_block_; |
| 578 }; | 580 }; |
| 579 | 581 |
| 580 | 582 |
| 581 class DebuggerStatement: public Statement { | 583 class DebuggerStatement: public Statement { |
| 582 public: | 584 public: |
| 583 virtual void Accept(Visitor* v); | 585 virtual void Accept(AstVisitor* v); |
| 584 }; | 586 }; |
| 585 | 587 |
| 586 | 588 |
| 587 class EmptyStatement: public Statement { | 589 class EmptyStatement: public Statement { |
| 588 public: | 590 public: |
| 589 virtual void Accept(Visitor* v); | 591 virtual void Accept(AstVisitor* v); |
| 590 | 592 |
| 591 // Type testing & conversion. | 593 // Type testing & conversion. |
| 592 virtual EmptyStatement* AsEmptyStatement() { return this; } | 594 virtual EmptyStatement* AsEmptyStatement() { return this; } |
| 593 }; | 595 }; |
| 594 | 596 |
| 595 | 597 |
| 596 class Literal: public Expression { | 598 class Literal: public Expression { |
| 597 public: | 599 public: |
| 598 explicit Literal(Handle<Object> handle) : handle_(handle) { } | 600 explicit Literal(Handle<Object> handle) : handle_(handle) { } |
| 599 | 601 |
| 600 virtual void Accept(Visitor* v); | 602 virtual void Accept(AstVisitor* v); |
| 601 | 603 |
| 602 // Type testing & conversion. | 604 // Type testing & conversion. |
| 603 virtual Literal* AsLiteral() { return this; } | 605 virtual Literal* AsLiteral() { return this; } |
| 604 | 606 |
| 605 // Check if this literal is identical to the other literal. | 607 // Check if this literal is identical to the other literal. |
| 606 bool IsIdenticalTo(const Literal* other) const { | 608 bool IsIdenticalTo(const Literal* other) const { |
| 607 return handle_.is_identical_to(other->handle_); | 609 return handle_.is_identical_to(other->handle_); |
| 608 } | 610 } |
| 609 | 611 |
| 610 // Identity testers. | 612 // Identity testers. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 }; | 665 }; |
| 664 | 666 |
| 665 ObjectLiteral(Handle<FixedArray> constant_properties, | 667 ObjectLiteral(Handle<FixedArray> constant_properties, |
| 666 ZoneList<Property*>* properties, | 668 ZoneList<Property*>* properties, |
| 667 int literal_index) | 669 int literal_index) |
| 668 : MaterializedLiteral(literal_index), | 670 : MaterializedLiteral(literal_index), |
| 669 constant_properties_(constant_properties), | 671 constant_properties_(constant_properties), |
| 670 properties_(properties) { | 672 properties_(properties) { |
| 671 } | 673 } |
| 672 | 674 |
| 673 virtual void Accept(Visitor* v); | 675 virtual void Accept(AstVisitor* v); |
| 674 | 676 |
| 675 Handle<FixedArray> constant_properties() const { | 677 Handle<FixedArray> constant_properties() const { |
| 676 return constant_properties_; | 678 return constant_properties_; |
| 677 } | 679 } |
| 678 ZoneList<Property*>* properties() const { return properties_; } | 680 ZoneList<Property*>* properties() const { return properties_; } |
| 679 | 681 |
| 680 private: | 682 private: |
| 681 Handle<FixedArray> constant_properties_; | 683 Handle<FixedArray> constant_properties_; |
| 682 ZoneList<Property*>* properties_; | 684 ZoneList<Property*>* properties_; |
| 683 }; | 685 }; |
| 684 | 686 |
| 685 | 687 |
| 686 // Node for capturing a regexp literal. | 688 // Node for capturing a regexp literal. |
| 687 class RegExpLiteral: public MaterializedLiteral { | 689 class RegExpLiteral: public MaterializedLiteral { |
| 688 public: | 690 public: |
| 689 RegExpLiteral(Handle<String> pattern, | 691 RegExpLiteral(Handle<String> pattern, |
| 690 Handle<String> flags, | 692 Handle<String> flags, |
| 691 int literal_index) | 693 int literal_index) |
| 692 : MaterializedLiteral(literal_index), | 694 : MaterializedLiteral(literal_index), |
| 693 pattern_(pattern), | 695 pattern_(pattern), |
| 694 flags_(flags) {} | 696 flags_(flags) {} |
| 695 | 697 |
| 696 virtual void Accept(Visitor* v); | 698 virtual void Accept(AstVisitor* v); |
| 697 | 699 |
| 698 Handle<String> pattern() const { return pattern_; } | 700 Handle<String> pattern() const { return pattern_; } |
| 699 Handle<String> flags() const { return flags_; } | 701 Handle<String> flags() const { return flags_; } |
| 700 | 702 |
| 701 private: | 703 private: |
| 702 Handle<String> pattern_; | 704 Handle<String> pattern_; |
| 703 Handle<String> flags_; | 705 Handle<String> flags_; |
| 704 }; | 706 }; |
| 705 | 707 |
| 706 // An array literal has a literals object that is used | 708 // An array literal has a literals object that is used |
| 707 // used for minimizing the work when contructing it at runtime. | 709 // used for minimizing the work when contructing it at runtime. |
| 708 class ArrayLiteral: public Expression { | 710 class ArrayLiteral: public Expression { |
| 709 public: | 711 public: |
| 710 ArrayLiteral(Handle<FixedArray> literals, | 712 ArrayLiteral(Handle<FixedArray> literals, |
| 711 ZoneList<Expression*>* values) | 713 ZoneList<Expression*>* values) |
| 712 : literals_(literals), values_(values) { | 714 : literals_(literals), values_(values) { |
| 713 } | 715 } |
| 714 | 716 |
| 715 virtual void Accept(Visitor* v); | 717 virtual void Accept(AstVisitor* v); |
| 716 | 718 |
| 717 Handle<FixedArray> literals() const { return literals_; } | 719 Handle<FixedArray> literals() const { return literals_; } |
| 718 ZoneList<Expression*>* values() const { return values_; } | 720 ZoneList<Expression*>* values() const { return values_; } |
| 719 | 721 |
| 720 private: | 722 private: |
| 721 Handle<FixedArray> literals_; | 723 Handle<FixedArray> literals_; |
| 722 ZoneList<Expression*>* values_; | 724 ZoneList<Expression*>* values_; |
| 723 }; | 725 }; |
| 724 | 726 |
| 725 | 727 |
| 726 class VariableProxy: public Expression { | 728 class VariableProxy: public Expression { |
| 727 public: | 729 public: |
| 728 virtual void Accept(Visitor* v); | 730 virtual void Accept(AstVisitor* v); |
| 729 | 731 |
| 730 // Type testing & conversion | 732 // Type testing & conversion |
| 731 virtual Property* AsProperty() { | 733 virtual Property* AsProperty() { |
| 732 return var_ == NULL ? NULL : var_->AsProperty(); | 734 return var_ == NULL ? NULL : var_->AsProperty(); |
| 733 } | 735 } |
| 734 virtual VariableProxy* AsVariableProxy() { return this; } | 736 virtual VariableProxy* AsVariableProxy() { return this; } |
| 735 | 737 |
| 736 Variable* AsVariable() { | 738 Variable* AsVariable() { |
| 737 return this == NULL || var_ == NULL ? NULL : var_->AsVariable(); | 739 return this == NULL || var_ == NULL ? NULL : var_->AsVariable(); |
| 738 } | 740 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 // with lookup starting at the current context. index() | 812 // with lookup starting at the current context. index() |
| 811 // is invalid. | 813 // is invalid. |
| 812 LOOKUP, | 814 LOOKUP, |
| 813 | 815 |
| 814 // A property in the global object. var()->name() is | 816 // A property in the global object. var()->name() is |
| 815 // the property name. | 817 // the property name. |
| 816 GLOBAL | 818 GLOBAL |
| 817 }; | 819 }; |
| 818 | 820 |
| 819 Slot(Variable* var, Type type, int index) | 821 Slot(Variable* var, Type type, int index) |
| 820 : var_(var), type_(type), index_(index) { | 822 : var_(var), type_(type), index_(index) { |
| 821 ASSERT(var != NULL); | 823 ASSERT(var != NULL); |
| 822 } | 824 } |
| 823 | 825 |
| 824 virtual void Accept(Visitor* v); | 826 virtual void Accept(AstVisitor* v); |
| 825 | 827 |
| 826 // Type testing & conversion | 828 // Type testing & conversion |
| 827 virtual Slot* AsSlot() { return this; } | 829 virtual Slot* AsSlot() { return this; } |
| 828 | 830 |
| 829 // Accessors | 831 // Accessors |
| 830 Variable* var() const { return var_; } | 832 Variable* var() const { return var_; } |
| 831 Type type() const { return type_; } | 833 Type type() const { return type_; } |
| 832 int index() const { return index_; } | 834 int index() const { return index_; } |
| 833 | 835 |
| 834 private: | 836 private: |
| 835 Variable* var_; | 837 Variable* var_; |
| 836 Type type_; | 838 Type type_; |
| 837 int index_; | 839 int index_; |
| 838 }; | 840 }; |
| 839 | 841 |
| 840 | 842 |
| 841 class Property: public Expression { | 843 class Property: public Expression { |
| 842 public: | 844 public: |
| 843 Property(Expression* obj, Expression* key, int pos) | 845 Property(Expression* obj, Expression* key, int pos) |
| 844 : obj_(obj), key_(key), pos_(pos) { } | 846 : obj_(obj), key_(key), pos_(pos) { } |
| 845 | 847 |
| 846 virtual void Accept(Visitor* v); | 848 virtual void Accept(AstVisitor* v); |
| 847 | 849 |
| 848 // Type testing & conversion | 850 // Type testing & conversion |
| 849 virtual Property* AsProperty() { return this; } | 851 virtual Property* AsProperty() { return this; } |
| 850 | 852 |
| 851 virtual bool IsValidLeftHandSide() { return true; } | 853 virtual bool IsValidLeftHandSide() { return true; } |
| 852 | 854 |
| 853 Expression* obj() const { return obj_; } | 855 Expression* obj() const { return obj_; } |
| 854 Expression* key() const { return key_; } | 856 Expression* key() const { return key_; } |
| 855 int position() const { return pos_; } | 857 int position() const { return pos_; } |
| 856 | 858 |
| 857 // Returns a property singleton property access on 'this'. Used | 859 // Returns a property singleton property access on 'this'. Used |
| 858 // during preparsing. | 860 // during preparsing. |
| 859 static Property* this_property() { return &this_property_; } | 861 static Property* this_property() { return &this_property_; } |
| 860 | 862 |
| 861 private: | 863 private: |
| 862 Expression* obj_; | 864 Expression* obj_; |
| 863 Expression* key_; | 865 Expression* key_; |
| 864 int pos_; | 866 int pos_; |
| 865 | 867 |
| 866 // Dummy property used during preparsing | 868 // Dummy property used during preparsing |
| 867 static Property this_property_; | 869 static Property this_property_; |
| 868 }; | 870 }; |
| 869 | 871 |
| 870 | 872 |
| 871 class Call: public Expression { | 873 class Call: public Expression { |
| 872 public: | 874 public: |
| 873 Call(Expression* expression, | 875 Call(Expression* expression, |
| 874 ZoneList<Expression*>* arguments, | 876 ZoneList<Expression*>* arguments, |
| 875 bool is_eval, | |
| 876 int pos) | 877 int pos) |
| 877 : expression_(expression), | 878 : expression_(expression), |
| 878 arguments_(arguments), | 879 arguments_(arguments), |
| 879 is_eval_(is_eval), | |
| 880 pos_(pos) { } | 880 pos_(pos) { } |
| 881 | 881 |
| 882 virtual void Accept(Visitor* v); | 882 virtual void Accept(AstVisitor* v); |
| 883 | 883 |
| 884 // Type testing and conversion. | 884 // Type testing and conversion. |
| 885 virtual Call* AsCall() { return this; } | 885 virtual Call* AsCall() { return this; } |
| 886 | 886 |
| 887 Expression* expression() const { return expression_; } | 887 Expression* expression() const { return expression_; } |
| 888 ZoneList<Expression*>* arguments() const { return arguments_; } | 888 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 889 bool is_eval() { return is_eval_; } | |
| 890 int position() { return pos_; } | 889 int position() { return pos_; } |
| 891 | 890 |
| 892 static Call* sentinel() { return &sentinel_; } | 891 static Call* sentinel() { return &sentinel_; } |
| 893 | 892 |
| 894 private: | 893 private: |
| 895 Expression* expression_; | 894 Expression* expression_; |
| 896 ZoneList<Expression*>* arguments_; | 895 ZoneList<Expression*>* arguments_; |
| 897 bool is_eval_; | |
| 898 int pos_; | 896 int pos_; |
| 899 | 897 |
| 900 static Call sentinel_; | 898 static Call sentinel_; |
| 901 }; | 899 }; |
| 902 | 900 |
| 903 | 901 |
| 904 class CallNew: public Call { | 902 class CallNew: public Call { |
| 905 public: | 903 public: |
| 906 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 904 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 907 : Call(expression, arguments, false, pos) { } | 905 : Call(expression, arguments, pos) { } |
| 908 | 906 |
| 909 virtual void Accept(Visitor* v); | 907 virtual void Accept(AstVisitor* v); |
| 908 }; |
| 909 |
| 910 |
| 911 // The CallEval class represents a call of the form 'eval(...)' where eval |
| 912 // cannot be seen to be overwritten at compile time. It is potentially a |
| 913 // direct (i.e. not aliased) eval call. The real nature of the call is |
| 914 // determined at runtime. |
| 915 class CallEval: public Call { |
| 916 public: |
| 917 CallEval(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 918 : Call(expression, arguments, pos) { } |
| 919 |
| 920 virtual void Accept(AstVisitor* v); |
| 921 |
| 922 static CallEval* sentinel() { return &sentinel_; } |
| 923 |
| 924 private: |
| 925 static CallEval sentinel_; |
| 910 }; | 926 }; |
| 911 | 927 |
| 912 | 928 |
| 913 // The CallRuntime class does not represent any official JavaScript | 929 // The CallRuntime class does not represent any official JavaScript |
| 914 // language construct. Instead it is used to call a C or JS function | 930 // language construct. Instead it is used to call a C or JS function |
| 915 // with a set of arguments. This is used from the builtins that are | 931 // with a set of arguments. This is used from the builtins that are |
| 916 // implemented in JavaScript (see "v8natives.js"). | 932 // implemented in JavaScript (see "v8natives.js"). |
| 917 class CallRuntime: public Expression { | 933 class CallRuntime: public Expression { |
| 918 public: | 934 public: |
| 919 CallRuntime(Handle<String> name, | 935 CallRuntime(Handle<String> name, |
| 920 Runtime::Function* function, | 936 Runtime::Function* function, |
| 921 ZoneList<Expression*>* arguments) | 937 ZoneList<Expression*>* arguments) |
| 922 : name_(name), function_(function), arguments_(arguments) { } | 938 : name_(name), function_(function), arguments_(arguments) { } |
| 923 | 939 |
| 924 virtual void Accept(Visitor* v); | 940 virtual void Accept(AstVisitor* v); |
| 925 | 941 |
| 926 Handle<String> name() const { return name_; } | 942 Handle<String> name() const { return name_; } |
| 927 Runtime::Function* function() const { return function_; } | 943 Runtime::Function* function() const { return function_; } |
| 928 ZoneList<Expression*>* arguments() const { return arguments_; } | 944 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 929 | 945 |
| 930 private: | 946 private: |
| 931 Handle<String> name_; | 947 Handle<String> name_; |
| 932 Runtime::Function* function_; | 948 Runtime::Function* function_; |
| 933 ZoneList<Expression*>* arguments_; | 949 ZoneList<Expression*>* arguments_; |
| 934 }; | 950 }; |
| 935 | 951 |
| 936 | 952 |
| 937 class UnaryOperation: public Expression { | 953 class UnaryOperation: public Expression { |
| 938 public: | 954 public: |
| 939 UnaryOperation(Token::Value op, Expression* expression) | 955 UnaryOperation(Token::Value op, Expression* expression) |
| 940 : op_(op), expression_(expression) { | 956 : op_(op), expression_(expression) { |
| 941 ASSERT(Token::IsUnaryOp(op)); | 957 ASSERT(Token::IsUnaryOp(op)); |
| 942 } | 958 } |
| 943 | 959 |
| 944 virtual void Accept(Visitor* v); | 960 virtual void Accept(AstVisitor* v); |
| 945 | 961 |
| 946 // Type testing & conversion | 962 // Type testing & conversion |
| 947 virtual UnaryOperation* AsUnaryOperation() { return this; } | 963 virtual UnaryOperation* AsUnaryOperation() { return this; } |
| 948 | 964 |
| 949 Token::Value op() const { return op_; } | 965 Token::Value op() const { return op_; } |
| 950 Expression* expression() const { return expression_; } | 966 Expression* expression() const { return expression_; } |
| 951 | 967 |
| 952 private: | 968 private: |
| 953 Token::Value op_; | 969 Token::Value op_; |
| 954 Expression* expression_; | 970 Expression* expression_; |
| 955 }; | 971 }; |
| 956 | 972 |
| 957 | 973 |
| 958 class BinaryOperation: public Expression { | 974 class BinaryOperation: public Expression { |
| 959 public: | 975 public: |
| 960 BinaryOperation(Token::Value op, Expression* left, Expression* right) | 976 BinaryOperation(Token::Value op, Expression* left, Expression* right) |
| 961 : op_(op), left_(left), right_(right) { | 977 : op_(op), left_(left), right_(right) { |
| 962 ASSERT(Token::IsBinaryOp(op)); | 978 ASSERT(Token::IsBinaryOp(op)); |
| 963 } | 979 } |
| 964 | 980 |
| 965 virtual void Accept(Visitor* v); | 981 virtual void Accept(AstVisitor* v); |
| 966 | 982 |
| 967 // Type testing & conversion | 983 // Type testing & conversion |
| 968 virtual BinaryOperation* AsBinaryOperation() { return this; } | 984 virtual BinaryOperation* AsBinaryOperation() { return this; } |
| 969 | 985 |
| 970 // True iff the result can be safely overwritten (to avoid allocation). | 986 // True iff the result can be safely overwritten (to avoid allocation). |
| 971 // False for operations that can return one of their operands. | 987 // False for operations that can return one of their operands. |
| 972 bool ResultOverwriteAllowed() { | 988 bool ResultOverwriteAllowed() { |
| 973 switch (op_) { | 989 switch (op_) { |
| 974 case Token::COMMA: | 990 case Token::COMMA: |
| 975 case Token::OR: | 991 case Token::OR: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1000 private: | 1016 private: |
| 1001 Token::Value op_; | 1017 Token::Value op_; |
| 1002 Expression* left_; | 1018 Expression* left_; |
| 1003 Expression* right_; | 1019 Expression* right_; |
| 1004 }; | 1020 }; |
| 1005 | 1021 |
| 1006 | 1022 |
| 1007 class CountOperation: public Expression { | 1023 class CountOperation: public Expression { |
| 1008 public: | 1024 public: |
| 1009 CountOperation(bool is_prefix, Token::Value op, Expression* expression) | 1025 CountOperation(bool is_prefix, Token::Value op, Expression* expression) |
| 1010 : is_prefix_(is_prefix), op_(op), expression_(expression) { | 1026 : is_prefix_(is_prefix), op_(op), expression_(expression) { |
| 1011 ASSERT(Token::IsCountOp(op)); | 1027 ASSERT(Token::IsCountOp(op)); |
| 1012 } | 1028 } |
| 1013 | 1029 |
| 1014 virtual void Accept(Visitor* v); | 1030 virtual void Accept(AstVisitor* v); |
| 1015 | 1031 |
| 1016 bool is_prefix() const { return is_prefix_; } | 1032 bool is_prefix() const { return is_prefix_; } |
| 1017 bool is_postfix() const { return !is_prefix_; } | 1033 bool is_postfix() const { return !is_prefix_; } |
| 1018 Token::Value op() const { return op_; } | 1034 Token::Value op() const { return op_; } |
| 1019 Expression* expression() const { return expression_; } | 1035 Expression* expression() const { return expression_; } |
| 1020 | 1036 |
| 1021 virtual void MarkAsStatement() { is_prefix_ = true; } | 1037 virtual void MarkAsStatement() { is_prefix_ = true; } |
| 1022 | 1038 |
| 1023 private: | 1039 private: |
| 1024 bool is_prefix_; | 1040 bool is_prefix_; |
| 1025 Token::Value op_; | 1041 Token::Value op_; |
| 1026 Expression* expression_; | 1042 Expression* expression_; |
| 1027 }; | 1043 }; |
| 1028 | 1044 |
| 1029 | 1045 |
| 1030 class CompareOperation: public Expression { | 1046 class CompareOperation: public Expression { |
| 1031 public: | 1047 public: |
| 1032 CompareOperation(Token::Value op, Expression* left, Expression* right) | 1048 CompareOperation(Token::Value op, Expression* left, Expression* right) |
| 1033 : op_(op), left_(left), right_(right) { | 1049 : op_(op), left_(left), right_(right) { |
| 1034 ASSERT(Token::IsCompareOp(op)); | 1050 ASSERT(Token::IsCompareOp(op)); |
| 1035 } | 1051 } |
| 1036 | 1052 |
| 1037 virtual void Accept(Visitor* v); | 1053 virtual void Accept(AstVisitor* v); |
| 1038 | 1054 |
| 1039 Token::Value op() const { return op_; } | 1055 Token::Value op() const { return op_; } |
| 1040 Expression* left() const { return left_; } | 1056 Expression* left() const { return left_; } |
| 1041 Expression* right() const { return right_; } | 1057 Expression* right() const { return right_; } |
| 1042 | 1058 |
| 1043 private: | 1059 private: |
| 1044 Token::Value op_; | 1060 Token::Value op_; |
| 1045 Expression* left_; | 1061 Expression* left_; |
| 1046 Expression* right_; | 1062 Expression* right_; |
| 1047 }; | 1063 }; |
| 1048 | 1064 |
| 1049 | 1065 |
| 1050 class Conditional: public Expression { | 1066 class Conditional: public Expression { |
| 1051 public: | 1067 public: |
| 1052 Conditional(Expression* condition, | 1068 Conditional(Expression* condition, |
| 1053 Expression* then_expression, | 1069 Expression* then_expression, |
| 1054 Expression* else_expression) | 1070 Expression* else_expression) |
| 1055 : condition_(condition), | 1071 : condition_(condition), |
| 1056 then_expression_(then_expression), | 1072 then_expression_(then_expression), |
| 1057 else_expression_(else_expression) { } | 1073 else_expression_(else_expression) { } |
| 1058 | 1074 |
| 1059 virtual void Accept(Visitor* v); | 1075 virtual void Accept(AstVisitor* v); |
| 1060 | 1076 |
| 1061 Expression* condition() const { return condition_; } | 1077 Expression* condition() const { return condition_; } |
| 1062 Expression* then_expression() const { return then_expression_; } | 1078 Expression* then_expression() const { return then_expression_; } |
| 1063 Expression* else_expression() const { return else_expression_; } | 1079 Expression* else_expression() const { return else_expression_; } |
| 1064 | 1080 |
| 1065 private: | 1081 private: |
| 1066 Expression* condition_; | 1082 Expression* condition_; |
| 1067 Expression* then_expression_; | 1083 Expression* then_expression_; |
| 1068 Expression* else_expression_; | 1084 Expression* else_expression_; |
| 1069 }; | 1085 }; |
| 1070 | 1086 |
| 1071 | 1087 |
| 1072 class Assignment: public Expression { | 1088 class Assignment: public Expression { |
| 1073 public: | 1089 public: |
| 1074 Assignment(Token::Value op, Expression* target, Expression* value, int pos) | 1090 Assignment(Token::Value op, Expression* target, Expression* value, int pos) |
| 1075 : op_(op), target_(target), value_(value), pos_(pos) { | 1091 : op_(op), target_(target), value_(value), pos_(pos) { |
| 1076 ASSERT(Token::IsAssignmentOp(op)); | 1092 ASSERT(Token::IsAssignmentOp(op)); |
| 1077 } | 1093 } |
| 1078 | 1094 |
| 1079 virtual void Accept(Visitor* v); | 1095 virtual void Accept(AstVisitor* v); |
| 1080 virtual Assignment* AsAssignment() { return this; } | 1096 virtual Assignment* AsAssignment() { return this; } |
| 1081 | 1097 |
| 1082 Token::Value binary_op() const; | 1098 Token::Value binary_op() const; |
| 1083 | 1099 |
| 1084 Token::Value op() const { return op_; } | 1100 Token::Value op() const { return op_; } |
| 1085 Expression* target() const { return target_; } | 1101 Expression* target() const { return target_; } |
| 1086 Expression* value() const { return value_; } | 1102 Expression* value() const { return value_; } |
| 1087 int position() { return pos_; } | 1103 int position() { return pos_; } |
| 1088 | 1104 |
| 1089 private: | 1105 private: |
| 1090 Token::Value op_; | 1106 Token::Value op_; |
| 1091 Expression* target_; | 1107 Expression* target_; |
| 1092 Expression* value_; | 1108 Expression* value_; |
| 1093 int pos_; | 1109 int pos_; |
| 1094 }; | 1110 }; |
| 1095 | 1111 |
| 1096 | 1112 |
| 1097 class Throw: public Expression { | 1113 class Throw: public Expression { |
| 1098 public: | 1114 public: |
| 1099 Throw(Expression* exception, int pos) | 1115 Throw(Expression* exception, int pos) |
| 1100 : exception_(exception), pos_(pos) {} | 1116 : exception_(exception), pos_(pos) {} |
| 1101 | 1117 |
| 1102 virtual void Accept(Visitor* v); | 1118 virtual void Accept(AstVisitor* v); |
| 1103 Expression* exception() const { return exception_; } | 1119 Expression* exception() const { return exception_; } |
| 1104 int position() const { return pos_; } | 1120 int position() const { return pos_; } |
| 1105 | 1121 |
| 1106 private: | 1122 private: |
| 1107 Expression* exception_; | 1123 Expression* exception_; |
| 1108 int pos_; | 1124 int pos_; |
| 1109 }; | 1125 }; |
| 1110 | 1126 |
| 1111 | 1127 |
| 1112 class FunctionLiteral: public Expression { | 1128 class FunctionLiteral: public Expression { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1128 contains_array_literal_(contains_array_literal), | 1144 contains_array_literal_(contains_array_literal), |
| 1129 expected_property_count_(expected_property_count), | 1145 expected_property_count_(expected_property_count), |
| 1130 num_parameters_(num_parameters), | 1146 num_parameters_(num_parameters), |
| 1131 start_position_(start_position), | 1147 start_position_(start_position), |
| 1132 end_position_(end_position), | 1148 end_position_(end_position), |
| 1133 is_expression_(is_expression), | 1149 is_expression_(is_expression), |
| 1134 loop_nesting_(0), | 1150 loop_nesting_(0), |
| 1135 function_token_position_(RelocInfo::kNoPosition) { | 1151 function_token_position_(RelocInfo::kNoPosition) { |
| 1136 } | 1152 } |
| 1137 | 1153 |
| 1138 virtual void Accept(Visitor* v); | 1154 virtual void Accept(AstVisitor* v); |
| 1139 | 1155 |
| 1140 // Type testing & conversion | 1156 // Type testing & conversion |
| 1141 virtual FunctionLiteral* AsFunctionLiteral() { return this; } | 1157 virtual FunctionLiteral* AsFunctionLiteral() { return this; } |
| 1142 | 1158 |
| 1143 Handle<String> name() const { return name_; } | 1159 Handle<String> name() const { return name_; } |
| 1144 Scope* scope() const { return scope_; } | 1160 Scope* scope() const { return scope_; } |
| 1145 ZoneList<Statement*>* body() const { return body_; } | 1161 ZoneList<Statement*>* body() const { return body_; } |
| 1146 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1162 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1147 int function_token_position() const { return function_token_position_; } | 1163 int function_token_position() const { return function_token_position_; } |
| 1148 int start_position() const { return start_position_; } | 1164 int start_position() const { return start_position_; } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1177 | 1193 |
| 1178 class FunctionBoilerplateLiteral: public Expression { | 1194 class FunctionBoilerplateLiteral: public Expression { |
| 1179 public: | 1195 public: |
| 1180 explicit FunctionBoilerplateLiteral(Handle<JSFunction> boilerplate) | 1196 explicit FunctionBoilerplateLiteral(Handle<JSFunction> boilerplate) |
| 1181 : boilerplate_(boilerplate) { | 1197 : boilerplate_(boilerplate) { |
| 1182 ASSERT(boilerplate->IsBoilerplate()); | 1198 ASSERT(boilerplate->IsBoilerplate()); |
| 1183 } | 1199 } |
| 1184 | 1200 |
| 1185 Handle<JSFunction> boilerplate() const { return boilerplate_; } | 1201 Handle<JSFunction> boilerplate() const { return boilerplate_; } |
| 1186 | 1202 |
| 1187 virtual void Accept(Visitor* v); | 1203 virtual void Accept(AstVisitor* v); |
| 1188 | 1204 |
| 1189 private: | 1205 private: |
| 1190 Handle<JSFunction> boilerplate_; | 1206 Handle<JSFunction> boilerplate_; |
| 1191 }; | 1207 }; |
| 1192 | 1208 |
| 1193 | 1209 |
| 1194 class ThisFunction: public Expression { | 1210 class ThisFunction: public Expression { |
| 1195 public: | 1211 public: |
| 1196 virtual void Accept(Visitor* v); | 1212 virtual void Accept(AstVisitor* v); |
| 1213 }; |
| 1214 |
| 1215 |
| 1216 // ---------------------------------------------------------------------------- |
| 1217 // Regular expressions |
| 1218 |
| 1219 |
| 1220 class RegExpTree: public ZoneObject { |
| 1221 public: |
| 1222 virtual ~RegExpTree() { } |
| 1223 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; |
| 1224 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1225 RegExpNode* on_success, |
| 1226 RegExpNode* on_failure) = 0; |
| 1227 virtual bool IsTextElement() { return false; } |
| 1228 virtual void AppendToText(RegExpText* text); |
| 1229 SmartPointer<const char> ToString(); |
| 1230 #define MAKE_ASTYPE(Name) \ |
| 1231 virtual RegExp##Name* As##Name(); \ |
| 1232 virtual bool Is##Name(); |
| 1233 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) |
| 1234 #undef MAKE_ASTYPE |
| 1235 }; |
| 1236 |
| 1237 |
| 1238 class RegExpDisjunction: public RegExpTree { |
| 1239 public: |
| 1240 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) |
| 1241 : alternatives_(alternatives) { } |
| 1242 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1243 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1244 RegExpNode* on_success, |
| 1245 RegExpNode* on_failure); |
| 1246 virtual RegExpDisjunction* AsDisjunction(); |
| 1247 virtual bool IsDisjunction(); |
| 1248 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } |
| 1249 private: |
| 1250 ZoneList<RegExpTree*>* alternatives_; |
| 1251 }; |
| 1252 |
| 1253 |
| 1254 class RegExpAlternative: public RegExpTree { |
| 1255 public: |
| 1256 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes) : nodes_(nodes) { } |
| 1257 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1258 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1259 RegExpNode* on_success, |
| 1260 RegExpNode* on_failure); |
| 1261 virtual RegExpAlternative* AsAlternative(); |
| 1262 virtual bool IsAlternative(); |
| 1263 ZoneList<RegExpTree*>* nodes() { return nodes_; } |
| 1264 private: |
| 1265 ZoneList<RegExpTree*>* nodes_; |
| 1266 }; |
| 1267 |
| 1268 |
| 1269 class RegExpText: public RegExpTree { |
| 1270 public: |
| 1271 RegExpText() : elements_(2) { } |
| 1272 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1273 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1274 RegExpNode* on_success, |
| 1275 RegExpNode* on_failure); |
| 1276 virtual RegExpText* AsText(); |
| 1277 virtual bool IsText(); |
| 1278 virtual bool IsTextElement() { return true; } |
| 1279 virtual void AppendToText(RegExpText* text); |
| 1280 void AddElement(TextElement elm) { elements_.Add(elm); } |
| 1281 ZoneList<TextElement>* elements() { return &elements_; } |
| 1282 private: |
| 1283 ZoneList<TextElement> elements_; |
| 1284 }; |
| 1285 |
| 1286 |
| 1287 class RegExpAssertion: public RegExpTree { |
| 1288 public: |
| 1289 enum Type { |
| 1290 START_OF_LINE, |
| 1291 START_OF_INPUT, |
| 1292 END_OF_LINE, |
| 1293 END_OF_INPUT, |
| 1294 BOUNDARY, |
| 1295 NON_BOUNDARY |
| 1296 }; |
| 1297 explicit RegExpAssertion(Type type) : type_(type) { } |
| 1298 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1299 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1300 RegExpNode* on_success, |
| 1301 RegExpNode* on_failure); |
| 1302 virtual RegExpAssertion* AsAssertion(); |
| 1303 virtual bool IsAssertion(); |
| 1304 Type type() { return type_; } |
| 1305 private: |
| 1306 Type type_; |
| 1307 }; |
| 1308 |
| 1309 |
| 1310 class RegExpCharacterClass: public RegExpTree { |
| 1311 public: |
| 1312 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) |
| 1313 : ranges_(ranges), |
| 1314 is_negated_(is_negated) { } |
| 1315 explicit RegExpCharacterClass(uc16 type) |
| 1316 : ranges_(new ZoneList<CharacterRange>(2)), |
| 1317 is_negated_(false) { |
| 1318 CharacterRange::AddClassEscape(type, ranges_); |
| 1319 } |
| 1320 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1321 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1322 RegExpNode* on_success, |
| 1323 RegExpNode* on_failure); |
| 1324 virtual RegExpCharacterClass* AsCharacterClass(); |
| 1325 virtual bool IsCharacterClass(); |
| 1326 virtual bool IsTextElement() { return true; } |
| 1327 virtual void AppendToText(RegExpText* text); |
| 1328 ZoneList<CharacterRange>* ranges() { return ranges_; } |
| 1329 bool is_negated() { return is_negated_; } |
| 1330 private: |
| 1331 ZoneList<CharacterRange>* ranges_; |
| 1332 bool is_negated_; |
| 1333 }; |
| 1334 |
| 1335 |
| 1336 class RegExpAtom: public RegExpTree { |
| 1337 public: |
| 1338 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } |
| 1339 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1340 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1341 RegExpNode* on_success, |
| 1342 RegExpNode* on_failure); |
| 1343 virtual RegExpAtom* AsAtom(); |
| 1344 virtual bool IsAtom(); |
| 1345 virtual bool IsTextElement() { return true; } |
| 1346 virtual void AppendToText(RegExpText* text); |
| 1347 Vector<const uc16> data() { return data_; } |
| 1348 private: |
| 1349 Vector<const uc16> data_; |
| 1350 }; |
| 1351 |
| 1352 |
| 1353 class RegExpQuantifier: public RegExpTree { |
| 1354 public: |
| 1355 RegExpQuantifier(int min, int max, bool is_greedy, RegExpTree* body) |
| 1356 : min_(min), |
| 1357 max_(max), |
| 1358 is_greedy_(is_greedy), |
| 1359 body_(body) { } |
| 1360 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1361 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1362 RegExpNode* on_success, |
| 1363 RegExpNode* on_failure); |
| 1364 static RegExpNode* ToNode(int min, |
| 1365 int max, |
| 1366 bool is_greedy, |
| 1367 RegExpTree* body, |
| 1368 RegExpCompiler* compiler, |
| 1369 RegExpNode* on_success, |
| 1370 RegExpNode* on_failure); |
| 1371 virtual RegExpQuantifier* AsQuantifier(); |
| 1372 virtual bool IsQuantifier(); |
| 1373 int min() { return min_; } |
| 1374 int max() { return max_; } |
| 1375 bool is_greedy() { return is_greedy_; } |
| 1376 RegExpTree* body() { return body_; } |
| 1377 // We just use a very large integer value as infinity because 2^30 |
| 1378 // is infinite in practice. |
| 1379 static const int kInfinity = (1 << 30); |
| 1380 private: |
| 1381 int min_; |
| 1382 int max_; |
| 1383 bool is_greedy_; |
| 1384 RegExpTree* body_; |
| 1385 }; |
| 1386 |
| 1387 |
| 1388 enum CaptureAvailability { |
| 1389 CAPTURE_AVAILABLE, |
| 1390 CAPTURE_UNREACHABLE, |
| 1391 CAPTURE_PERMANENTLY_UNREACHABLE |
| 1392 }; |
| 1393 |
| 1394 class RegExpCapture: public RegExpTree { |
| 1395 public: |
| 1396 explicit RegExpCapture(RegExpTree* body, int index) |
| 1397 : body_(body), index_(index), available_(CAPTURE_AVAILABLE) { } |
| 1398 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1399 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1400 RegExpNode* on_success, |
| 1401 RegExpNode* on_failure); |
| 1402 static RegExpNode* ToNode(RegExpTree* body, |
| 1403 int index, |
| 1404 RegExpCompiler* compiler, |
| 1405 RegExpNode* on_success, |
| 1406 RegExpNode* on_failure); |
| 1407 virtual RegExpCapture* AsCapture(); |
| 1408 virtual bool IsCapture(); |
| 1409 RegExpTree* body() { return body_; } |
| 1410 int index() { return index_; } |
| 1411 inline CaptureAvailability available() { return available_; } |
| 1412 inline void set_available(CaptureAvailability availability) { |
| 1413 available_ = availability; |
| 1414 } |
| 1415 static int StartRegister(int index) { return index * 2; } |
| 1416 static int EndRegister(int index) { return index * 2 + 1; } |
| 1417 private: |
| 1418 RegExpTree* body_; |
| 1419 int index_; |
| 1420 CaptureAvailability available_; |
| 1421 }; |
| 1422 |
| 1423 |
| 1424 class RegExpLookahead: public RegExpTree { |
| 1425 public: |
| 1426 RegExpLookahead(RegExpTree* body, bool is_positive) |
| 1427 : body_(body), |
| 1428 is_positive_(is_positive) { } |
| 1429 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1430 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1431 RegExpNode* on_success, |
| 1432 RegExpNode* on_failure); |
| 1433 virtual RegExpLookahead* AsLookahead(); |
| 1434 virtual bool IsLookahead(); |
| 1435 RegExpTree* body() { return body_; } |
| 1436 bool is_positive() { return is_positive_; } |
| 1437 private: |
| 1438 RegExpTree* body_; |
| 1439 bool is_positive_; |
| 1440 }; |
| 1441 |
| 1442 |
| 1443 class RegExpBackReference: public RegExpTree { |
| 1444 public: |
| 1445 explicit RegExpBackReference(RegExpCapture* capture) |
| 1446 : capture_(capture) { } |
| 1447 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1448 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1449 RegExpNode* on_success, |
| 1450 RegExpNode* on_failure); |
| 1451 virtual RegExpBackReference* AsBackReference(); |
| 1452 virtual bool IsBackReference(); |
| 1453 int index() { return capture_->index(); } |
| 1454 RegExpCapture* capture() { return capture_; } |
| 1455 private: |
| 1456 RegExpCapture* capture_; |
| 1457 }; |
| 1458 |
| 1459 |
| 1460 class RegExpEmpty: public RegExpTree { |
| 1461 public: |
| 1462 RegExpEmpty() { } |
| 1463 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1464 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1465 RegExpNode* on_success, |
| 1466 RegExpNode* on_failure); |
| 1467 virtual RegExpEmpty* AsEmpty(); |
| 1468 virtual bool IsEmpty(); |
| 1469 static RegExpEmpty* GetInstance() { return &kInstance; } |
| 1470 private: |
| 1471 static RegExpEmpty kInstance; |
| 1472 }; |
| 1473 |
| 1474 |
| 1475 class RegExpVisitor BASE_EMBEDDED { |
| 1476 public: |
| 1477 virtual ~RegExpVisitor() { } |
| 1478 #define MAKE_CASE(Name) \ |
| 1479 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; |
| 1480 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
| 1481 #undef MAKE_CASE |
| 1197 }; | 1482 }; |
| 1198 | 1483 |
| 1199 | 1484 |
| 1200 // ---------------------------------------------------------------------------- | 1485 // ---------------------------------------------------------------------------- |
| 1201 // Basic visitor | 1486 // Basic visitor |
| 1202 // - leaf node visitors are abstract. | 1487 // - leaf node visitors are abstract. |
| 1203 | 1488 |
| 1204 class Visitor BASE_EMBEDDED { | 1489 class AstVisitor BASE_EMBEDDED { |
| 1205 public: | 1490 public: |
| 1206 Visitor() : stack_overflow_(false) { } | 1491 AstVisitor() : stack_overflow_(false) { } |
| 1207 virtual ~Visitor() { } | 1492 virtual ~AstVisitor() { } |
| 1208 | 1493 |
| 1209 // Dispatch | 1494 // Dispatch |
| 1210 void Visit(Node* node) { node->Accept(this); } | 1495 void Visit(Node* node) { node->Accept(this); } |
| 1211 | 1496 |
| 1212 // Iteration | 1497 // Iteration |
| 1213 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1498 virtual void VisitStatements(ZoneList<Statement*>* statements); |
| 1214 virtual void VisitExpressions(ZoneList<Expression*>* expressions); | 1499 virtual void VisitExpressions(ZoneList<Expression*>* expressions); |
| 1215 | 1500 |
| 1216 // Stack overflow tracking support. | 1501 // Stack overflow tracking support. |
| 1217 bool HasStackOverflow() const { return stack_overflow_; } | 1502 bool HasStackOverflow() const { return stack_overflow_; } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1235 #undef DEF_VISIT | 1520 #undef DEF_VISIT |
| 1236 | 1521 |
| 1237 private: | 1522 private: |
| 1238 bool stack_overflow_; | 1523 bool stack_overflow_; |
| 1239 }; | 1524 }; |
| 1240 | 1525 |
| 1241 | 1526 |
| 1242 } } // namespace v8::internal | 1527 } } // namespace v8::internal |
| 1243 | 1528 |
| 1244 #endif // V8_AST_H_ | 1529 #endif // V8_AST_H_ |
| OLD | NEW |