Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: src/ast.h

Issue 7134014: Stop using with explicitly to implement try/catch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 #define EXPRESSION_NODE_LIST(V) \ 74 #define EXPRESSION_NODE_LIST(V) \
75 V(FunctionLiteral) \ 75 V(FunctionLiteral) \
76 V(SharedFunctionInfoLiteral) \ 76 V(SharedFunctionInfoLiteral) \
77 V(Conditional) \ 77 V(Conditional) \
78 V(VariableProxy) \ 78 V(VariableProxy) \
79 V(Literal) \ 79 V(Literal) \
80 V(RegExpLiteral) \ 80 V(RegExpLiteral) \
81 V(ObjectLiteral) \ 81 V(ObjectLiteral) \
82 V(ArrayLiteral) \ 82 V(ArrayLiteral) \
83 V(CatchExtensionObject) \
84 V(Assignment) \ 83 V(Assignment) \
85 V(Throw) \ 84 V(Throw) \
86 V(Property) \ 85 V(Property) \
87 V(Call) \ 86 V(Call) \
88 V(CallNew) \ 87 V(CallNew) \
89 V(CallRuntime) \ 88 V(CallRuntime) \
90 V(UnaryOperation) \ 89 V(UnaryOperation) \
91 V(CountOperation) \ 90 V(CountOperation) \
92 V(BinaryOperation) \ 91 V(BinaryOperation) \
93 V(CompareOperation) \ 92 V(CompareOperation) \
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 Expression* expression() const { return expression_; } 606 Expression* expression() const { return expression_; }
608 virtual bool IsInlineable() const; 607 virtual bool IsInlineable() const;
609 608
610 private: 609 private:
611 Expression* expression_; 610 Expression* expression_;
612 }; 611 };
613 612
614 613
615 class WithEnterStatement: public Statement { 614 class WithEnterStatement: public Statement {
616 public: 615 public:
617 explicit WithEnterStatement(Expression* expression, bool is_catch_block) 616 explicit WithEnterStatement(Expression* expression)
618 : expression_(expression), is_catch_block_(is_catch_block) { } 617 : expression_(expression) { }
619 618
620 DECLARE_NODE_TYPE(WithEnterStatement) 619 DECLARE_NODE_TYPE(WithEnterStatement)
621 620
622 Expression* expression() const { return expression_; } 621 Expression* expression() const { return expression_; }
623 622
624 bool is_catch_block() const { return is_catch_block_; }
625 virtual bool IsInlineable() const; 623 virtual bool IsInlineable() const;
626 624
627 private: 625 private:
628 Expression* expression_; 626 Expression* expression_;
629 bool is_catch_block_;
630 }; 627 };
631 628
632 629
633 class WithExitStatement: public Statement { 630 class WithExitStatement: public Statement {
634 public: 631 public:
635 WithExitStatement() { } 632 WithExitStatement() { }
636 633
637 virtual bool IsInlineable() const; 634 virtual bool IsInlineable() const;
638 635
639 DECLARE_NODE_TYPE(WithExitStatement) 636 DECLARE_NODE_TYPE(WithExitStatement)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 int if_id_; 733 int if_id_;
737 int then_id_; 734 int then_id_;
738 int else_id_; 735 int else_id_;
739 }; 736 };
740 737
741 738
742 // NOTE: TargetCollectors are represented as nodes to fit in the target 739 // NOTE: TargetCollectors are represented as nodes to fit in the target
743 // stack in the compiler; this should probably be reworked. 740 // stack in the compiler; this should probably be reworked.
744 class TargetCollector: public AstNode { 741 class TargetCollector: public AstNode {
745 public: 742 public:
746 explicit TargetCollector(ZoneList<Label*>* targets) 743 TargetCollector(): targets_(0) { }
747 : targets_(targets) {
748 }
749 744
750 // Adds a jump target to the collector. The collector stores a pointer not 745 // Adds a jump target to the collector. The collector stores a pointer not
751 // a copy of the target to make binding work, so make sure not to pass in 746 // a copy of the target to make binding work, so make sure not to pass in
752 // references to something on the stack. 747 // references to something on the stack.
753 void AddTarget(Label* target); 748 void AddTarget(Label* target);
754 749
755 // Virtual behaviour. TargetCollectors are never part of the AST. 750 // Virtual behaviour. TargetCollectors are never part of the AST.
756 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } 751 virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
757 virtual TargetCollector* AsTargetCollector() { return this; } 752 virtual TargetCollector* AsTargetCollector() { return this; }
758 753
759 ZoneList<Label*>* targets() { return targets_; } 754 ZoneList<Label*>* targets() { return &targets_; }
760 virtual bool IsInlineable() const; 755 virtual bool IsInlineable() const;
761 756
762 private: 757 private:
763 ZoneList<Label*>* targets_; 758 ZoneList<Label*> targets_;
764 }; 759 };
765 760
766 761
767 class TryStatement: public Statement { 762 class TryStatement: public Statement {
768 public: 763 public:
769 explicit TryStatement(Block* try_block) 764 explicit TryStatement(Block* try_block)
770 : try_block_(try_block), escaping_targets_(NULL) { } 765 : try_block_(try_block), escaping_targets_(NULL) { }
771 766
772 void set_escaping_targets(ZoneList<Label*>* targets) { 767 void set_escaping_targets(ZoneList<Label*>* targets) {
773 escaping_targets_ = targets; 768 escaping_targets_ = targets;
774 } 769 }
775 770
776 Block* try_block() const { return try_block_; } 771 Block* try_block() const { return try_block_; }
777 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } 772 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; }
778 virtual bool IsInlineable() const; 773 virtual bool IsInlineable() const;
779 774
780 private: 775 private:
781 Block* try_block_; 776 Block* try_block_;
782 ZoneList<Label*>* escaping_targets_; 777 ZoneList<Label*>* escaping_targets_;
783 }; 778 };
784 779
785 780
786 class TryCatchStatement: public TryStatement { 781 class TryCatchStatement: public TryStatement {
787 public: 782 public:
788 TryCatchStatement(Block* try_block, 783 TryCatchStatement(Block* try_block, Handle<String> name, Block* catch_block)
789 VariableProxy* catch_var,
790 Block* catch_block)
791 : TryStatement(try_block), 784 : TryStatement(try_block),
792 catch_var_(catch_var), 785 name_(name),
793 catch_block_(catch_block) { 786 catch_block_(catch_block) {
794 } 787 }
795 788
796 DECLARE_NODE_TYPE(TryCatchStatement) 789 DECLARE_NODE_TYPE(TryCatchStatement)
797 790
798 VariableProxy* catch_var() const { return catch_var_; }
799 Block* catch_block() const { return catch_block_; } 791 Block* catch_block() const { return catch_block_; }
792 Handle<String> name() const { return name_; }
800 virtual bool IsInlineable() const; 793 virtual bool IsInlineable() const;
801 794
802 private: 795 private:
803 VariableProxy* catch_var_; 796 Handle<String> name_;
804 Block* catch_block_; 797 Block* catch_block_;
805 }; 798 };
806 799
807 800
808 class TryFinallyStatement: public TryStatement { 801 class TryFinallyStatement: public TryStatement {
809 public: 802 public:
810 TryFinallyStatement(Block* try_block, Block* finally_block) 803 TryFinallyStatement(Block* try_block, Block* finally_block)
811 : TryStatement(try_block), 804 : TryStatement(try_block),
812 finally_block_(finally_block) { } 805 finally_block_(finally_block) { }
813 806
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 // Return an AST id for an element that is used in simulate instructions. 1026 // Return an AST id for an element that is used in simulate instructions.
1034 int GetIdForElement(int i) { return first_element_id_ + i; } 1027 int GetIdForElement(int i) { return first_element_id_ + i; }
1035 1028
1036 private: 1029 private:
1037 Handle<FixedArray> constant_elements_; 1030 Handle<FixedArray> constant_elements_;
1038 ZoneList<Expression*>* values_; 1031 ZoneList<Expression*>* values_;
1039 int first_element_id_; 1032 int first_element_id_;
1040 }; 1033 };
1041 1034
1042 1035
1043 // Node for constructing a context extension object for a catch block.
1044 // The catch context extension object has one property, the catch
1045 // variable, which should be DontDelete.
1046 class CatchExtensionObject: public Expression {
1047 public:
1048 CatchExtensionObject(Literal* key, VariableProxy* value)
1049 : key_(key), value_(value) {
1050 }
1051
1052 DECLARE_NODE_TYPE(CatchExtensionObject)
1053
1054 Literal* key() const { return key_; }
1055 VariableProxy* value() const { return value_; }
1056 virtual bool IsInlineable() const;
1057
1058 private:
1059 Literal* key_;
1060 VariableProxy* value_;
1061 };
1062
1063
1064 class VariableProxy: public Expression { 1036 class VariableProxy: public Expression {
1065 public: 1037 public:
1066 explicit VariableProxy(Variable* var); 1038 explicit VariableProxy(Variable* var);
1067 1039
1068 DECLARE_NODE_TYPE(VariableProxy) 1040 DECLARE_NODE_TYPE(VariableProxy)
1069 1041
1070 // Type testing & conversion 1042 // Type testing & conversion
1071 virtual Property* AsProperty() { 1043 virtual Property* AsProperty() {
1072 return var_ == NULL ? NULL : var_->AsProperty(); 1044 return var_ == NULL ? NULL : var_->AsProperty();
1073 } 1045 }
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 2152
2181 private: 2153 private:
2182 Isolate* isolate_; 2154 Isolate* isolate_;
2183 bool stack_overflow_; 2155 bool stack_overflow_;
2184 }; 2156 };
2185 2157
2186 2158
2187 } } // namespace v8::internal 2159 } } // namespace v8::internal
2188 2160
2189 #endif // V8_AST_H_ 2161 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698