| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 V(IfStatement) \ | 83 V(IfStatement) \ |
| 84 V(ContinueStatement) \ | 84 V(ContinueStatement) \ |
| 85 V(BreakStatement) \ | 85 V(BreakStatement) \ |
| 86 V(ReturnStatement) \ | 86 V(ReturnStatement) \ |
| 87 V(WithStatement) \ | 87 V(WithStatement) \ |
| 88 V(SwitchStatement) \ | 88 V(SwitchStatement) \ |
| 89 V(DoWhileStatement) \ | 89 V(DoWhileStatement) \ |
| 90 V(WhileStatement) \ | 90 V(WhileStatement) \ |
| 91 V(ForStatement) \ | 91 V(ForStatement) \ |
| 92 V(ForInStatement) \ | 92 V(ForInStatement) \ |
| 93 V(ForOfStatement) \ |
| 93 V(TryCatchStatement) \ | 94 V(TryCatchStatement) \ |
| 94 V(TryFinallyStatement) \ | 95 V(TryFinallyStatement) \ |
| 95 V(DebuggerStatement) | 96 V(DebuggerStatement) |
| 96 | 97 |
| 97 #define EXPRESSION_NODE_LIST(V) \ | 98 #define EXPRESSION_NODE_LIST(V) \ |
| 98 V(FunctionLiteral) \ | 99 V(FunctionLiteral) \ |
| 99 V(SharedFunctionInfoLiteral) \ | 100 V(SharedFunctionInfoLiteral) \ |
| 100 V(Conditional) \ | 101 V(Conditional) \ |
| 101 V(VariableProxy) \ | 102 V(VariableProxy) \ |
| 102 V(Literal) \ | 103 V(Literal) \ |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 | 868 |
| 868 // True if there is a function literal subexpression in the condition. | 869 // True if there is a function literal subexpression in the condition. |
| 869 bool may_have_function_literal_; | 870 bool may_have_function_literal_; |
| 870 Variable* loop_variable_; | 871 Variable* loop_variable_; |
| 871 | 872 |
| 872 const BailoutId continue_id_; | 873 const BailoutId continue_id_; |
| 873 const BailoutId body_id_; | 874 const BailoutId body_id_; |
| 874 }; | 875 }; |
| 875 | 876 |
| 876 | 877 |
| 877 class ForInStatement: public IterationStatement { | 878 class ForEachStatement: public IterationStatement { |
| 878 public: | 879 public: |
| 879 DECLARE_NODE_TYPE(ForInStatement) | 880 enum VisitMode { |
| 881 ENUMERATE, // for (each in subject) body; |
| 882 ITERATE // for (each of subject) body; |
| 883 }; |
| 880 | 884 |
| 881 void Initialize(Expression* each, Expression* enumerable, Statement* body) { | 885 void Initialize(Expression* each, Expression* subject, Statement* body) { |
| 882 IterationStatement::Initialize(body); | 886 IterationStatement::Initialize(body); |
| 883 each_ = each; | 887 each_ = each; |
| 884 enumerable_ = enumerable; | 888 subject_ = subject; |
| 885 for_in_type_ = SLOW_FOR_IN; | |
| 886 } | 889 } |
| 887 | 890 |
| 888 Expression* each() const { return each_; } | 891 Expression* each() const { return each_; } |
| 889 Expression* enumerable() const { return enumerable_; } | 892 Expression* subject() const { return subject_; } |
| 890 | 893 |
| 891 virtual BailoutId ContinueId() const { return EntryId(); } | 894 virtual BailoutId ContinueId() const { return EntryId(); } |
| 892 virtual BailoutId StackCheckId() const { return body_id_; } | 895 virtual BailoutId StackCheckId() const { return body_id_; } |
| 893 BailoutId BodyId() const { return body_id_; } | 896 BailoutId BodyId() const { return body_id_; } |
| 894 BailoutId PrepareId() const { return prepare_id_; } | 897 BailoutId PrepareId() const { return prepare_id_; } |
| 895 | 898 |
| 899 protected: |
| 900 ForEachStatement(Isolate* isolate, ZoneStringList* labels) |
| 901 : IterationStatement(isolate, labels), |
| 902 each_(NULL), |
| 903 subject_(NULL), |
| 904 body_id_(GetNextId(isolate)), |
| 905 prepare_id_(GetNextId(isolate)) { |
| 906 } |
| 907 |
| 908 private: |
| 909 Expression* each_; |
| 910 Expression* subject_; |
| 911 const BailoutId body_id_; |
| 912 const BailoutId prepare_id_; |
| 913 }; |
| 914 |
| 915 |
| 916 class ForInStatement: public ForEachStatement { |
| 917 public: |
| 918 DECLARE_NODE_TYPE(ForInStatement) |
| 919 |
| 920 Expression* enumerable() const { |
| 921 return subject(); |
| 922 } |
| 923 |
| 896 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } | 924 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } |
| 897 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 925 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 898 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 926 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 899 ForInType for_in_type() const { return for_in_type_; } | 927 ForInType for_in_type() const { return for_in_type_; } |
| 900 | 928 |
| 901 protected: | 929 protected: |
| 902 ForInStatement(Isolate* isolate, ZoneStringList* labels) | 930 ForInStatement(Isolate* isolate, ZoneStringList* labels) |
| 903 : IterationStatement(isolate, labels), | 931 : ForEachStatement(isolate, labels), |
| 904 each_(NULL), | 932 for_in_type_(SLOW_FOR_IN) { |
| 905 enumerable_(NULL), | |
| 906 body_id_(GetNextId(isolate)), | |
| 907 prepare_id_(GetNextId(isolate)) { | |
| 908 } | 933 } |
| 909 | 934 |
| 910 private: | |
| 911 Expression* each_; | |
| 912 Expression* enumerable_; | |
| 913 | |
| 914 ForInType for_in_type_; | 935 ForInType for_in_type_; |
| 915 | |
| 916 const BailoutId body_id_; | |
| 917 const BailoutId prepare_id_; | |
| 918 }; | 936 }; |
| 919 | 937 |
| 920 | 938 |
| 939 class ForOfStatement: public ForEachStatement { |
| 940 public: |
| 941 DECLARE_NODE_TYPE(ForOfStatement) |
| 942 |
| 943 Expression* iterable() const { |
| 944 return subject(); |
| 945 } |
| 946 |
| 947 protected: |
| 948 ForOfStatement(Isolate* isolate, ZoneStringList* labels) |
| 949 : ForEachStatement(isolate, labels) { |
| 950 } |
| 951 }; |
| 952 |
| 953 |
| 921 class ExpressionStatement: public Statement { | 954 class ExpressionStatement: public Statement { |
| 922 public: | 955 public: |
| 923 DECLARE_NODE_TYPE(ExpressionStatement) | 956 DECLARE_NODE_TYPE(ExpressionStatement) |
| 924 | 957 |
| 925 void set_expression(Expression* e) { expression_ = e; } | 958 void set_expression(Expression* e) { expression_ = e; } |
| 926 Expression* expression() const { return expression_; } | 959 Expression* expression() const { return expression_; } |
| 927 | 960 |
| 928 protected: | 961 protected: |
| 929 explicit ExpressionStatement(Expression* expression) | 962 explicit ExpressionStatement(Expression* expression) |
| 930 : expression_(expression) { } | 963 : expression_(expression) { } |
| (...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2846 } | 2879 } |
| 2847 | 2880 |
| 2848 #define STATEMENT_WITH_LABELS(NodeType) \ | 2881 #define STATEMENT_WITH_LABELS(NodeType) \ |
| 2849 NodeType* New##NodeType(ZoneStringList* labels) { \ | 2882 NodeType* New##NodeType(ZoneStringList* labels) { \ |
| 2850 NodeType* stmt = new(zone_) NodeType(isolate_, labels); \ | 2883 NodeType* stmt = new(zone_) NodeType(isolate_, labels); \ |
| 2851 VISIT_AND_RETURN(NodeType, stmt); \ | 2884 VISIT_AND_RETURN(NodeType, stmt); \ |
| 2852 } | 2885 } |
| 2853 STATEMENT_WITH_LABELS(DoWhileStatement) | 2886 STATEMENT_WITH_LABELS(DoWhileStatement) |
| 2854 STATEMENT_WITH_LABELS(WhileStatement) | 2887 STATEMENT_WITH_LABELS(WhileStatement) |
| 2855 STATEMENT_WITH_LABELS(ForStatement) | 2888 STATEMENT_WITH_LABELS(ForStatement) |
| 2856 STATEMENT_WITH_LABELS(ForInStatement) | |
| 2857 STATEMENT_WITH_LABELS(SwitchStatement) | 2889 STATEMENT_WITH_LABELS(SwitchStatement) |
| 2858 #undef STATEMENT_WITH_LABELS | 2890 #undef STATEMENT_WITH_LABELS |
| 2859 | 2891 |
| 2892 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, |
| 2893 ZoneStringList* labels) { |
| 2894 switch (visit_mode) { |
| 2895 case ForEachStatement::ENUMERATE: { |
| 2896 ForInStatement* stmt = new(zone_) ForInStatement(isolate_, labels); |
| 2897 VISIT_AND_RETURN(ForInStatement, stmt); |
| 2898 } |
| 2899 case ForEachStatement::ITERATE: { |
| 2900 ForOfStatement* stmt = new(zone_) ForOfStatement(isolate_, labels); |
| 2901 VISIT_AND_RETURN(ForOfStatement, stmt); |
| 2902 } |
| 2903 } |
| 2904 UNREACHABLE(); |
| 2905 return NULL; |
| 2906 } |
| 2907 |
| 2860 ModuleStatement* NewModuleStatement(VariableProxy* proxy, Block* body) { | 2908 ModuleStatement* NewModuleStatement(VariableProxy* proxy, Block* body) { |
| 2861 ModuleStatement* stmt = new(zone_) ModuleStatement(proxy, body); | 2909 ModuleStatement* stmt = new(zone_) ModuleStatement(proxy, body); |
| 2862 VISIT_AND_RETURN(ModuleStatement, stmt) | 2910 VISIT_AND_RETURN(ModuleStatement, stmt) |
| 2863 } | 2911 } |
| 2864 | 2912 |
| 2865 ExpressionStatement* NewExpressionStatement(Expression* expression) { | 2913 ExpressionStatement* NewExpressionStatement(Expression* expression) { |
| 2866 ExpressionStatement* stmt = new(zone_) ExpressionStatement(expression); | 2914 ExpressionStatement* stmt = new(zone_) ExpressionStatement(expression); |
| 2867 VISIT_AND_RETURN(ExpressionStatement, stmt) | 2915 VISIT_AND_RETURN(ExpressionStatement, stmt) |
| 2868 } | 2916 } |
| 2869 | 2917 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3128 private: | 3176 private: |
| 3129 Isolate* isolate_; | 3177 Isolate* isolate_; |
| 3130 Zone* zone_; | 3178 Zone* zone_; |
| 3131 Visitor visitor_; | 3179 Visitor visitor_; |
| 3132 }; | 3180 }; |
| 3133 | 3181 |
| 3134 | 3182 |
| 3135 } } // namespace v8::internal | 3183 } } // namespace v8::internal |
| 3136 | 3184 |
| 3137 #endif // V8_AST_H_ | 3185 #endif // V8_AST_H_ |
| OLD | NEW |