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