| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
| 6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| 11 #include "src/ast-value-factory.h" | |
| 12 #include "src/factory.h" | 11 #include "src/factory.h" |
| 13 #include "src/feedback-slots.h" | 12 #include "src/feedback-slots.h" |
| 14 #include "src/isolate.h" | 13 #include "src/isolate.h" |
| 15 #include "src/jsregexp.h" | 14 #include "src/jsregexp.h" |
| 16 #include "src/list-inl.h" | 15 #include "src/list-inl.h" |
| 17 #include "src/runtime.h" | 16 #include "src/runtime.h" |
| 18 #include "src/small-pointer-list.h" | 17 #include "src/small-pointer-list.h" |
| 19 #include "src/smart-pointers.h" | 18 #include "src/smart-pointers.h" |
| 20 #include "src/token.h" | 19 #include "src/token.h" |
| 21 #include "src/types.h" | 20 #include "src/types.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // TODO(rossberg): this should move to its own AST node eventually. | 360 // TODO(rossberg): this should move to its own AST node eventually. |
| 362 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 361 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 363 byte to_boolean_types() const { return to_boolean_types_; } | 362 byte to_boolean_types() const { return to_boolean_types_; } |
| 364 | 363 |
| 365 BailoutId id() const { return id_; } | 364 BailoutId id() const { return id_; } |
| 366 TypeFeedbackId test_id() const { return test_id_; } | 365 TypeFeedbackId test_id() const { return test_id_; } |
| 367 | 366 |
| 368 protected: | 367 protected: |
| 369 Expression(Zone* zone, int pos) | 368 Expression(Zone* zone, int pos) |
| 370 : AstNode(pos), | 369 : AstNode(pos), |
| 371 zone_(zone), | |
| 372 bounds_(Bounds::Unbounded(zone)), | 370 bounds_(Bounds::Unbounded(zone)), |
| 373 id_(GetNextId(zone)), | 371 id_(GetNextId(zone)), |
| 374 test_id_(GetNextId(zone)) {} | 372 test_id_(GetNextId(zone)) {} |
| 375 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } | 373 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
| 376 | 374 |
| 377 Zone* zone_; | |
| 378 | |
| 379 private: | 375 private: |
| 380 Bounds bounds_; | 376 Bounds bounds_; |
| 381 byte to_boolean_types_; | 377 byte to_boolean_types_; |
| 382 | 378 |
| 383 const BailoutId id_; | 379 const BailoutId id_; |
| 384 const TypeFeedbackId test_id_; | 380 const TypeFeedbackId test_id_; |
| 385 }; | 381 }; |
| 386 | 382 |
| 387 | 383 |
| 388 class BreakableStatement : public Statement { | 384 class BreakableStatement : public Statement { |
| 389 public: | 385 public: |
| 390 enum BreakableType { | 386 enum BreakableType { |
| 391 TARGET_FOR_ANONYMOUS, | 387 TARGET_FOR_ANONYMOUS, |
| 392 TARGET_FOR_NAMED_ONLY | 388 TARGET_FOR_NAMED_ONLY |
| 393 }; | 389 }; |
| 394 | 390 |
| 395 // The labels associated with this statement. May be NULL; | 391 // The labels associated with this statement. May be NULL; |
| 396 // if it is != NULL, guaranteed to contain at least one entry. | 392 // if it is != NULL, guaranteed to contain at least one entry. |
| 397 ZoneList<const AstString*>* labels() const { return labels_; } | 393 ZoneStringList* labels() const { return labels_; } |
| 398 | 394 |
| 399 // Type testing & conversion. | 395 // Type testing & conversion. |
| 400 virtual BreakableStatement* AsBreakableStatement() V8_FINAL V8_OVERRIDE { | 396 virtual BreakableStatement* AsBreakableStatement() V8_FINAL V8_OVERRIDE { |
| 401 return this; | 397 return this; |
| 402 } | 398 } |
| 403 | 399 |
| 404 // Code generation | 400 // Code generation |
| 405 Label* break_target() { return &break_target_; } | 401 Label* break_target() { return &break_target_; } |
| 406 | 402 |
| 407 // Testers. | 403 // Testers. |
| 408 bool is_target_for_anonymous() const { | 404 bool is_target_for_anonymous() const { |
| 409 return breakable_type_ == TARGET_FOR_ANONYMOUS; | 405 return breakable_type_ == TARGET_FOR_ANONYMOUS; |
| 410 } | 406 } |
| 411 | 407 |
| 412 BailoutId EntryId() const { return entry_id_; } | 408 BailoutId EntryId() const { return entry_id_; } |
| 413 BailoutId ExitId() const { return exit_id_; } | 409 BailoutId ExitId() const { return exit_id_; } |
| 414 | 410 |
| 415 protected: | 411 protected: |
| 416 BreakableStatement( | 412 BreakableStatement( |
| 417 Zone* zone, ZoneList<const AstString*>* labels, | 413 Zone* zone, ZoneStringList* labels, |
| 418 BreakableType breakable_type, int position) | 414 BreakableType breakable_type, int position) |
| 419 : Statement(zone, position), | 415 : Statement(zone, position), |
| 420 labels_(labels), | 416 labels_(labels), |
| 421 breakable_type_(breakable_type), | 417 breakable_type_(breakable_type), |
| 422 entry_id_(GetNextId(zone)), | 418 entry_id_(GetNextId(zone)), |
| 423 exit_id_(GetNextId(zone)) { | 419 exit_id_(GetNextId(zone)) { |
| 424 ASSERT(labels == NULL || labels->length() > 0); | 420 ASSERT(labels == NULL || labels->length() > 0); |
| 425 } | 421 } |
| 426 | 422 |
| 427 | 423 |
| 428 private: | 424 private: |
| 429 ZoneList<const AstString*>* labels_; | 425 ZoneStringList* labels_; |
| 430 BreakableType breakable_type_; | 426 BreakableType breakable_type_; |
| 431 Label break_target_; | 427 Label break_target_; |
| 432 const BailoutId entry_id_; | 428 const BailoutId entry_id_; |
| 433 const BailoutId exit_id_; | 429 const BailoutId exit_id_; |
| 434 }; | 430 }; |
| 435 | 431 |
| 436 | 432 |
| 437 class Block V8_FINAL : public BreakableStatement { | 433 class Block V8_FINAL : public BreakableStatement { |
| 438 public: | 434 public: |
| 439 DECLARE_NODE_TYPE(Block) | 435 DECLARE_NODE_TYPE(Block) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 450 virtual bool IsJump() const V8_OVERRIDE { | 446 virtual bool IsJump() const V8_OVERRIDE { |
| 451 return !statements_.is_empty() && statements_.last()->IsJump() | 447 return !statements_.is_empty() && statements_.last()->IsJump() |
| 452 && labels() == NULL; // Good enough as an approximation... | 448 && labels() == NULL; // Good enough as an approximation... |
| 453 } | 449 } |
| 454 | 450 |
| 455 Scope* scope() const { return scope_; } | 451 Scope* scope() const { return scope_; } |
| 456 void set_scope(Scope* scope) { scope_ = scope; } | 452 void set_scope(Scope* scope) { scope_ = scope; } |
| 457 | 453 |
| 458 protected: | 454 protected: |
| 459 Block(Zone* zone, | 455 Block(Zone* zone, |
| 460 ZoneList<const AstString*>* labels, | 456 ZoneStringList* labels, |
| 461 int capacity, | 457 int capacity, |
| 462 bool is_initializer_block, | 458 bool is_initializer_block, |
| 463 int pos) | 459 int pos) |
| 464 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), | 460 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), |
| 465 statements_(capacity, zone), | 461 statements_(capacity, zone), |
| 466 is_initializer_block_(is_initializer_block), | 462 is_initializer_block_(is_initializer_block), |
| 467 decls_id_(GetNextId(zone)), | 463 decls_id_(GetNextId(zone)), |
| 468 scope_(NULL) { | 464 scope_(NULL) { |
| 469 } | 465 } |
| 470 | 466 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 private: | 655 private: |
| 660 VariableProxy* proxy_; | 656 VariableProxy* proxy_; |
| 661 }; | 657 }; |
| 662 | 658 |
| 663 | 659 |
| 664 class ModulePath V8_FINAL : public Module { | 660 class ModulePath V8_FINAL : public Module { |
| 665 public: | 661 public: |
| 666 DECLARE_NODE_TYPE(ModulePath) | 662 DECLARE_NODE_TYPE(ModulePath) |
| 667 | 663 |
| 668 Module* module() const { return module_; } | 664 Module* module() const { return module_; } |
| 669 Handle<String> name() const { return name_->string(); } | 665 Handle<String> name() const { return name_; } |
| 670 | 666 |
| 671 protected: | 667 protected: |
| 672 ModulePath(Zone* zone, Module* module, const AstString* name, int pos) | 668 ModulePath(Zone* zone, Module* module, Handle<String> name, int pos) |
| 673 : Module(zone, pos), module_(module), name_(name) {} | 669 : Module(zone, pos), |
| 670 module_(module), |
| 671 name_(name) { |
| 672 } |
| 674 | 673 |
| 675 private: | 674 private: |
| 676 Module* module_; | 675 Module* module_; |
| 677 const AstString* name_; | 676 Handle<String> name_; |
| 678 }; | 677 }; |
| 679 | 678 |
| 680 | 679 |
| 681 class ModuleUrl V8_FINAL : public Module { | 680 class ModuleUrl V8_FINAL : public Module { |
| 682 public: | 681 public: |
| 683 DECLARE_NODE_TYPE(ModuleUrl) | 682 DECLARE_NODE_TYPE(ModuleUrl) |
| 684 | 683 |
| 685 Handle<String> url() const { return url_; } | 684 Handle<String> url() const { return url_; } |
| 686 | 685 |
| 687 protected: | 686 protected: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 Statement* body() const { return body_; } | 723 Statement* body() const { return body_; } |
| 725 | 724 |
| 726 BailoutId OsrEntryId() const { return osr_entry_id_; } | 725 BailoutId OsrEntryId() const { return osr_entry_id_; } |
| 727 virtual BailoutId ContinueId() const = 0; | 726 virtual BailoutId ContinueId() const = 0; |
| 728 virtual BailoutId StackCheckId() const = 0; | 727 virtual BailoutId StackCheckId() const = 0; |
| 729 | 728 |
| 730 // Code generation | 729 // Code generation |
| 731 Label* continue_target() { return &continue_target_; } | 730 Label* continue_target() { return &continue_target_; } |
| 732 | 731 |
| 733 protected: | 732 protected: |
| 734 IterationStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 733 IterationStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 735 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 734 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
| 736 body_(NULL), | 735 body_(NULL), |
| 737 osr_entry_id_(GetNextId(zone)) { | 736 osr_entry_id_(GetNextId(zone)) { |
| 738 } | 737 } |
| 739 | 738 |
| 740 void Initialize(Statement* body) { | 739 void Initialize(Statement* body) { |
| 741 body_ = body; | 740 body_ = body; |
| 742 } | 741 } |
| 743 | 742 |
| 744 private: | 743 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 758 cond_ = cond; | 757 cond_ = cond; |
| 759 } | 758 } |
| 760 | 759 |
| 761 Expression* cond() const { return cond_; } | 760 Expression* cond() const { return cond_; } |
| 762 | 761 |
| 763 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } | 762 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } |
| 764 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; } | 763 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; } |
| 765 BailoutId BackEdgeId() const { return back_edge_id_; } | 764 BailoutId BackEdgeId() const { return back_edge_id_; } |
| 766 | 765 |
| 767 protected: | 766 protected: |
| 768 DoWhileStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 767 DoWhileStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 769 : IterationStatement(zone, labels, pos), | 768 : IterationStatement(zone, labels, pos), |
| 770 cond_(NULL), | 769 cond_(NULL), |
| 771 continue_id_(GetNextId(zone)), | 770 continue_id_(GetNextId(zone)), |
| 772 back_edge_id_(GetNextId(zone)) { | 771 back_edge_id_(GetNextId(zone)) { |
| 773 } | 772 } |
| 774 | 773 |
| 775 private: | 774 private: |
| 776 Expression* cond_; | 775 Expression* cond_; |
| 777 | 776 |
| 778 const BailoutId continue_id_; | 777 const BailoutId continue_id_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 795 } | 794 } |
| 796 void set_may_have_function_literal(bool value) { | 795 void set_may_have_function_literal(bool value) { |
| 797 may_have_function_literal_ = value; | 796 may_have_function_literal_ = value; |
| 798 } | 797 } |
| 799 | 798 |
| 800 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } | 799 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } |
| 801 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } | 800 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } |
| 802 BailoutId BodyId() const { return body_id_; } | 801 BailoutId BodyId() const { return body_id_; } |
| 803 | 802 |
| 804 protected: | 803 protected: |
| 805 WhileStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 804 WhileStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 806 : IterationStatement(zone, labels, pos), | 805 : IterationStatement(zone, labels, pos), |
| 807 cond_(NULL), | 806 cond_(NULL), |
| 808 may_have_function_literal_(true), | 807 may_have_function_literal_(true), |
| 809 body_id_(GetNextId(zone)) { | 808 body_id_(GetNextId(zone)) { |
| 810 } | 809 } |
| 811 | 810 |
| 812 private: | 811 private: |
| 813 Expression* cond_; | 812 Expression* cond_; |
| 814 | 813 |
| 815 // True if there is a function literal subexpression in the condition. | 814 // True if there is a function literal subexpression in the condition. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 846 | 845 |
| 847 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } | 846 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } |
| 848 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } | 847 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } |
| 849 BailoutId BodyId() const { return body_id_; } | 848 BailoutId BodyId() const { return body_id_; } |
| 850 | 849 |
| 851 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 850 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 852 Variable* loop_variable() { return loop_variable_; } | 851 Variable* loop_variable() { return loop_variable_; } |
| 853 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 852 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 854 | 853 |
| 855 protected: | 854 protected: |
| 856 ForStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 855 ForStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 857 : IterationStatement(zone, labels, pos), | 856 : IterationStatement(zone, labels, pos), |
| 858 init_(NULL), | 857 init_(NULL), |
| 859 cond_(NULL), | 858 cond_(NULL), |
| 860 next_(NULL), | 859 next_(NULL), |
| 861 may_have_function_literal_(true), | 860 may_have_function_literal_(true), |
| 862 loop_variable_(NULL), | 861 loop_variable_(NULL), |
| 863 continue_id_(GetNextId(zone)), | 862 continue_id_(GetNextId(zone)), |
| 864 body_id_(GetNextId(zone)) { | 863 body_id_(GetNextId(zone)) { |
| 865 } | 864 } |
| 866 | 865 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 888 void Initialize(Expression* each, Expression* subject, Statement* body) { | 887 void Initialize(Expression* each, Expression* subject, Statement* body) { |
| 889 IterationStatement::Initialize(body); | 888 IterationStatement::Initialize(body); |
| 890 each_ = each; | 889 each_ = each; |
| 891 subject_ = subject; | 890 subject_ = subject; |
| 892 } | 891 } |
| 893 | 892 |
| 894 Expression* each() const { return each_; } | 893 Expression* each() const { return each_; } |
| 895 Expression* subject() const { return subject_; } | 894 Expression* subject() const { return subject_; } |
| 896 | 895 |
| 897 protected: | 896 protected: |
| 898 ForEachStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 897 ForEachStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 899 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} | 898 : IterationStatement(zone, labels, pos), |
| 899 each_(NULL), |
| 900 subject_(NULL) { |
| 901 } |
| 900 | 902 |
| 901 private: | 903 private: |
| 902 Expression* each_; | 904 Expression* each_; |
| 903 Expression* subject_; | 905 Expression* subject_; |
| 904 }; | 906 }; |
| 905 | 907 |
| 906 | 908 |
| 907 class ForInStatement V8_FINAL : public ForEachStatement, | 909 class ForInStatement V8_FINAL : public ForEachStatement, |
| 908 public FeedbackSlotInterface { | 910 public FeedbackSlotInterface { |
| 909 public: | 911 public: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 925 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 927 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 926 ForInType for_in_type() const { return for_in_type_; } | 928 ForInType for_in_type() const { return for_in_type_; } |
| 927 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 929 void set_for_in_type(ForInType type) { for_in_type_ = type; } |
| 928 | 930 |
| 929 BailoutId BodyId() const { return body_id_; } | 931 BailoutId BodyId() const { return body_id_; } |
| 930 BailoutId PrepareId() const { return prepare_id_; } | 932 BailoutId PrepareId() const { return prepare_id_; } |
| 931 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } | 933 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } |
| 932 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } | 934 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } |
| 933 | 935 |
| 934 protected: | 936 protected: |
| 935 ForInStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 937 ForInStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 936 : ForEachStatement(zone, labels, pos), | 938 : ForEachStatement(zone, labels, pos), |
| 937 for_in_type_(SLOW_FOR_IN), | 939 for_in_type_(SLOW_FOR_IN), |
| 938 for_in_feedback_slot_(kInvalidFeedbackSlot), | 940 for_in_feedback_slot_(kInvalidFeedbackSlot), |
| 939 body_id_(GetNextId(zone)), | 941 body_id_(GetNextId(zone)), |
| 940 prepare_id_(GetNextId(zone)) { | 942 prepare_id_(GetNextId(zone)) { |
| 941 } | 943 } |
| 942 | 944 |
| 943 ForInType for_in_type_; | 945 ForInType for_in_type_; |
| 944 int for_in_feedback_slot_; | 946 int for_in_feedback_slot_; |
| 945 const BailoutId body_id_; | 947 const BailoutId body_id_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 Expression* assign_each() const { | 997 Expression* assign_each() const { |
| 996 return assign_each_; | 998 return assign_each_; |
| 997 } | 999 } |
| 998 | 1000 |
| 999 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } | 1001 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } |
| 1000 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); } | 1002 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); } |
| 1001 | 1003 |
| 1002 BailoutId BackEdgeId() const { return back_edge_id_; } | 1004 BailoutId BackEdgeId() const { return back_edge_id_; } |
| 1003 | 1005 |
| 1004 protected: | 1006 protected: |
| 1005 ForOfStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 1007 ForOfStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 1006 : ForEachStatement(zone, labels, pos), | 1008 : ForEachStatement(zone, labels, pos), |
| 1007 assign_iterator_(NULL), | 1009 assign_iterator_(NULL), |
| 1008 next_result_(NULL), | 1010 next_result_(NULL), |
| 1009 result_done_(NULL), | 1011 result_done_(NULL), |
| 1010 assign_each_(NULL), | 1012 assign_each_(NULL), |
| 1011 back_edge_id_(GetNextId(zone)) { | 1013 back_edge_id_(GetNextId(zone)) { |
| 1012 } | 1014 } |
| 1013 | 1015 |
| 1014 Expression* assign_iterable_; | 1016 Expression* assign_iterable_; |
| 1015 Expression* assign_iterator_; | 1017 Expression* assign_iterator_; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 | 1158 |
| 1157 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1159 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 1158 tag_ = tag; | 1160 tag_ = tag; |
| 1159 cases_ = cases; | 1161 cases_ = cases; |
| 1160 } | 1162 } |
| 1161 | 1163 |
| 1162 Expression* tag() const { return tag_; } | 1164 Expression* tag() const { return tag_; } |
| 1163 ZoneList<CaseClause*>* cases() const { return cases_; } | 1165 ZoneList<CaseClause*>* cases() const { return cases_; } |
| 1164 | 1166 |
| 1165 protected: | 1167 protected: |
| 1166 SwitchStatement(Zone* zone, ZoneList<const AstString*>* labels, int pos) | 1168 SwitchStatement(Zone* zone, ZoneStringList* labels, int pos) |
| 1167 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 1169 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
| 1168 tag_(NULL), | 1170 tag_(NULL), |
| 1169 cases_(NULL) { } | 1171 cases_(NULL) { } |
| 1170 | 1172 |
| 1171 private: | 1173 private: |
| 1172 Expression* tag_; | 1174 Expression* tag_; |
| 1173 ZoneList<CaseClause*>* cases_; | 1175 ZoneList<CaseClause*>* cases_; |
| 1174 }; | 1176 }; |
| 1175 | 1177 |
| 1176 | 1178 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 protected: | 1338 protected: |
| 1337 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} | 1339 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} |
| 1338 }; | 1340 }; |
| 1339 | 1341 |
| 1340 | 1342 |
| 1341 class Literal V8_FINAL : public Expression { | 1343 class Literal V8_FINAL : public Expression { |
| 1342 public: | 1344 public: |
| 1343 DECLARE_NODE_TYPE(Literal) | 1345 DECLARE_NODE_TYPE(Literal) |
| 1344 | 1346 |
| 1345 virtual bool IsPropertyName() const V8_OVERRIDE { | 1347 virtual bool IsPropertyName() const V8_OVERRIDE { |
| 1346 return value_->IsPropertyName(); | 1348 if (value_->IsInternalizedString()) { |
| 1349 uint32_t ignored; |
| 1350 return !String::cast(*value_)->AsArrayIndex(&ignored); |
| 1351 } |
| 1352 return false; |
| 1347 } | 1353 } |
| 1348 | 1354 |
| 1349 Handle<String> AsPropertyName() { | 1355 Handle<String> AsPropertyName() { |
| 1350 ASSERT(IsPropertyName()); | 1356 ASSERT(IsPropertyName()); |
| 1351 return Handle<String>::cast(value()); | 1357 return Handle<String>::cast(value_); |
| 1352 } | |
| 1353 | |
| 1354 const AstString* AsRawPropertyName() { | |
| 1355 ASSERT(IsPropertyName()); | |
| 1356 return value_->AsString(); | |
| 1357 } | 1358 } |
| 1358 | 1359 |
| 1359 virtual bool ToBooleanIsTrue() const V8_OVERRIDE { | 1360 virtual bool ToBooleanIsTrue() const V8_OVERRIDE { |
| 1360 return value()->BooleanValue(); | 1361 return value_->BooleanValue(); |
| 1361 } | 1362 } |
| 1362 virtual bool ToBooleanIsFalse() const V8_OVERRIDE { | 1363 virtual bool ToBooleanIsFalse() const V8_OVERRIDE { |
| 1363 return !value()->BooleanValue(); | 1364 return !value_->BooleanValue(); |
| 1364 } | 1365 } |
| 1365 | 1366 |
| 1366 Handle<Object> value() const { return value_->value(); } | 1367 Handle<Object> value() const { return value_; } |
| 1367 const AstValue* raw_value() const { return value_; } | |
| 1368 | 1368 |
| 1369 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1369 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
| 1370 // only for string and number literals! | 1370 // only for string and number literals! |
| 1371 uint32_t Hash() { return ToString()->Hash(); } | 1371 uint32_t Hash() { return ToString()->Hash(); } |
| 1372 | 1372 |
| 1373 static bool Match(void* literal1, void* literal2) { | 1373 static bool Match(void* literal1, void* literal2) { |
| 1374 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); | 1374 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); |
| 1375 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); | 1375 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); |
| 1376 return String::Equals(s1, s2); | 1376 return String::Equals(s1, s2); |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } | 1379 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } |
| 1380 | 1380 |
| 1381 protected: | 1381 protected: |
| 1382 Literal(Zone* zone, const AstValue* value, int position) | 1382 Literal(Zone* zone, Handle<Object> value, int position) |
| 1383 : Expression(zone, position), | 1383 : Expression(zone, position), |
| 1384 value_(value), | 1384 value_(value), |
| 1385 isolate_(zone->isolate()) { } | 1385 isolate_(zone->isolate()) { } |
| 1386 | 1386 |
| 1387 private: | 1387 private: |
| 1388 Handle<String> ToString(); | 1388 Handle<String> ToString(); |
| 1389 | 1389 |
| 1390 const AstValue* value_; | 1390 Handle<Object> value_; |
| 1391 // TODO(dcarney): remove. this is only needed for Match and Hash. | 1391 // TODO(dcarney): remove. this is only needed for Match and Hash. |
| 1392 Isolate* isolate_; | 1392 Isolate* isolate_; |
| 1393 }; | 1393 }; |
| 1394 | 1394 |
| 1395 | 1395 |
| 1396 // Base class for literals that needs space in the corresponding JSFunction. | 1396 // Base class for literals that needs space in the corresponding JSFunction. |
| 1397 class MaterializedLiteral : public Expression { | 1397 class MaterializedLiteral : public Expression { |
| 1398 public: | 1398 public: |
| 1399 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1399 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 1400 | 1400 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 class ObjectLiteralProperty V8_FINAL : public ZoneObject { | 1451 class ObjectLiteralProperty V8_FINAL : public ZoneObject { |
| 1452 public: | 1452 public: |
| 1453 enum Kind { | 1453 enum Kind { |
| 1454 CONSTANT, // Property with constant value (compile time). | 1454 CONSTANT, // Property with constant value (compile time). |
| 1455 COMPUTED, // Property with computed value (execution time). | 1455 COMPUTED, // Property with computed value (execution time). |
| 1456 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 1456 MATERIALIZED_LITERAL, // Property value is a materialized literal. |
| 1457 GETTER, SETTER, // Property is an accessor function. | 1457 GETTER, SETTER, // Property is an accessor function. |
| 1458 PROTOTYPE // Property is __proto__. | 1458 PROTOTYPE // Property is __proto__. |
| 1459 }; | 1459 }; |
| 1460 | 1460 |
| 1461 ObjectLiteralProperty(Zone* zone, AstValueFactory* ast_value_factory, | 1461 ObjectLiteralProperty(Zone* zone, Literal* key, Expression* value); |
| 1462 Literal* key, Expression* value); | |
| 1463 | 1462 |
| 1464 Literal* key() { return key_; } | 1463 Literal* key() { return key_; } |
| 1465 Expression* value() { return value_; } | 1464 Expression* value() { return value_; } |
| 1466 Kind kind() { return kind_; } | 1465 Kind kind() { return kind_; } |
| 1467 | 1466 |
| 1468 // Type feedback information. | 1467 // Type feedback information. |
| 1469 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1468 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1470 bool IsMonomorphic() { return !receiver_type_.is_null(); } | 1469 bool IsMonomorphic() { return !receiver_type_.is_null(); } |
| 1471 Handle<Map> GetReceiverType() { return receiver_type_; } | 1470 Handle<Map> GetReceiverType() { return receiver_type_; } |
| 1472 | 1471 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 bool may_store_doubles_; | 1550 bool may_store_doubles_; |
| 1552 bool has_function_; | 1551 bool has_function_; |
| 1553 }; | 1552 }; |
| 1554 | 1553 |
| 1555 | 1554 |
| 1556 // Node for capturing a regexp literal. | 1555 // Node for capturing a regexp literal. |
| 1557 class RegExpLiteral V8_FINAL : public MaterializedLiteral { | 1556 class RegExpLiteral V8_FINAL : public MaterializedLiteral { |
| 1558 public: | 1557 public: |
| 1559 DECLARE_NODE_TYPE(RegExpLiteral) | 1558 DECLARE_NODE_TYPE(RegExpLiteral) |
| 1560 | 1559 |
| 1561 Handle<String> pattern() const { return pattern_->string(); } | 1560 Handle<String> pattern() const { return pattern_; } |
| 1562 Handle<String> flags() const { return flags_->string(); } | 1561 Handle<String> flags() const { return flags_; } |
| 1563 | 1562 |
| 1564 protected: | 1563 protected: |
| 1565 RegExpLiteral(Zone* zone, | 1564 RegExpLiteral(Zone* zone, |
| 1566 const AstString* pattern, | 1565 Handle<String> pattern, |
| 1567 const AstString* flags, | 1566 Handle<String> flags, |
| 1568 int literal_index, | 1567 int literal_index, |
| 1569 int pos) | 1568 int pos) |
| 1570 : MaterializedLiteral(zone, literal_index, pos), | 1569 : MaterializedLiteral(zone, literal_index, pos), |
| 1571 pattern_(pattern), | 1570 pattern_(pattern), |
| 1572 flags_(flags) { | 1571 flags_(flags) { |
| 1573 set_depth(1); | 1572 set_depth(1); |
| 1574 } | 1573 } |
| 1575 | 1574 |
| 1576 private: | 1575 private: |
| 1577 const AstString* pattern_; | 1576 Handle<String> pattern_; |
| 1578 const AstString* flags_; | 1577 Handle<String> flags_; |
| 1579 }; | 1578 }; |
| 1580 | 1579 |
| 1581 | 1580 |
| 1582 // An array literal has a literals object that is used | 1581 // An array literal has a literals object that is used |
| 1583 // for minimizing the work when constructing it at runtime. | 1582 // for minimizing the work when constructing it at runtime. |
| 1584 class ArrayLiteral V8_FINAL : public MaterializedLiteral { | 1583 class ArrayLiteral V8_FINAL : public MaterializedLiteral { |
| 1585 public: | 1584 public: |
| 1586 DECLARE_NODE_TYPE(ArrayLiteral) | 1585 DECLARE_NODE_TYPE(ArrayLiteral) |
| 1587 | 1586 |
| 1588 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1587 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1619 | 1618 |
| 1620 | 1619 |
| 1621 class VariableProxy V8_FINAL : public Expression { | 1620 class VariableProxy V8_FINAL : public Expression { |
| 1622 public: | 1621 public: |
| 1623 DECLARE_NODE_TYPE(VariableProxy) | 1622 DECLARE_NODE_TYPE(VariableProxy) |
| 1624 | 1623 |
| 1625 virtual bool IsValidReferenceExpression() const V8_OVERRIDE { | 1624 virtual bool IsValidReferenceExpression() const V8_OVERRIDE { |
| 1626 return var_ == NULL ? true : var_->IsValidReference(); | 1625 return var_ == NULL ? true : var_->IsValidReference(); |
| 1627 } | 1626 } |
| 1628 | 1627 |
| 1628 bool IsVariable(Handle<String> n) const { |
| 1629 return !is_this() && name().is_identical_to(n); |
| 1630 } |
| 1631 |
| 1629 bool IsArguments() const { return var_ != NULL && var_->is_arguments(); } | 1632 bool IsArguments() const { return var_ != NULL && var_->is_arguments(); } |
| 1630 | 1633 |
| 1631 bool IsLValue() const { return is_lvalue_; } | 1634 bool IsLValue() const { return is_lvalue_; } |
| 1632 | 1635 |
| 1633 Handle<String> name() const { return name_->string(); } | 1636 Handle<String> name() const { return name_; } |
| 1634 const AstString* raw_name() const { return name_; } | |
| 1635 Variable* var() const { return var_; } | 1637 Variable* var() const { return var_; } |
| 1636 bool is_this() const { return is_this_; } | 1638 bool is_this() const { return is_this_; } |
| 1637 Interface* interface() const { return interface_; } | 1639 Interface* interface() const { return interface_; } |
| 1638 | 1640 |
| 1639 | 1641 |
| 1640 void MarkAsTrivial() { is_trivial_ = true; } | 1642 void MarkAsTrivial() { is_trivial_ = true; } |
| 1641 void MarkAsLValue() { is_lvalue_ = true; } | 1643 void MarkAsLValue() { is_lvalue_ = true; } |
| 1642 | 1644 |
| 1643 // Bind this proxy to the variable var. Interfaces must match. | 1645 // Bind this proxy to the variable var. Interfaces must match. |
| 1644 void BindTo(Variable* var); | 1646 void BindTo(Variable* var); |
| 1645 | 1647 |
| 1646 protected: | 1648 protected: |
| 1647 VariableProxy(Zone* zone, Variable* var, int position); | 1649 VariableProxy(Zone* zone, Variable* var, int position); |
| 1648 | 1650 |
| 1649 VariableProxy(Zone* zone, | 1651 VariableProxy(Zone* zone, |
| 1650 const AstString* name, | 1652 Handle<String> name, |
| 1651 bool is_this, | 1653 bool is_this, |
| 1652 Interface* interface, | 1654 Interface* interface, |
| 1653 int position); | 1655 int position); |
| 1654 | 1656 |
| 1655 const AstString* name_; | 1657 Handle<String> name_; |
| 1656 Variable* var_; // resolved variable, or NULL | 1658 Variable* var_; // resolved variable, or NULL |
| 1657 bool is_this_; | 1659 bool is_this_; |
| 1658 bool is_trivial_; | 1660 bool is_trivial_; |
| 1659 // True if this variable proxy is being used in an assignment | 1661 // True if this variable proxy is being used in an assignment |
| 1660 // or with a increment/decrement operator. | 1662 // or with a increment/decrement operator. |
| 1661 bool is_lvalue_; | 1663 bool is_lvalue_; |
| 1662 Interface* interface_; | 1664 Interface* interface_; |
| 1663 }; | 1665 }; |
| 1664 | 1666 |
| 1665 | 1667 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 | 1893 |
| 1892 | 1894 |
| 1893 // The CallRuntime class does not represent any official JavaScript | 1895 // The CallRuntime class does not represent any official JavaScript |
| 1894 // language construct. Instead it is used to call a C or JS function | 1896 // language construct. Instead it is used to call a C or JS function |
| 1895 // with a set of arguments. This is used from the builtins that are | 1897 // with a set of arguments. This is used from the builtins that are |
| 1896 // implemented in JavaScript (see "v8natives.js"). | 1898 // implemented in JavaScript (see "v8natives.js"). |
| 1897 class CallRuntime V8_FINAL : public Expression { | 1899 class CallRuntime V8_FINAL : public Expression { |
| 1898 public: | 1900 public: |
| 1899 DECLARE_NODE_TYPE(CallRuntime) | 1901 DECLARE_NODE_TYPE(CallRuntime) |
| 1900 | 1902 |
| 1901 Handle<String> name() const { return raw_name_->string(); } | 1903 Handle<String> name() const { return name_; } |
| 1902 const AstString* raw_name() const { return raw_name_; } | |
| 1903 const Runtime::Function* function() const { return function_; } | 1904 const Runtime::Function* function() const { return function_; } |
| 1904 ZoneList<Expression*>* arguments() const { return arguments_; } | 1905 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1905 bool is_jsruntime() const { return function_ == NULL; } | 1906 bool is_jsruntime() const { return function_ == NULL; } |
| 1906 | 1907 |
| 1907 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } | 1908 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } |
| 1908 | 1909 |
| 1909 protected: | 1910 protected: |
| 1910 CallRuntime(Zone* zone, | 1911 CallRuntime(Zone* zone, |
| 1911 const AstString* name, | 1912 Handle<String> name, |
| 1912 const Runtime::Function* function, | 1913 const Runtime::Function* function, |
| 1913 ZoneList<Expression*>* arguments, | 1914 ZoneList<Expression*>* arguments, |
| 1914 int pos) | 1915 int pos) |
| 1915 : Expression(zone, pos), | 1916 : Expression(zone, pos), |
| 1916 raw_name_(name), | 1917 name_(name), |
| 1917 function_(function), | 1918 function_(function), |
| 1918 arguments_(arguments) { } | 1919 arguments_(arguments) { } |
| 1919 | 1920 |
| 1920 private: | 1921 private: |
| 1921 const AstString* raw_name_; | 1922 Handle<String> name_; |
| 1922 const Runtime::Function* function_; | 1923 const Runtime::Function* function_; |
| 1923 ZoneList<Expression*>* arguments_; | 1924 ZoneList<Expression*>* arguments_; |
| 1924 }; | 1925 }; |
| 1925 | 1926 |
| 1926 | 1927 |
| 1927 class UnaryOperation V8_FINAL : public Expression { | 1928 class UnaryOperation V8_FINAL : public Expression { |
| 1928 public: | 1929 public: |
| 1929 DECLARE_NODE_TYPE(UnaryOperation) | 1930 DECLARE_NODE_TYPE(UnaryOperation) |
| 1930 | 1931 |
| 1931 Token::Value op() const { return op_; } | 1932 Token::Value op() const { return op_; } |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2305 }; | 2306 }; |
| 2306 | 2307 |
| 2307 enum ArityRestriction { | 2308 enum ArityRestriction { |
| 2308 NORMAL_ARITY, | 2309 NORMAL_ARITY, |
| 2309 GETTER_ARITY, | 2310 GETTER_ARITY, |
| 2310 SETTER_ARITY | 2311 SETTER_ARITY |
| 2311 }; | 2312 }; |
| 2312 | 2313 |
| 2313 DECLARE_NODE_TYPE(FunctionLiteral) | 2314 DECLARE_NODE_TYPE(FunctionLiteral) |
| 2314 | 2315 |
| 2315 Handle<String> name() const { return raw_name_->string(); } | 2316 Handle<String> name() const { return name_; } |
| 2316 const AstString* raw_name() const { return raw_name_; } | |
| 2317 Scope* scope() const { return scope_; } | 2317 Scope* scope() const { return scope_; } |
| 2318 ZoneList<Statement*>* body() const { return body_; } | 2318 ZoneList<Statement*>* body() const { return body_; } |
| 2319 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2319 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 2320 int function_token_position() const { return function_token_position_; } | 2320 int function_token_position() const { return function_token_position_; } |
| 2321 int start_position() const; | 2321 int start_position() const; |
| 2322 int end_position() const; | 2322 int end_position() const; |
| 2323 int SourceSize() const { return end_position() - start_position(); } | 2323 int SourceSize() const { return end_position() - start_position(); } |
| 2324 bool is_expression() const { return IsExpression::decode(bitfield_); } | 2324 bool is_expression() const { return IsExpression::decode(bitfield_); } |
| 2325 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } | 2325 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } |
| 2326 StrictMode strict_mode() const; | 2326 StrictMode strict_mode() const; |
| 2327 | 2327 |
| 2328 int materialized_literal_count() { return materialized_literal_count_; } | 2328 int materialized_literal_count() { return materialized_literal_count_; } |
| 2329 int expected_property_count() { return expected_property_count_; } | 2329 int expected_property_count() { return expected_property_count_; } |
| 2330 int handler_count() { return handler_count_; } | 2330 int handler_count() { return handler_count_; } |
| 2331 int parameter_count() { return parameter_count_; } | 2331 int parameter_count() { return parameter_count_; } |
| 2332 | 2332 |
| 2333 bool AllowsLazyCompilation(); | 2333 bool AllowsLazyCompilation(); |
| 2334 bool AllowsLazyCompilationWithoutContext(); | 2334 bool AllowsLazyCompilationWithoutContext(); |
| 2335 | 2335 |
| 2336 void InitializeSharedInfo(Handle<Code> code); | 2336 void InitializeSharedInfo(Handle<Code> code); |
| 2337 | 2337 |
| 2338 Handle<String> debug_name() const { | 2338 Handle<String> debug_name() const { |
| 2339 if (raw_name_ != NULL && !raw_name_->IsEmpty()) { | 2339 if (name_->length() > 0) return name_; |
| 2340 return raw_name_->string(); | |
| 2341 } | |
| 2342 return inferred_name(); | 2340 return inferred_name(); |
| 2343 } | 2341 } |
| 2344 | 2342 |
| 2345 Handle<String> inferred_name() const { | 2343 Handle<String> inferred_name() const { return inferred_name_; } |
| 2346 if (!inferred_name_.is_null()) { | |
| 2347 ASSERT(raw_inferred_name_ == NULL); | |
| 2348 return inferred_name_; | |
| 2349 } | |
| 2350 if (raw_inferred_name_ != NULL) { | |
| 2351 return raw_inferred_name_->string(); | |
| 2352 } | |
| 2353 UNREACHABLE(); | |
| 2354 return Handle<String>(); | |
| 2355 } | |
| 2356 | |
| 2357 // Only one of {set_inferred_name, set_raw_inferred_name} should be called. | |
| 2358 void set_inferred_name(Handle<String> inferred_name) { | 2344 void set_inferred_name(Handle<String> inferred_name) { |
| 2359 inferred_name_ = inferred_name; | 2345 inferred_name_ = inferred_name; |
| 2360 ASSERT(raw_inferred_name_== NULL || raw_inferred_name_->IsEmpty()); | |
| 2361 raw_inferred_name_ = NULL; | |
| 2362 } | |
| 2363 | |
| 2364 void set_raw_inferred_name(const AstString* raw_inferred_name) { | |
| 2365 raw_inferred_name_ = raw_inferred_name; | |
| 2366 ASSERT(inferred_name_.is_null()); | |
| 2367 inferred_name_ = Handle<String>(); | |
| 2368 } | 2346 } |
| 2369 | 2347 |
| 2370 // shared_info may be null if it's not cached in full code. | 2348 // shared_info may be null if it's not cached in full code. |
| 2371 Handle<SharedFunctionInfo> shared_info() { return shared_info_; } | 2349 Handle<SharedFunctionInfo> shared_info() { return shared_info_; } |
| 2372 | 2350 |
| 2373 bool pretenure() { return Pretenure::decode(bitfield_); } | 2351 bool pretenure() { return Pretenure::decode(bitfield_); } |
| 2374 void set_pretenure() { bitfield_ |= Pretenure::encode(true); } | 2352 void set_pretenure() { bitfield_ |= Pretenure::encode(true); } |
| 2375 | 2353 |
| 2376 bool has_duplicate_parameters() { | 2354 bool has_duplicate_parameters() { |
| 2377 return HasDuplicateParameters::decode(bitfield_); | 2355 return HasDuplicateParameters::decode(bitfield_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2404 return ast_properties_.feedback_slots(); | 2382 return ast_properties_.feedback_slots(); |
| 2405 } | 2383 } |
| 2406 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2384 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
| 2407 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2385 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
| 2408 void set_dont_optimize_reason(BailoutReason reason) { | 2386 void set_dont_optimize_reason(BailoutReason reason) { |
| 2409 dont_optimize_reason_ = reason; | 2387 dont_optimize_reason_ = reason; |
| 2410 } | 2388 } |
| 2411 | 2389 |
| 2412 protected: | 2390 protected: |
| 2413 FunctionLiteral(Zone* zone, | 2391 FunctionLiteral(Zone* zone, |
| 2414 const AstString* name, | 2392 Handle<String> name, |
| 2415 AstValueFactory* ast_value_factory, | |
| 2416 Scope* scope, | 2393 Scope* scope, |
| 2417 ZoneList<Statement*>* body, | 2394 ZoneList<Statement*>* body, |
| 2418 int materialized_literal_count, | 2395 int materialized_literal_count, |
| 2419 int expected_property_count, | 2396 int expected_property_count, |
| 2420 int handler_count, | 2397 int handler_count, |
| 2421 int parameter_count, | 2398 int parameter_count, |
| 2422 FunctionType function_type, | 2399 FunctionType function_type, |
| 2423 ParameterFlag has_duplicate_parameters, | 2400 ParameterFlag has_duplicate_parameters, |
| 2424 IsFunctionFlag is_function, | 2401 IsFunctionFlag is_function, |
| 2425 IsParenthesizedFlag is_parenthesized, | 2402 IsParenthesizedFlag is_parenthesized, |
| 2426 IsGeneratorFlag is_generator, | 2403 IsGeneratorFlag is_generator, |
| 2427 int position) | 2404 int position) |
| 2428 : Expression(zone, position), | 2405 : Expression(zone, position), |
| 2429 raw_name_(name), | 2406 name_(name), |
| 2430 scope_(scope), | 2407 scope_(scope), |
| 2431 body_(body), | 2408 body_(body), |
| 2432 raw_inferred_name_(ast_value_factory->empty_string()), | 2409 inferred_name_(zone->isolate()->factory()->empty_string()), |
| 2433 dont_optimize_reason_(kNoReason), | 2410 dont_optimize_reason_(kNoReason), |
| 2434 materialized_literal_count_(materialized_literal_count), | 2411 materialized_literal_count_(materialized_literal_count), |
| 2435 expected_property_count_(expected_property_count), | 2412 expected_property_count_(expected_property_count), |
| 2436 handler_count_(handler_count), | 2413 handler_count_(handler_count), |
| 2437 parameter_count_(parameter_count), | 2414 parameter_count_(parameter_count), |
| 2438 function_token_position_(RelocInfo::kNoPosition) { | 2415 function_token_position_(RelocInfo::kNoPosition) { |
| 2439 bitfield_ = | 2416 bitfield_ = |
| 2440 IsExpression::encode(function_type != DECLARATION) | | 2417 IsExpression::encode(function_type != DECLARATION) | |
| 2441 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | | 2418 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | |
| 2442 Pretenure::encode(false) | | 2419 Pretenure::encode(false) | |
| 2443 HasDuplicateParameters::encode(has_duplicate_parameters) | | 2420 HasDuplicateParameters::encode(has_duplicate_parameters) | |
| 2444 IsFunction::encode(is_function) | | 2421 IsFunction::encode(is_function) | |
| 2445 IsParenthesized::encode(is_parenthesized) | | 2422 IsParenthesized::encode(is_parenthesized) | |
| 2446 IsGenerator::encode(is_generator); | 2423 IsGenerator::encode(is_generator); |
| 2447 } | 2424 } |
| 2448 | 2425 |
| 2449 private: | 2426 private: |
| 2450 const AstString* raw_name_; | |
| 2451 Handle<String> name_; | 2427 Handle<String> name_; |
| 2452 Handle<SharedFunctionInfo> shared_info_; | 2428 Handle<SharedFunctionInfo> shared_info_; |
| 2453 Scope* scope_; | 2429 Scope* scope_; |
| 2454 ZoneList<Statement*>* body_; | 2430 ZoneList<Statement*>* body_; |
| 2455 const AstString* raw_inferred_name_; | |
| 2456 Handle<String> inferred_name_; | 2431 Handle<String> inferred_name_; |
| 2457 AstProperties ast_properties_; | 2432 AstProperties ast_properties_; |
| 2458 BailoutReason dont_optimize_reason_; | 2433 BailoutReason dont_optimize_reason_; |
| 2459 | 2434 |
| 2460 int materialized_literal_count_; | 2435 int materialized_literal_count_; |
| 2461 int expected_property_count_; | 2436 int expected_property_count_; |
| 2462 int handler_count_; | 2437 int handler_count_; |
| 2463 int parameter_count_; | 2438 int parameter_count_; |
| 2464 int function_token_position_; | 2439 int function_token_position_; |
| 2465 | 2440 |
| 2466 unsigned bitfield_; | 2441 unsigned bitfield_; |
| 2467 class IsExpression: public BitField<bool, 0, 1> {}; | 2442 class IsExpression: public BitField<bool, 0, 1> {}; |
| 2468 class IsAnonymous: public BitField<bool, 1, 1> {}; | 2443 class IsAnonymous: public BitField<bool, 1, 1> {}; |
| 2469 class Pretenure: public BitField<bool, 2, 1> {}; | 2444 class Pretenure: public BitField<bool, 2, 1> {}; |
| 2470 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; | 2445 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; |
| 2471 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; | 2446 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; |
| 2472 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; | 2447 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; |
| 2473 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; | 2448 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; |
| 2474 }; | 2449 }; |
| 2475 | 2450 |
| 2476 | 2451 |
| 2477 class NativeFunctionLiteral V8_FINAL : public Expression { | 2452 class NativeFunctionLiteral V8_FINAL : public Expression { |
| 2478 public: | 2453 public: |
| 2479 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2454 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
| 2480 | 2455 |
| 2481 Handle<String> name() const { return name_->string(); } | 2456 Handle<String> name() const { return name_; } |
| 2482 v8::Extension* extension() const { return extension_; } | 2457 v8::Extension* extension() const { return extension_; } |
| 2483 | 2458 |
| 2484 protected: | 2459 protected: |
| 2485 NativeFunctionLiteral(Zone* zone, const AstString* name, | 2460 NativeFunctionLiteral( |
| 2486 v8::Extension* extension, int pos) | 2461 Zone* zone, Handle<String> name, v8::Extension* extension, int pos) |
| 2487 : Expression(zone, pos), name_(name), extension_(extension) {} | 2462 : Expression(zone, pos), name_(name), extension_(extension) {} |
| 2488 | 2463 |
| 2489 private: | 2464 private: |
| 2490 const AstString* name_; | 2465 Handle<String> name_; |
| 2491 v8::Extension* extension_; | 2466 v8::Extension* extension_; |
| 2492 }; | 2467 }; |
| 2493 | 2468 |
| 2494 | 2469 |
| 2495 class ThisFunction V8_FINAL : public Expression { | 2470 class ThisFunction V8_FINAL : public Expression { |
| 2496 public: | 2471 public: |
| 2497 DECLARE_NODE_TYPE(ThisFunction) | 2472 DECLARE_NODE_TYPE(ThisFunction) |
| 2498 | 2473 |
| 2499 protected: | 2474 protected: |
| 2500 explicit ThisFunction(Zone* zone, int pos): Expression(zone, pos) {} | 2475 explicit ThisFunction(Zone* zone, int pos): Expression(zone, pos) {} |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2972 }; | 2947 }; |
| 2973 | 2948 |
| 2974 | 2949 |
| 2975 | 2950 |
| 2976 // ---------------------------------------------------------------------------- | 2951 // ---------------------------------------------------------------------------- |
| 2977 // AstNode factory | 2952 // AstNode factory |
| 2978 | 2953 |
| 2979 template<class Visitor> | 2954 template<class Visitor> |
| 2980 class AstNodeFactory V8_FINAL BASE_EMBEDDED { | 2955 class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
| 2981 public: | 2956 public: |
| 2982 explicit AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory) | 2957 explicit AstNodeFactory(Zone* zone) : zone_(zone) { } |
| 2983 : zone_(zone), ast_value_factory_(ast_value_factory) {} | |
| 2984 | 2958 |
| 2985 Visitor* visitor() { return &visitor_; } | 2959 Visitor* visitor() { return &visitor_; } |
| 2986 | 2960 |
| 2987 #define VISIT_AND_RETURN(NodeType, node) \ | 2961 #define VISIT_AND_RETURN(NodeType, node) \ |
| 2988 visitor_.Visit##NodeType((node)); \ | 2962 visitor_.Visit##NodeType((node)); \ |
| 2989 return node; | 2963 return node; |
| 2990 | 2964 |
| 2991 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, | 2965 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
| 2992 VariableMode mode, | 2966 VariableMode mode, |
| 2993 Scope* scope, | 2967 Scope* scope, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3037 ModuleLiteral* module = | 3011 ModuleLiteral* module = |
| 3038 new(zone_) ModuleLiteral(zone_, body, interface, pos); | 3012 new(zone_) ModuleLiteral(zone_, body, interface, pos); |
| 3039 VISIT_AND_RETURN(ModuleLiteral, module) | 3013 VISIT_AND_RETURN(ModuleLiteral, module) |
| 3040 } | 3014 } |
| 3041 | 3015 |
| 3042 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) { | 3016 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) { |
| 3043 ModuleVariable* module = new(zone_) ModuleVariable(zone_, proxy, pos); | 3017 ModuleVariable* module = new(zone_) ModuleVariable(zone_, proxy, pos); |
| 3044 VISIT_AND_RETURN(ModuleVariable, module) | 3018 VISIT_AND_RETURN(ModuleVariable, module) |
| 3045 } | 3019 } |
| 3046 | 3020 |
| 3047 ModulePath* NewModulePath(Module* origin, const AstString* name, int pos) { | 3021 ModulePath* NewModulePath(Module* origin, Handle<String> name, int pos) { |
| 3048 ModulePath* module = new (zone_) ModulePath(zone_, origin, name, pos); | 3022 ModulePath* module = new(zone_) ModulePath(zone_, origin, name, pos); |
| 3049 VISIT_AND_RETURN(ModulePath, module) | 3023 VISIT_AND_RETURN(ModulePath, module) |
| 3050 } | 3024 } |
| 3051 | 3025 |
| 3052 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { | 3026 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { |
| 3053 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); | 3027 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); |
| 3054 VISIT_AND_RETURN(ModuleUrl, module) | 3028 VISIT_AND_RETURN(ModuleUrl, module) |
| 3055 } | 3029 } |
| 3056 | 3030 |
| 3057 Block* NewBlock(ZoneList<const AstString*>* labels, | 3031 Block* NewBlock(ZoneStringList* labels, |
| 3058 int capacity, | 3032 int capacity, |
| 3059 bool is_initializer_block, | 3033 bool is_initializer_block, |
| 3060 int pos) { | 3034 int pos) { |
| 3061 Block* block = new(zone_) Block( | 3035 Block* block = new(zone_) Block( |
| 3062 zone_, labels, capacity, is_initializer_block, pos); | 3036 zone_, labels, capacity, is_initializer_block, pos); |
| 3063 VISIT_AND_RETURN(Block, block) | 3037 VISIT_AND_RETURN(Block, block) |
| 3064 } | 3038 } |
| 3065 | 3039 |
| 3066 #define STATEMENT_WITH_LABELS(NodeType) \ | 3040 #define STATEMENT_WITH_LABELS(NodeType) \ |
| 3067 NodeType* New##NodeType(ZoneList<const AstString*>* labels, int pos) { \ | 3041 NodeType* New##NodeType(ZoneStringList* labels, int pos) { \ |
| 3068 NodeType* stmt = new(zone_) NodeType(zone_, labels, pos); \ | 3042 NodeType* stmt = new(zone_) NodeType(zone_, labels, pos); \ |
| 3069 VISIT_AND_RETURN(NodeType, stmt); \ | 3043 VISIT_AND_RETURN(NodeType, stmt); \ |
| 3070 } | 3044 } |
| 3071 STATEMENT_WITH_LABELS(DoWhileStatement) | 3045 STATEMENT_WITH_LABELS(DoWhileStatement) |
| 3072 STATEMENT_WITH_LABELS(WhileStatement) | 3046 STATEMENT_WITH_LABELS(WhileStatement) |
| 3073 STATEMENT_WITH_LABELS(ForStatement) | 3047 STATEMENT_WITH_LABELS(ForStatement) |
| 3074 STATEMENT_WITH_LABELS(SwitchStatement) | 3048 STATEMENT_WITH_LABELS(SwitchStatement) |
| 3075 #undef STATEMENT_WITH_LABELS | 3049 #undef STATEMENT_WITH_LABELS |
| 3076 | 3050 |
| 3077 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, | 3051 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, |
| 3078 ZoneList<const AstString*>* labels, | 3052 ZoneStringList* labels, |
| 3079 int pos) { | 3053 int pos) { |
| 3080 switch (visit_mode) { | 3054 switch (visit_mode) { |
| 3081 case ForEachStatement::ENUMERATE: { | 3055 case ForEachStatement::ENUMERATE: { |
| 3082 ForInStatement* stmt = new(zone_) ForInStatement(zone_, labels, pos); | 3056 ForInStatement* stmt = new(zone_) ForInStatement(zone_, labels, pos); |
| 3083 VISIT_AND_RETURN(ForInStatement, stmt); | 3057 VISIT_AND_RETURN(ForInStatement, stmt); |
| 3084 } | 3058 } |
| 3085 case ForEachStatement::ITERATE: { | 3059 case ForEachStatement::ITERATE: { |
| 3086 ForOfStatement* stmt = new(zone_) ForOfStatement(zone_, labels, pos); | 3060 ForOfStatement* stmt = new(zone_) ForOfStatement(zone_, labels, pos); |
| 3087 VISIT_AND_RETURN(ForOfStatement, stmt); | 3061 VISIT_AND_RETURN(ForOfStatement, stmt); |
| 3088 } | 3062 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3165 return new(zone_) EmptyStatement(zone_, pos); | 3139 return new(zone_) EmptyStatement(zone_, pos); |
| 3166 } | 3140 } |
| 3167 | 3141 |
| 3168 CaseClause* NewCaseClause( | 3142 CaseClause* NewCaseClause( |
| 3169 Expression* label, ZoneList<Statement*>* statements, int pos) { | 3143 Expression* label, ZoneList<Statement*>* statements, int pos) { |
| 3170 CaseClause* clause = | 3144 CaseClause* clause = |
| 3171 new(zone_) CaseClause(zone_, label, statements, pos); | 3145 new(zone_) CaseClause(zone_, label, statements, pos); |
| 3172 VISIT_AND_RETURN(CaseClause, clause) | 3146 VISIT_AND_RETURN(CaseClause, clause) |
| 3173 } | 3147 } |
| 3174 | 3148 |
| 3175 Literal* NewStringLiteral(const AstString* string, int pos) { | 3149 Literal* NewLiteral(Handle<Object> handle, int pos) { |
| 3176 Literal* lit = | 3150 Literal* lit = new(zone_) Literal(zone_, handle, pos); |
| 3177 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos); | |
| 3178 VISIT_AND_RETURN(Literal, lit) | |
| 3179 } | |
| 3180 | |
| 3181 // A JavaScript symbol (ECMA-262 edition 6). | |
| 3182 Literal* NewSymbolLiteral(const char* name, int pos) { | |
| 3183 Literal* lit = | |
| 3184 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); | |
| 3185 VISIT_AND_RETURN(Literal, lit) | 3151 VISIT_AND_RETURN(Literal, lit) |
| 3186 } | 3152 } |
| 3187 | 3153 |
| 3188 Literal* NewNumberLiteral(double number, int pos) { | 3154 Literal* NewNumberLiteral(double number, int pos) { |
| 3189 Literal* lit = new (zone_) | 3155 return NewLiteral( |
| 3190 Literal(zone_, ast_value_factory_->NewNumber(number), pos); | 3156 zone_->isolate()->factory()->NewNumber(number, TENURED), pos); |
| 3191 VISIT_AND_RETURN(Literal, lit) | |
| 3192 } | |
| 3193 | |
| 3194 Literal* NewSmiLiteral(int number, int pos) { | |
| 3195 Literal* lit = | |
| 3196 new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); | |
| 3197 VISIT_AND_RETURN(Literal, lit) | |
| 3198 } | |
| 3199 | |
| 3200 Literal* NewBooleanLiteral(bool b, int pos) { | |
| 3201 Literal* lit = | |
| 3202 new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); | |
| 3203 VISIT_AND_RETURN(Literal, lit) | |
| 3204 } | |
| 3205 | |
| 3206 Literal* NewStringListLiteral(ZoneList<const AstString*>* strings, int pos) { | |
| 3207 Literal* lit = new (zone_) | |
| 3208 Literal(zone_, ast_value_factory_->NewStringList(strings), pos); | |
| 3209 VISIT_AND_RETURN(Literal, lit) | |
| 3210 } | |
| 3211 | |
| 3212 Literal* NewNullLiteral(int pos) { | |
| 3213 Literal* lit = | |
| 3214 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); | |
| 3215 VISIT_AND_RETURN(Literal, lit) | |
| 3216 } | |
| 3217 | |
| 3218 Literal* NewUndefinedLiteral(int pos) { | |
| 3219 Literal* lit = | |
| 3220 new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); | |
| 3221 VISIT_AND_RETURN(Literal, lit) | |
| 3222 } | |
| 3223 | |
| 3224 Literal* NewTheHoleLiteral(int pos) { | |
| 3225 Literal* lit = | |
| 3226 new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); | |
| 3227 VISIT_AND_RETURN(Literal, lit) | |
| 3228 } | 3157 } |
| 3229 | 3158 |
| 3230 ObjectLiteral* NewObjectLiteral( | 3159 ObjectLiteral* NewObjectLiteral( |
| 3231 ZoneList<ObjectLiteral::Property*>* properties, | 3160 ZoneList<ObjectLiteral::Property*>* properties, |
| 3232 int literal_index, | 3161 int literal_index, |
| 3233 int boilerplate_properties, | 3162 int boilerplate_properties, |
| 3234 bool has_function, | 3163 bool has_function, |
| 3235 int pos) { | 3164 int pos) { |
| 3236 ObjectLiteral* lit = new(zone_) ObjectLiteral( | 3165 ObjectLiteral* lit = new(zone_) ObjectLiteral( |
| 3237 zone_, properties, literal_index, boilerplate_properties, | 3166 zone_, properties, literal_index, boilerplate_properties, |
| 3238 has_function, pos); | 3167 has_function, pos); |
| 3239 VISIT_AND_RETURN(ObjectLiteral, lit) | 3168 VISIT_AND_RETURN(ObjectLiteral, lit) |
| 3240 } | 3169 } |
| 3241 | 3170 |
| 3242 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, | 3171 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, |
| 3243 Expression* value) { | 3172 Expression* value) { |
| 3244 return new (zone_) | 3173 return new(zone_) ObjectLiteral::Property(zone_, key, value); |
| 3245 ObjectLiteral::Property(zone_, ast_value_factory_, key, value); | |
| 3246 } | 3174 } |
| 3247 | 3175 |
| 3248 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, | 3176 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, |
| 3249 FunctionLiteral* value, | 3177 FunctionLiteral* value, |
| 3250 int pos) { | 3178 int pos) { |
| 3251 ObjectLiteral::Property* prop = | 3179 ObjectLiteral::Property* prop = |
| 3252 new(zone_) ObjectLiteral::Property(zone_, is_getter, value); | 3180 new(zone_) ObjectLiteral::Property(zone_, is_getter, value); |
| 3253 prop->set_key(NewStringLiteral(value->raw_name(), pos)); | 3181 prop->set_key(NewLiteral(value->name(), pos)); |
| 3254 return prop; // Not an AST node, will not be visited. | 3182 return prop; // Not an AST node, will not be visited. |
| 3255 } | 3183 } |
| 3256 | 3184 |
| 3257 RegExpLiteral* NewRegExpLiteral(const AstString* pattern, | 3185 RegExpLiteral* NewRegExpLiteral(Handle<String> pattern, |
| 3258 const AstString* flags, | 3186 Handle<String> flags, |
| 3259 int literal_index, | 3187 int literal_index, |
| 3260 int pos) { | 3188 int pos) { |
| 3261 RegExpLiteral* lit = | 3189 RegExpLiteral* lit = |
| 3262 new(zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); | 3190 new(zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); |
| 3263 VISIT_AND_RETURN(RegExpLiteral, lit); | 3191 VISIT_AND_RETURN(RegExpLiteral, lit); |
| 3264 } | 3192 } |
| 3265 | 3193 |
| 3266 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3194 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
| 3267 int literal_index, | 3195 int literal_index, |
| 3268 int pos) { | 3196 int pos) { |
| 3269 ArrayLiteral* lit = new(zone_) ArrayLiteral( | 3197 ArrayLiteral* lit = new(zone_) ArrayLiteral( |
| 3270 zone_, values, literal_index, pos); | 3198 zone_, values, literal_index, pos); |
| 3271 VISIT_AND_RETURN(ArrayLiteral, lit) | 3199 VISIT_AND_RETURN(ArrayLiteral, lit) |
| 3272 } | 3200 } |
| 3273 | 3201 |
| 3274 VariableProxy* NewVariableProxy(Variable* var, | 3202 VariableProxy* NewVariableProxy(Variable* var, |
| 3275 int pos = RelocInfo::kNoPosition) { | 3203 int pos = RelocInfo::kNoPosition) { |
| 3276 VariableProxy* proxy = new(zone_) VariableProxy(zone_, var, pos); | 3204 VariableProxy* proxy = new(zone_) VariableProxy(zone_, var, pos); |
| 3277 VISIT_AND_RETURN(VariableProxy, proxy) | 3205 VISIT_AND_RETURN(VariableProxy, proxy) |
| 3278 } | 3206 } |
| 3279 | 3207 |
| 3280 VariableProxy* NewVariableProxy(const AstString* name, | 3208 VariableProxy* NewVariableProxy(Handle<String> name, |
| 3281 bool is_this, | 3209 bool is_this, |
| 3282 Interface* interface = Interface::NewValue(), | 3210 Interface* interface = Interface::NewValue(), |
| 3283 int position = RelocInfo::kNoPosition) { | 3211 int position = RelocInfo::kNoPosition) { |
| 3284 VariableProxy* proxy = | 3212 VariableProxy* proxy = |
| 3285 new(zone_) VariableProxy(zone_, name, is_this, interface, position); | 3213 new(zone_) VariableProxy(zone_, name, is_this, interface, position); |
| 3286 VISIT_AND_RETURN(VariableProxy, proxy) | 3214 VISIT_AND_RETURN(VariableProxy, proxy) |
| 3287 } | 3215 } |
| 3288 | 3216 |
| 3289 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3217 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
| 3290 Property* prop = new(zone_) Property(zone_, obj, key, pos); | 3218 Property* prop = new(zone_) Property(zone_, obj, key, pos); |
| 3291 VISIT_AND_RETURN(Property, prop) | 3219 VISIT_AND_RETURN(Property, prop) |
| 3292 } | 3220 } |
| 3293 | 3221 |
| 3294 Call* NewCall(Expression* expression, | 3222 Call* NewCall(Expression* expression, |
| 3295 ZoneList<Expression*>* arguments, | 3223 ZoneList<Expression*>* arguments, |
| 3296 int pos) { | 3224 int pos) { |
| 3297 Call* call = new(zone_) Call(zone_, expression, arguments, pos); | 3225 Call* call = new(zone_) Call(zone_, expression, arguments, pos); |
| 3298 VISIT_AND_RETURN(Call, call) | 3226 VISIT_AND_RETURN(Call, call) |
| 3299 } | 3227 } |
| 3300 | 3228 |
| 3301 CallNew* NewCallNew(Expression* expression, | 3229 CallNew* NewCallNew(Expression* expression, |
| 3302 ZoneList<Expression*>* arguments, | 3230 ZoneList<Expression*>* arguments, |
| 3303 int pos) { | 3231 int pos) { |
| 3304 CallNew* call = new(zone_) CallNew(zone_, expression, arguments, pos); | 3232 CallNew* call = new(zone_) CallNew(zone_, expression, arguments, pos); |
| 3305 VISIT_AND_RETURN(CallNew, call) | 3233 VISIT_AND_RETURN(CallNew, call) |
| 3306 } | 3234 } |
| 3307 | 3235 |
| 3308 CallRuntime* NewCallRuntime(const AstString* name, | 3236 CallRuntime* NewCallRuntime(Handle<String> name, |
| 3309 const Runtime::Function* function, | 3237 const Runtime::Function* function, |
| 3310 ZoneList<Expression*>* arguments, | 3238 ZoneList<Expression*>* arguments, |
| 3311 int pos) { | 3239 int pos) { |
| 3312 CallRuntime* call = | 3240 CallRuntime* call = |
| 3313 new(zone_) CallRuntime(zone_, name, function, arguments, pos); | 3241 new(zone_) CallRuntime(zone_, name, function, arguments, pos); |
| 3314 VISIT_AND_RETURN(CallRuntime, call) | 3242 VISIT_AND_RETURN(CallRuntime, call) |
| 3315 } | 3243 } |
| 3316 | 3244 |
| 3317 UnaryOperation* NewUnaryOperation(Token::Value op, | 3245 UnaryOperation* NewUnaryOperation(Token::Value op, |
| 3318 Expression* expression, | 3246 Expression* expression, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3376 zone_, generator_object, expression, yield_kind, pos); | 3304 zone_, generator_object, expression, yield_kind, pos); |
| 3377 VISIT_AND_RETURN(Yield, yield) | 3305 VISIT_AND_RETURN(Yield, yield) |
| 3378 } | 3306 } |
| 3379 | 3307 |
| 3380 Throw* NewThrow(Expression* exception, int pos) { | 3308 Throw* NewThrow(Expression* exception, int pos) { |
| 3381 Throw* t = new(zone_) Throw(zone_, exception, pos); | 3309 Throw* t = new(zone_) Throw(zone_, exception, pos); |
| 3382 VISIT_AND_RETURN(Throw, t) | 3310 VISIT_AND_RETURN(Throw, t) |
| 3383 } | 3311 } |
| 3384 | 3312 |
| 3385 FunctionLiteral* NewFunctionLiteral( | 3313 FunctionLiteral* NewFunctionLiteral( |
| 3386 const AstString* name, | 3314 Handle<String> name, |
| 3387 AstValueFactory* ast_value_factory, | |
| 3388 Scope* scope, | 3315 Scope* scope, |
| 3389 ZoneList<Statement*>* body, | 3316 ZoneList<Statement*>* body, |
| 3390 int materialized_literal_count, | 3317 int materialized_literal_count, |
| 3391 int expected_property_count, | 3318 int expected_property_count, |
| 3392 int handler_count, | 3319 int handler_count, |
| 3393 int parameter_count, | 3320 int parameter_count, |
| 3394 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3321 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 3395 FunctionLiteral::FunctionType function_type, | 3322 FunctionLiteral::FunctionType function_type, |
| 3396 FunctionLiteral::IsFunctionFlag is_function, | 3323 FunctionLiteral::IsFunctionFlag is_function, |
| 3397 FunctionLiteral::IsParenthesizedFlag is_parenthesized, | 3324 FunctionLiteral::IsParenthesizedFlag is_parenthesized, |
| 3398 FunctionLiteral::IsGeneratorFlag is_generator, | 3325 FunctionLiteral::IsGeneratorFlag is_generator, |
| 3399 int position) { | 3326 int position) { |
| 3400 FunctionLiteral* lit = new(zone_) FunctionLiteral( | 3327 FunctionLiteral* lit = new(zone_) FunctionLiteral( |
| 3401 zone_, name, ast_value_factory, scope, body, | 3328 zone_, name, scope, body, |
| 3402 materialized_literal_count, expected_property_count, handler_count, | 3329 materialized_literal_count, expected_property_count, handler_count, |
| 3403 parameter_count, function_type, has_duplicate_parameters, is_function, | 3330 parameter_count, function_type, has_duplicate_parameters, is_function, |
| 3404 is_parenthesized, is_generator, position); | 3331 is_parenthesized, is_generator, position); |
| 3405 // Top-level literal doesn't count for the AST's properties. | 3332 // Top-level literal doesn't count for the AST's properties. |
| 3406 if (is_function == FunctionLiteral::kIsFunction) { | 3333 if (is_function == FunctionLiteral::kIsFunction) { |
| 3407 visitor_.VisitFunctionLiteral(lit); | 3334 visitor_.VisitFunctionLiteral(lit); |
| 3408 } | 3335 } |
| 3409 return lit; | 3336 return lit; |
| 3410 } | 3337 } |
| 3411 | 3338 |
| 3412 NativeFunctionLiteral* NewNativeFunctionLiteral( | 3339 NativeFunctionLiteral* NewNativeFunctionLiteral( |
| 3413 const AstString* name, v8::Extension* extension, | 3340 Handle<String> name, v8::Extension* extension, int pos) { |
| 3414 int pos) { | |
| 3415 NativeFunctionLiteral* lit = | 3341 NativeFunctionLiteral* lit = |
| 3416 new(zone_) NativeFunctionLiteral(zone_, name, extension, pos); | 3342 new(zone_) NativeFunctionLiteral(zone_, name, extension, pos); |
| 3417 VISIT_AND_RETURN(NativeFunctionLiteral, lit) | 3343 VISIT_AND_RETURN(NativeFunctionLiteral, lit) |
| 3418 } | 3344 } |
| 3419 | 3345 |
| 3420 ThisFunction* NewThisFunction(int pos) { | 3346 ThisFunction* NewThisFunction(int pos) { |
| 3421 ThisFunction* fun = new(zone_) ThisFunction(zone_, pos); | 3347 ThisFunction* fun = new(zone_) ThisFunction(zone_, pos); |
| 3422 VISIT_AND_RETURN(ThisFunction, fun) | 3348 VISIT_AND_RETURN(ThisFunction, fun) |
| 3423 } | 3349 } |
| 3424 | 3350 |
| 3425 #undef VISIT_AND_RETURN | 3351 #undef VISIT_AND_RETURN |
| 3426 | 3352 |
| 3427 private: | 3353 private: |
| 3428 Zone* zone_; | 3354 Zone* zone_; |
| 3429 Visitor visitor_; | 3355 Visitor visitor_; |
| 3430 AstValueFactory* ast_value_factory_; | |
| 3431 }; | 3356 }; |
| 3432 | 3357 |
| 3433 | 3358 |
| 3434 } } // namespace v8::internal | 3359 } } // namespace v8::internal |
| 3435 | 3360 |
| 3436 #endif // V8_AST_H_ | 3361 #endif // V8_AST_H_ |
| OLD | NEW |