| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 323 } |
| 324 | 324 |
| 325 virtual CountOperation* StatementAsCountOperation() { | 325 virtual CountOperation* StatementAsCountOperation() { |
| 326 if (statements_.length() != 1) return NULL; | 326 if (statements_.length() != 1) return NULL; |
| 327 return statements_[0]->StatementAsCountOperation(); | 327 return statements_[0]->StatementAsCountOperation(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void AddStatement(Statement* statement) { statements_.Add(statement); } | 330 void AddStatement(Statement* statement) { statements_.Add(statement); } |
| 331 | 331 |
| 332 ZoneList<Statement*>* statements() { return &statements_; } | 332 ZoneList<Statement*>* statements() { return &statements_; } |
| 333 bool is_initializer_block() const { return is_initializer_block_; } | 333 bool is_initializer_block() const { return is_initializer_block_; } |
| 334 | 334 |
| 335 private: | 335 private: |
| 336 ZoneList<Statement*> statements_; | 336 ZoneList<Statement*> statements_; |
| 337 bool is_initializer_block_; | 337 bool is_initializer_block_; |
| 338 }; | 338 }; |
| 339 | 339 |
| 340 | 340 |
| 341 class Declaration: public AstNode { | 341 class Declaration: public AstNode { |
| 342 public: | 342 public: |
| 343 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) | 343 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) |
| 344 : proxy_(proxy), | 344 : proxy_(proxy), |
| 345 mode_(mode), | 345 mode_(mode), |
| 346 fun_(fun) { | 346 fun_(fun) { |
| 347 ASSERT(mode == Variable::VAR || mode == Variable::CONST); | 347 ASSERT(mode == Variable::VAR || mode == Variable::CONST); |
| 348 // At the moment there are no "const functions"'s in JavaScript... | 348 // At the moment there are no "const functions"'s in JavaScript... |
| 349 ASSERT(fun == NULL || mode == Variable::VAR); | 349 ASSERT(fun == NULL || mode == Variable::VAR); |
| 350 } | 350 } |
| 351 | 351 |
| 352 virtual void Accept(AstVisitor* v); | 352 virtual void Accept(AstVisitor* v); |
| 353 | 353 |
| 354 VariableProxy* proxy() const { return proxy_; } | 354 VariableProxy* proxy() const { return proxy_; } |
| 355 Variable::Mode mode() const { return mode_; } | 355 Variable::Mode mode() const { return mode_; } |
| 356 FunctionLiteral* fun() const { return fun_; } // may be NULL | 356 FunctionLiteral* fun() const { return fun_; } // may be NULL |
| 357 | 357 |
| 358 private: | 358 private: |
| 359 VariableProxy* proxy_; | 359 VariableProxy* proxy_; |
| 360 Variable::Mode mode_; | 360 Variable::Mode mode_; |
| 361 FunctionLiteral* fun_; | 361 FunctionLiteral* fun_; |
| 362 }; | 362 }; |
| 363 | 363 |
| 364 | 364 |
| 365 class IterationStatement: public BreakableStatement { | 365 class IterationStatement: public BreakableStatement { |
| 366 public: | 366 public: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 Statement* next, | 447 Statement* next, |
| 448 Statement* body) { | 448 Statement* body) { |
| 449 IterationStatement::Initialize(body); | 449 IterationStatement::Initialize(body); |
| 450 init_ = init; | 450 init_ = init; |
| 451 cond_ = cond; | 451 cond_ = cond; |
| 452 next_ = next; | 452 next_ = next; |
| 453 } | 453 } |
| 454 | 454 |
| 455 virtual void Accept(AstVisitor* v); | 455 virtual void Accept(AstVisitor* v); |
| 456 | 456 |
| 457 Statement* init() const { return init_; } | 457 Statement* init() const { return init_; } |
| 458 void set_init(Statement* stmt) { init_ = stmt; } | 458 void set_init(Statement* stmt) { init_ = stmt; } |
| 459 Expression* cond() const { return cond_; } | 459 Expression* cond() const { return cond_; } |
| 460 void set_cond(Expression* expr) { cond_ = expr; } | 460 void set_cond(Expression* expr) { cond_ = expr; } |
| 461 Statement* next() const { return next_; } | 461 Statement* next() const { return next_; } |
| 462 void set_next(Statement* stmt) { next_ = stmt; } | 462 void set_next(Statement* stmt) { next_ = stmt; } |
| 463 | 463 |
| 464 bool may_have_function_literal() const { | 464 bool may_have_function_literal() const { |
| 465 return may_have_function_literal_; | 465 return may_have_function_literal_; |
| 466 } | 466 } |
| 467 void set_may_have_function_literal(bool value) { | 467 void set_may_have_function_literal(bool value) { |
| 468 may_have_function_literal_ = value; | 468 may_have_function_literal_ = value; |
| 469 } | 469 } |
| 470 | 470 |
| 471 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 471 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 }; | 524 }; |
| 525 | 525 |
| 526 | 526 |
| 527 class ContinueStatement: public Statement { | 527 class ContinueStatement: public Statement { |
| 528 public: | 528 public: |
| 529 explicit ContinueStatement(IterationStatement* target) | 529 explicit ContinueStatement(IterationStatement* target) |
| 530 : target_(target) { } | 530 : target_(target) { } |
| 531 | 531 |
| 532 virtual void Accept(AstVisitor* v); | 532 virtual void Accept(AstVisitor* v); |
| 533 | 533 |
| 534 IterationStatement* target() const { return target_; } | 534 IterationStatement* target() const { return target_; } |
| 535 | 535 |
| 536 private: | 536 private: |
| 537 IterationStatement* target_; | 537 IterationStatement* target_; |
| 538 }; | 538 }; |
| 539 | 539 |
| 540 | 540 |
| 541 class BreakStatement: public Statement { | 541 class BreakStatement: public Statement { |
| 542 public: | 542 public: |
| 543 explicit BreakStatement(BreakableStatement* target) | 543 explicit BreakStatement(BreakableStatement* target) |
| 544 : target_(target) { } | 544 : target_(target) { } |
| 545 | 545 |
| 546 virtual void Accept(AstVisitor* v); | 546 virtual void Accept(AstVisitor* v); |
| 547 | 547 |
| 548 BreakableStatement* target() const { return target_; } | 548 BreakableStatement* target() const { return target_; } |
| 549 | 549 |
| 550 private: | 550 private: |
| 551 BreakableStatement* target_; | 551 BreakableStatement* target_; |
| 552 }; | 552 }; |
| 553 | 553 |
| 554 | 554 |
| 555 class ReturnStatement: public Statement { | 555 class ReturnStatement: public Statement { |
| 556 public: | 556 public: |
| 557 explicit ReturnStatement(Expression* expression) | 557 explicit ReturnStatement(Expression* expression) |
| 558 : expression_(expression) { } | 558 : expression_(expression) { } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 569 }; | 569 }; |
| 570 | 570 |
| 571 | 571 |
| 572 class WithEnterStatement: public Statement { | 572 class WithEnterStatement: public Statement { |
| 573 public: | 573 public: |
| 574 explicit WithEnterStatement(Expression* expression, bool is_catch_block) | 574 explicit WithEnterStatement(Expression* expression, bool is_catch_block) |
| 575 : expression_(expression), is_catch_block_(is_catch_block) { } | 575 : expression_(expression), is_catch_block_(is_catch_block) { } |
| 576 | 576 |
| 577 virtual void Accept(AstVisitor* v); | 577 virtual void Accept(AstVisitor* v); |
| 578 | 578 |
| 579 Expression* expression() const { return expression_; } | 579 Expression* expression() const { return expression_; } |
| 580 | 580 |
| 581 bool is_catch_block() const { return is_catch_block_; } | 581 bool is_catch_block() const { return is_catch_block_; } |
| 582 | 582 |
| 583 private: | 583 private: |
| 584 Expression* expression_; | 584 Expression* expression_; |
| 585 bool is_catch_block_; | 585 bool is_catch_block_; |
| 586 }; | 586 }; |
| 587 | 587 |
| 588 | 588 |
| 589 class WithExitStatement: public Statement { | 589 class WithExitStatement: public Statement { |
| 590 public: | 590 public: |
| 591 WithExitStatement() { } | 591 WithExitStatement() { } |
| 592 | 592 |
| 593 virtual void Accept(AstVisitor* v); | 593 virtual void Accept(AstVisitor* v); |
| 594 }; | 594 }; |
| 595 | 595 |
| 596 | 596 |
| 597 class CaseClause: public ZoneObject { | 597 class CaseClause: public ZoneObject { |
| 598 public: | 598 public: |
| 599 CaseClause(Expression* label, ZoneList<Statement*>* statements); | 599 CaseClause(Expression* label, ZoneList<Statement*>* statements); |
| 600 | 600 |
| 601 bool is_default() const { return label_ == NULL; } | 601 bool is_default() const { return label_ == NULL; } |
| 602 Expression* label() const { | 602 Expression* label() const { |
| 603 CHECK(!is_default()); | 603 CHECK(!is_default()); |
| 604 return label_; | 604 return label_; |
| 605 } | 605 } |
| 606 JumpTarget* body_target() { return &body_target_; } | 606 JumpTarget* body_target() { return &body_target_; } |
| 607 ZoneList<Statement*>* statements() const { return statements_; } | 607 ZoneList<Statement*>* statements() const { return statements_; } |
| 608 | 608 |
| 609 private: | 609 private: |
| 610 Expression* label_; | 610 Expression* label_; |
| 611 JumpTarget body_target_; | 611 JumpTarget body_target_; |
| 612 ZoneList<Statement*>* statements_; | 612 ZoneList<Statement*>* statements_; |
| 613 }; | 613 }; |
| 614 | 614 |
| 615 | 615 |
| 616 class SwitchStatement: public BreakableStatement { | 616 class SwitchStatement: public BreakableStatement { |
| 617 public: | 617 public: |
| 618 explicit inline SwitchStatement(ZoneStringList* labels); | 618 explicit inline SwitchStatement(ZoneStringList* labels); |
| 619 | 619 |
| 620 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 620 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 621 tag_ = tag; | 621 tag_ = tag; |
| 622 cases_ = cases; | 622 cases_ = cases; |
| 623 } | 623 } |
| 624 | 624 |
| 625 virtual void Accept(AstVisitor* v); | 625 virtual void Accept(AstVisitor* v); |
| 626 | 626 |
| 627 Expression* tag() const { return tag_; } | 627 Expression* tag() const { return tag_; } |
| 628 ZoneList<CaseClause*>* cases() const { return cases_; } | 628 ZoneList<CaseClause*>* cases() const { return cases_; } |
| 629 | 629 |
| 630 private: | 630 private: |
| 631 Expression* tag_; | 631 Expression* tag_; |
| 632 ZoneList<CaseClause*>* cases_; | 632 ZoneList<CaseClause*>* cases_; |
| 633 }; | 633 }; |
| 634 | 634 |
| 635 | 635 |
| 636 // If-statements always have non-null references to their then- and | 636 // If-statements always have non-null references to their then- and |
| 637 // else-parts. When parsing if-statements with no explicit else-part, | 637 // else-parts. When parsing if-statements with no explicit else-part, |
| 638 // the parser implicitly creates an empty statement. Use the | 638 // the parser implicitly creates an empty statement. Use the |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 TryCatchStatement(Block* try_block, | 712 TryCatchStatement(Block* try_block, |
| 713 VariableProxy* catch_var, | 713 VariableProxy* catch_var, |
| 714 Block* catch_block) | 714 Block* catch_block) |
| 715 : TryStatement(try_block), | 715 : TryStatement(try_block), |
| 716 catch_var_(catch_var), | 716 catch_var_(catch_var), |
| 717 catch_block_(catch_block) { | 717 catch_block_(catch_block) { |
| 718 } | 718 } |
| 719 | 719 |
| 720 virtual void Accept(AstVisitor* v); | 720 virtual void Accept(AstVisitor* v); |
| 721 | 721 |
| 722 VariableProxy* catch_var() const { return catch_var_; } | 722 VariableProxy* catch_var() const { return catch_var_; } |
| 723 Block* catch_block() const { return catch_block_; } | 723 Block* catch_block() const { return catch_block_; } |
| 724 | 724 |
| 725 private: | 725 private: |
| 726 VariableProxy* catch_var_; | 726 VariableProxy* catch_var_; |
| 727 Block* catch_block_; | 727 Block* catch_block_; |
| 728 }; | 728 }; |
| 729 | 729 |
| 730 | 730 |
| 731 class TryFinallyStatement: public TryStatement { | 731 class TryFinallyStatement: public TryStatement { |
| 732 public: | 732 public: |
| 733 TryFinallyStatement(Block* try_block, Block* finally_block) | 733 TryFinallyStatement(Block* try_block, Block* finally_block) |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 | 980 |
| 981 bool IsVariable(Handle<String> n) { | 981 bool IsVariable(Handle<String> n) { |
| 982 return !is_this() && name().is_identical_to(n); | 982 return !is_this() && name().is_identical_to(n); |
| 983 } | 983 } |
| 984 | 984 |
| 985 bool IsArguments() { | 985 bool IsArguments() { |
| 986 Variable* variable = AsVariable(); | 986 Variable* variable = AsVariable(); |
| 987 return (variable == NULL) ? false : variable->is_arguments(); | 987 return (variable == NULL) ? false : variable->is_arguments(); |
| 988 } | 988 } |
| 989 | 989 |
| 990 Handle<String> name() const { return name_; } | 990 Handle<String> name() const { return name_; } |
| 991 Variable* var() const { return var_; } | 991 Variable* var() const { return var_; } |
| 992 bool is_this() const { return is_this_; } | 992 bool is_this() const { return is_this_; } |
| 993 bool inside_with() const { return inside_with_; } | 993 bool inside_with() const { return inside_with_; } |
| 994 | 994 |
| 995 void MarkAsTrivial() { is_trivial_ = true; } | 995 void MarkAsTrivial() { is_trivial_ = true; } |
| 996 | 996 |
| 997 // Bind this proxy to the variable var. | 997 // Bind this proxy to the variable var. |
| 998 void BindTo(Variable* var); | 998 void BindTo(Variable* var); |
| 999 | 999 |
| 1000 protected: | 1000 protected: |
| 1001 Handle<String> name_; | 1001 Handle<String> name_; |
| 1002 Variable* var_; // resolved variable, or NULL | 1002 Variable* var_; // resolved variable, or NULL |
| 1003 bool is_this_; | 1003 bool is_this_; |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 #ifdef DEBUG | 1450 #ifdef DEBUG |
| 1451 already_compiled_ = false; | 1451 already_compiled_ = false; |
| 1452 #endif | 1452 #endif |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 virtual void Accept(AstVisitor* v); | 1455 virtual void Accept(AstVisitor* v); |
| 1456 | 1456 |
| 1457 // Type testing & conversion | 1457 // Type testing & conversion |
| 1458 virtual FunctionLiteral* AsFunctionLiteral() { return this; } | 1458 virtual FunctionLiteral* AsFunctionLiteral() { return this; } |
| 1459 | 1459 |
| 1460 Handle<String> name() const { return name_; } | 1460 Handle<String> name() const { return name_; } |
| 1461 Scope* scope() const { return scope_; } | 1461 Scope* scope() const { return scope_; } |
| 1462 ZoneList<Statement*>* body() const { return body_; } | 1462 ZoneList<Statement*>* body() const { return body_; } |
| 1463 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1463 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1464 int function_token_position() const { return function_token_position_; } | 1464 int function_token_position() const { return function_token_position_; } |
| 1465 int start_position() const { return start_position_; } | 1465 int start_position() const { return start_position_; } |
| 1466 int end_position() const { return end_position_; } | 1466 int end_position() const { return end_position_; } |
| 1467 bool is_expression() const { return is_expression_; } | 1467 bool is_expression() const { return is_expression_; } |
| 1468 bool contains_loops() const { return contains_loops_; } | 1468 bool contains_loops() const { return contains_loops_; } |
| 1469 | 1469 |
| 1470 int materialized_literal_count() { return materialized_literal_count_; } | 1470 int materialized_literal_count() { return materialized_literal_count_; } |
| 1471 int expected_property_count() { return expected_property_count_; } | 1471 int expected_property_count() { return expected_property_count_; } |
| 1472 bool has_only_simple_this_property_assignments() { | 1472 bool has_only_simple_this_property_assignments() { |
| 1473 return has_only_simple_this_property_assignments_; | 1473 return has_only_simple_this_property_assignments_; |
| 1474 } | 1474 } |
| 1475 Handle<FixedArray> this_property_assignments() { | 1475 Handle<FixedArray> this_property_assignments() { |
| 1476 return this_property_assignments_; | 1476 return this_property_assignments_; |
| 1477 } | 1477 } |
| 1478 int num_parameters() { return num_parameters_; } | 1478 int num_parameters() { return num_parameters_; } |
| 1479 | 1479 |
| 1480 bool AllowsLazyCompilation(); | 1480 bool AllowsLazyCompilation(); |
| 1481 | 1481 |
| 1482 Handle<String> inferred_name() const { return inferred_name_; } | 1482 Handle<String> inferred_name() const { return inferred_name_; } |
| 1483 void set_inferred_name(Handle<String> inferred_name) { | 1483 void set_inferred_name(Handle<String> inferred_name) { |
| 1484 inferred_name_ = inferred_name; | 1484 inferred_name_ = inferred_name; |
| 1485 } | 1485 } |
| 1486 | 1486 |
| 1487 bool try_full_codegen() { return try_full_codegen_; } | 1487 bool try_full_codegen() { return try_full_codegen_; } |
| 1488 void set_try_full_codegen(bool flag) { try_full_codegen_ = flag; } | 1488 void set_try_full_codegen(bool flag) { try_full_codegen_ = flag; } |
| 1489 | 1489 |
| 1490 #ifdef DEBUG | 1490 #ifdef DEBUG |
| 1491 void mark_as_compiled() { | 1491 void mark_as_compiled() { |
| 1492 ASSERT(!already_compiled_); | 1492 ASSERT(!already_compiled_); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 AST_NODE_LIST(DEF_VISIT) | 1919 AST_NODE_LIST(DEF_VISIT) |
| 1920 #undef DEF_VISIT | 1920 #undef DEF_VISIT |
| 1921 | 1921 |
| 1922 private: | 1922 private: |
| 1923 bool stack_overflow_; | 1923 bool stack_overflow_; |
| 1924 }; | 1924 }; |
| 1925 | 1925 |
| 1926 } } // namespace v8::internal | 1926 } } // namespace v8::internal |
| 1927 | 1927 |
| 1928 #endif // V8_AST_H_ | 1928 #endif // V8_AST_H_ |
| OLD | NEW |