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

Side by Side Diff: src/ast.h

Issue 6527: Move code generation for storing to a reference out of the AST nodes, and... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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/codegen-arm.cc » ('j') | src/codegen-ia32.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 class Statement: public Node { 134 class Statement: public Node {
135 public: 135 public:
136 virtual Statement* AsStatement() { return this; } 136 virtual Statement* AsStatement() { return this; }
137 virtual ReturnStatement* AsReturnStatement() { return NULL; } 137 virtual ReturnStatement* AsReturnStatement() { return NULL; }
138 138
139 bool IsEmpty() { return AsEmptyStatement() != NULL; } 139 bool IsEmpty() { return AsEmptyStatement() != NULL; }
140 }; 140 };
141 141
142 142
143 class Reference;
144 enum InitState { CONST_INIT, NOT_CONST_INIT };
145
146 class Expression: public Node { 143 class Expression: public Node {
147 public: 144 public:
148 virtual Expression* AsExpression() { return this; } 145 virtual Expression* AsExpression() { return this; }
149 146
150 virtual bool IsValidLeftHandSide() { return false; } 147 virtual bool IsValidLeftHandSide() { return false; }
151 148
152 // Mark the expression as being compiled as an expression 149 // Mark the expression as being compiled as an expression
153 // statement. This is used to transform postfix increments to 150 // statement. This is used to transform postfix increments to
154 // (faster) prefix increments. 151 // (faster) prefix increments.
155 virtual void MarkAsStatement() { /* do nothing */ } 152 virtual void MarkAsStatement() { /* do nothing */ }
156
157 // Generate code to store into an expression evaluated as the left-hand
158 // side of an assignment. The code will expect the stored value on top of
159 // the expression stack, and a reference containing the expression
160 // immediately below that. This function is overridden for expression
161 // types that can be stored into.
162 virtual void GenerateStoreCode(CodeGenerator* cgen,
163 Reference* ref,
164 InitState init_state) {
165 UNREACHABLE();
166 }
167 }; 153 };
168 154
169 155
170 /** 156 /**
171 * A sentinel used during pre parsing that represents some expression 157 * A sentinel used during pre parsing that represents some expression
172 * that is a valid left hand side without having to actually build 158 * that is a valid left hand side without having to actually build
173 * the expression. 159 * the expression.
174 */ 160 */
175 class ValidLeftHandSideSentinel: public Expression { 161 class ValidLeftHandSideSentinel: public Expression {
176 public: 162 public:
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 Handle<String> name() const { return name_; } 737 Handle<String> name() const { return name_; }
752 Variable* var() const { return var_; } 738 Variable* var() const { return var_; }
753 UseCount* var_uses() { return &var_uses_; } 739 UseCount* var_uses() { return &var_uses_; }
754 UseCount* obj_uses() { return &obj_uses_; } 740 UseCount* obj_uses() { return &obj_uses_; }
755 bool is_this() const { return is_this_; } 741 bool is_this() const { return is_this_; }
756 bool inside_with() const { return inside_with_; } 742 bool inside_with() const { return inside_with_; }
757 743
758 // Bind this proxy to the variable var. 744 // Bind this proxy to the variable var.
759 void BindTo(Variable* var); 745 void BindTo(Variable* var);
760 746
761 // Generate code to store into an expression evaluated as the left-hand
762 // side of an assignment. The code will expect the stored value on top of
763 // the expression stack, and a reference containing the expression
764 // immediately below that.
765 virtual void GenerateStoreCode(CodeGenerator* cgen,
766 Reference* ref,
767 InitState init_state);
768 protected: 747 protected:
769 Handle<String> name_; 748 Handle<String> name_;
770 Variable* var_; // resolved variable, or NULL 749 Variable* var_; // resolved variable, or NULL
771 bool is_this_; 750 bool is_this_;
772 bool inside_with_; 751 bool inside_with_;
773 752
774 // VariableProxy usage info. 753 // VariableProxy usage info.
775 UseCount var_uses_; // uses of the variable value 754 UseCount var_uses_; // uses of the variable value
776 UseCount obj_uses_; // uses of the object the variable points to 755 UseCount obj_uses_; // uses of the object the variable points to
777 756
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 virtual void Accept(Visitor* v); 812 virtual void Accept(Visitor* v);
834 813
835 // Type testing & conversion 814 // Type testing & conversion
836 virtual Slot* AsSlot() { return this; } 815 virtual Slot* AsSlot() { return this; }
837 816
838 // Accessors 817 // Accessors
839 Variable* var() const { return var_; } 818 Variable* var() const { return var_; }
840 Type type() const { return type_; } 819 Type type() const { return type_; }
841 int index() const { return index_; } 820 int index() const { return index_; }
842 821
843 // Generate code to store into an expression evaluated as the left-hand
844 // side of an assignment. The code will expect the stored value on top of
845 // the expression stack, and a reference containing the expression
846 // immediately below that.
847 virtual void GenerateStoreCode(CodeGenerator* cgen,
848 Reference* ref,
849 InitState init_state);
850 private: 822 private:
851 Variable* var_; 823 Variable* var_;
852 Type type_; 824 Type type_;
853 int index_; 825 int index_;
854 }; 826 };
855 827
856 828
857 class Property: public Expression { 829 class Property: public Expression {
858 public: 830 public:
859 Property(Expression* obj, Expression* key, int pos) 831 Property(Expression* obj, Expression* key, int pos)
860 : obj_(obj), key_(key), pos_(pos) { } 832 : obj_(obj), key_(key), pos_(pos) { }
861 833
862 virtual void Accept(Visitor* v); 834 virtual void Accept(Visitor* v);
863 835
864 // Type testing & conversion 836 // Type testing & conversion
865 virtual Property* AsProperty() { return this; } 837 virtual Property* AsProperty() { return this; }
866 838
867 virtual bool IsValidLeftHandSide() { return true; } 839 virtual bool IsValidLeftHandSide() { return true; }
868 840
869 Expression* obj() const { return obj_; } 841 Expression* obj() const { return obj_; }
870 Expression* key() const { return key_; } 842 Expression* key() const { return key_; }
871 int position() const { return pos_; } 843 int position() const { return pos_; }
872 844
873 // Returns a property singleton property access on 'this'. Used 845 // Returns a property singleton property access on 'this'. Used
874 // during preparsing. 846 // during preparsing.
875 static Property* this_property() { return &this_property_; } 847 static Property* this_property() { return &this_property_; }
876 848
877 // Generate code to store into an expression evaluated as the left-hand
878 // side of an assignment. The code will expect the stored value on top of
879 // the expression stack, and a reference containing the expression
880 // immediately below that.
881 virtual void GenerateStoreCode(CodeGenerator* cgen,
882 Reference* ref,
883 InitState init_state);
884 private: 849 private:
885 Expression* obj_; 850 Expression* obj_;
886 Expression* key_; 851 Expression* key_;
887 int pos_; 852 int pos_;
888 853
889 // Dummy property used during preparsing 854 // Dummy property used during preparsing
890 static Property this_property_; 855 static Property this_property_;
891 }; 856 };
892 857
893 858
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 #undef DEF_VISIT 1218 #undef DEF_VISIT
1254 1219
1255 private: 1220 private:
1256 bool stack_overflow_; 1221 bool stack_overflow_;
1257 }; 1222 };
1258 1223
1259 1224
1260 } } // namespace v8::internal 1225 } } // namespace v8::internal
1261 1226
1262 #endif // V8_AST_H_ 1227 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/codegen-arm.cc » ('j') | src/codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698