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

Side by Side Diff: src/ast.h

Issue 1889: Remove some of the state-dependent behavior from the code generator.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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-arm.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
143 class Expression: public Node { 145 class Expression: public Node {
144 public: 146 public:
145 virtual Expression* AsExpression() { return this; } 147 virtual Expression* AsExpression() { return this; }
146 148
147 virtual bool IsValidLeftHandSide() { return false; } 149 virtual bool IsValidLeftHandSide() { return false; }
148 150
149 // Mark the expression as being compiled as an expression 151 // Mark the expression as being compiled as an expression
150 // statement. This is used to transform postfix increments to 152 // statement. This is used to transform postfix increments to
151 // (faster) prefix increments. 153 // (faster) prefix increments.
152 virtual void MarkAsStatement() { /* do nothing */ } 154 virtual void MarkAsStatement() { /* do nothing */ }
155
156 // Generate code to store into an expression evaluated as the left-hand
157 // side of an assignment. The code will expect the stored value on top of
158 // the expression stack, and a reference containing the expression
159 // immediately below that. This function is overridden for expression
160 // types that can be stored into.
161 virtual void GenerateStoreCode(MacroAssembler* masm,
162 Scope* scope,
163 Reference* ref,
164 bool is_const_init) {
iposva 2008/09/10 18:01:44 Can you please use an enum for the is_const_init t
Kevin Millikin (Chromium) 2008/09/11 07:15:55 Done. InitState with values CONST_INIT and NOT_CO
165 UNREACHABLE();
166 }
153 }; 167 };
154 168
155 169
156 /** 170 /**
157 * A sentinel used during pre parsing that represents some expression 171 * A sentinel used during pre parsing that represents some expression
158 * that is a valid left hand side without having to actually build 172 * that is a valid left hand side without having to actually build
159 * the expression. 173 * the expression.
160 */ 174 */
161 class ValidLeftHandSideSentinel: public Expression { 175 class ValidLeftHandSideSentinel: public Expression {
162 public: 176 public:
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 Handle<String> name() const { return name_; } 760 Handle<String> name() const { return name_; }
747 Variable* var() const { return var_; } 761 Variable* var() const { return var_; }
748 UseCount* var_uses() { return &var_uses_; } 762 UseCount* var_uses() { return &var_uses_; }
749 UseCount* obj_uses() { return &obj_uses_; } 763 UseCount* obj_uses() { return &obj_uses_; }
750 bool is_this() const { return is_this_; } 764 bool is_this() const { return is_this_; }
751 bool inside_with() const { return inside_with_; } 765 bool inside_with() const { return inside_with_; }
752 766
753 // Bind this proxy to the variable var. 767 // Bind this proxy to the variable var.
754 void BindTo(Variable* var); 768 void BindTo(Variable* var);
755 769
770 // Generate code to store into an expression evaluated as the left-hand
771 // side of an assignment. The code will expect the stored value on top of
772 // the expression stack, and a reference containing the expression
773 // immediately below that.
774 virtual void GenerateStoreCode(MacroAssembler* masm,
775 Scope* scope,
776 Reference* ref,
777 bool is_const_init);
756 protected: 778 protected:
757 Handle<String> name_; 779 Handle<String> name_;
758 Variable* var_; // resolved variable, or NULL 780 Variable* var_; // resolved variable, or NULL
759 bool is_this_; 781 bool is_this_;
760 bool inside_with_; 782 bool inside_with_;
761 783
762 // VariableProxy usage info. 784 // VariableProxy usage info.
763 UseCount var_uses_; // uses of the variable value 785 UseCount var_uses_; // uses of the variable value
764 UseCount obj_uses_; // uses of the object the variable points to 786 UseCount obj_uses_; // uses of the object the variable points to
765 787
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 virtual void Accept(Visitor* v); 843 virtual void Accept(Visitor* v);
822 844
823 // Type testing & conversion 845 // Type testing & conversion
824 virtual Slot* AsSlot() { return this; } 846 virtual Slot* AsSlot() { return this; }
825 847
826 // Accessors 848 // Accessors
827 Variable* var() const { return var_; } 849 Variable* var() const { return var_; }
828 Type type() const { return type_; } 850 Type type() const { return type_; }
829 int index() const { return index_; } 851 int index() const { return index_; }
830 852
853 // Generate code to store into an expression evaluated as the left-hand
854 // side of an assignment. The code will expect the stored value on top of
855 // the expression stack, and a reference containing the expression
856 // immediately below that.
857 virtual void GenerateStoreCode(MacroAssembler* masm,
858 Scope* scope,
859 Reference* ref,
860 bool is_const_init);
831 private: 861 private:
832 Variable* var_; 862 Variable* var_;
833 Type type_; 863 Type type_;
834 int index_; 864 int index_;
835 }; 865 };
836 866
837 867
838 class Property: public Expression { 868 class Property: public Expression {
839 public: 869 public:
840 Property(Expression* obj, Expression* key, int pos) 870 Property(Expression* obj, Expression* key, int pos)
841 : obj_(obj), key_(key), pos_(pos) { } 871 : obj_(obj), key_(key), pos_(pos) { }
842 872
843 virtual void Accept(Visitor* v); 873 virtual void Accept(Visitor* v);
844 874
845 // Type testing & conversion 875 // Type testing & conversion
846 virtual Property* AsProperty() { return this; } 876 virtual Property* AsProperty() { return this; }
847 877
848 virtual bool IsValidLeftHandSide() { return true; } 878 virtual bool IsValidLeftHandSide() { return true; }
849 879
850 Expression* obj() const { return obj_; } 880 Expression* obj() const { return obj_; }
851 Expression* key() const { return key_; } 881 Expression* key() const { return key_; }
852 int position() const { return pos_; } 882 int position() const { return pos_; }
853 883
854 // Returns a property singleton property access on 'this'. Used 884 // Returns a property singleton property access on 'this'. Used
855 // during preparsing. 885 // during preparsing.
856 static Property* this_property() { return &this_property_; } 886 static Property* this_property() { return &this_property_; }
857 887
888 // Generate code to store into an expression evaluated as the left-hand
889 // side of an assignment. The code will expect the stored value on top of
890 // the expression stack, and a reference containing the expression
891 // immediately below that.
892 virtual void GenerateStoreCode(MacroAssembler* masm,
893 Scope* scope,
894 Reference* ref,
895 bool is_const_init);
858 private: 896 private:
859 Expression* obj_; 897 Expression* obj_;
860 Expression* key_; 898 Expression* key_;
861 int pos_; 899 int pos_;
862 900
863 // Dummy property used during preparsing 901 // Dummy property used during preparsing
864 static Property this_property_; 902 static Property this_property_;
865 }; 903 };
866 904
867 905
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 #undef DEF_VISIT 1265 #undef DEF_VISIT
1228 1266
1229 private: 1267 private:
1230 bool stack_overflow_; 1268 bool stack_overflow_;
1231 }; 1269 };
1232 1270
1233 1271
1234 } } // namespace v8::internal 1272 } } // namespace v8::internal
1235 1273
1236 #endif // V8_AST_H_ 1274 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/codegen-arm.cc » ('j') | src/codegen-arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698