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_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 | 1169 |
1170 | 1170 |
1171 // Delegates to another statement, which may be overwritten. | 1171 // Delegates to another statement, which may be overwritten. |
1172 // This was introduced to implement ES2015 Annex B3.3 for conditionally making | 1172 // This was introduced to implement ES2015 Annex B3.3 for conditionally making |
1173 // sloppy-mode block-scoped functions have a var binding, which is changed | 1173 // sloppy-mode block-scoped functions have a var binding, which is changed |
1174 // from one statement to another during parsing. | 1174 // from one statement to another during parsing. |
1175 class SloppyBlockFunctionStatement final : public Statement { | 1175 class SloppyBlockFunctionStatement final : public Statement { |
1176 public: | 1176 public: |
1177 Statement* statement() const { return statement_; } | 1177 Statement* statement() const { return statement_; } |
1178 void set_statement(Statement* statement) { statement_ = statement; } | 1178 void set_statement(Statement* statement) { statement_ = statement; } |
| 1179 VariableProxy* from() const { return from_; } |
| 1180 void set_from(VariableProxy* from) { from_ = from; } |
| 1181 VariableProxy* to() const { return to_; } |
| 1182 void set_to(VariableProxy* to) { to_ = to; } |
1179 Scope* scope() const { return scope_; } | 1183 Scope* scope() const { return scope_; } |
1180 SloppyBlockFunctionStatement* next() { return next_; } | 1184 SloppyBlockFunctionStatement* next() { return next_; } |
1181 void set_next(SloppyBlockFunctionStatement* next) { next_ = next; } | 1185 void set_next(SloppyBlockFunctionStatement* next) { next_ = next; } |
1182 | 1186 |
1183 private: | 1187 private: |
1184 friend class AstNodeFactory; | 1188 friend class AstNodeFactory; |
1185 | 1189 |
1186 SloppyBlockFunctionStatement(Statement* statement, Scope* scope) | 1190 SloppyBlockFunctionStatement(Statement* statement, Scope* scope) |
1187 : Statement(kNoSourcePosition, kSloppyBlockFunctionStatement), | 1191 : Statement(kNoSourcePosition, kSloppyBlockFunctionStatement), |
1188 statement_(statement), | 1192 statement_(statement), |
| 1193 from_(nullptr), |
| 1194 to_(nullptr), |
1189 scope_(scope), | 1195 scope_(scope), |
1190 next_(nullptr) {} | 1196 next_(nullptr) {} |
1191 | 1197 |
1192 Statement* statement_; | 1198 Statement* statement_; |
| 1199 VariableProxy* from_; |
| 1200 VariableProxy* to_; |
1193 Scope* const scope_; | 1201 Scope* const scope_; |
1194 SloppyBlockFunctionStatement* next_; | 1202 SloppyBlockFunctionStatement* next_; |
1195 }; | 1203 }; |
1196 | 1204 |
1197 | 1205 |
1198 class Literal final : public Expression { | 1206 class Literal final : public Expression { |
1199 public: | 1207 public: |
1200 // Returns true if literal represents a property name (i.e. cannot be parsed | 1208 // Returns true if literal represents a property name (i.e. cannot be parsed |
1201 // as array indices). | 1209 // as array indices). |
1202 bool IsPropertyName() const { return value_->IsPropertyName(); } | 1210 bool IsPropertyName() const { return value_->IsPropertyName(); } |
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3117 } | 3125 } |
3118 | 3126 |
3119 DebuggerStatement* NewDebuggerStatement(int pos) { | 3127 DebuggerStatement* NewDebuggerStatement(int pos) { |
3120 return new (zone_) DebuggerStatement(pos); | 3128 return new (zone_) DebuggerStatement(pos); |
3121 } | 3129 } |
3122 | 3130 |
3123 EmptyStatement* NewEmptyStatement(int pos) { | 3131 EmptyStatement* NewEmptyStatement(int pos) { |
3124 return new (zone_) EmptyStatement(pos); | 3132 return new (zone_) EmptyStatement(pos); |
3125 } | 3133 } |
3126 | 3134 |
3127 SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement( | 3135 SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement(Scope* scope) { |
3128 Statement* statement, Scope* scope) { | 3136 return new (zone_) SloppyBlockFunctionStatement( |
3129 return new (zone_) SloppyBlockFunctionStatement(statement, scope); | 3137 NewEmptyStatement(kNoSourcePosition), scope); |
3130 } | 3138 } |
3131 | 3139 |
3132 CaseClause* NewCaseClause( | 3140 CaseClause* NewCaseClause( |
3133 Expression* label, ZoneList<Statement*>* statements, int pos) { | 3141 Expression* label, ZoneList<Statement*>* statements, int pos) { |
3134 return new (zone_) CaseClause(label, statements, pos); | 3142 return new (zone_) CaseClause(label, statements, pos); |
3135 } | 3143 } |
3136 | 3144 |
3137 Literal* NewStringLiteral(const AstRawString* string, int pos) { | 3145 Literal* NewStringLiteral(const AstRawString* string, int pos) { |
3138 return new (zone_) Literal(ast_value_factory_->NewString(string), pos); | 3146 return new (zone_) Literal(ast_value_factory_->NewString(string), pos); |
3139 } | 3147 } |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3464 : NULL; \ | 3472 : NULL; \ |
3465 } | 3473 } |
3466 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3474 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3467 #undef DECLARE_NODE_FUNCTIONS | 3475 #undef DECLARE_NODE_FUNCTIONS |
3468 | 3476 |
3469 | 3477 |
3470 } // namespace internal | 3478 } // namespace internal |
3471 } // namespace v8 | 3479 } // namespace v8 |
3472 | 3480 |
3473 #endif // V8_AST_AST_H_ | 3481 #endif // V8_AST_AST_H_ |
OLD | NEW |