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-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
9 #include "src/ast/modules.h" | 9 #include "src/ast/modules.h" |
10 #include "src/ast/variables.h" | 10 #include "src/ast/variables.h" |
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 | 2537 |
2538 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; | 2538 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; |
2539 | 2539 |
2540 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; | 2540 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; |
2541 | 2541 |
2542 DECLARE_NODE_TYPE(FunctionLiteral) | 2542 DECLARE_NODE_TYPE(FunctionLiteral) |
2543 | 2543 |
2544 Handle<String> name() const { return raw_name_->string(); } | 2544 Handle<String> name() const { return raw_name_->string(); } |
2545 const AstString* raw_name() const { return raw_name_; } | 2545 const AstString* raw_name() const { return raw_name_; } |
2546 void set_raw_name(const AstString* name) { raw_name_ = name; } | 2546 void set_raw_name(const AstString* name) { raw_name_ = name; } |
2547 Scope* scope() const { return scope_; } | 2547 DeclarationScope* scope() const { return scope_; } |
2548 ZoneList<Statement*>* body() const { return body_; } | 2548 ZoneList<Statement*>* body() const { return body_; } |
2549 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2549 void set_function_token_position(int pos) { function_token_position_ = pos; } |
2550 int function_token_position() const { return function_token_position_; } | 2550 int function_token_position() const { return function_token_position_; } |
2551 int start_position() const; | 2551 int start_position() const; |
2552 int end_position() const; | 2552 int end_position() const; |
2553 int SourceSize() const { return end_position() - start_position(); } | 2553 int SourceSize() const { return end_position() - start_position(); } |
2554 bool is_declaration() const { return function_type() == kDeclaration; } | 2554 bool is_declaration() const { return function_type() == kDeclaration; } |
2555 bool is_named_expression() const { | 2555 bool is_named_expression() const { |
2556 return function_type() == kNamedExpression; | 2556 return function_type() == kNamedExpression; |
2557 } | 2557 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2654 | 2654 |
2655 bool IsAnonymousFunctionDefinition() const { | 2655 bool IsAnonymousFunctionDefinition() const { |
2656 return is_anonymous_expression(); | 2656 return is_anonymous_expression(); |
2657 } | 2657 } |
2658 | 2658 |
2659 int yield_count() { return yield_count_; } | 2659 int yield_count() { return yield_count_; } |
2660 void set_yield_count(int yield_count) { yield_count_ = yield_count; } | 2660 void set_yield_count(int yield_count) { yield_count_ = yield_count; } |
2661 | 2661 |
2662 protected: | 2662 protected: |
2663 FunctionLiteral(Zone* zone, const AstString* name, | 2663 FunctionLiteral(Zone* zone, const AstString* name, |
2664 AstValueFactory* ast_value_factory, Scope* scope, | 2664 AstValueFactory* ast_value_factory, DeclarationScope* scope, |
2665 ZoneList<Statement*>* body, int materialized_literal_count, | 2665 ZoneList<Statement*>* body, int materialized_literal_count, |
2666 int expected_property_count, int parameter_count, | 2666 int expected_property_count, int parameter_count, |
2667 FunctionType function_type, | 2667 FunctionType function_type, |
2668 ParameterFlag has_duplicate_parameters, | 2668 ParameterFlag has_duplicate_parameters, |
2669 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2669 EagerCompileHint eager_compile_hint, FunctionKind kind, |
2670 int position, bool is_function) | 2670 int position, bool is_function) |
2671 : Expression(zone, position, kFunctionLiteral), | 2671 : Expression(zone, position, kFunctionLiteral), |
2672 dont_optimize_reason_(kNoReason), | 2672 dont_optimize_reason_(kNoReason), |
2673 materialized_literal_count_(materialized_literal_count), | 2673 materialized_literal_count_(materialized_literal_count), |
2674 expected_property_count_(expected_property_count), | 2674 expected_property_count_(expected_property_count), |
(...skipping 30 matching lines...) Expand all Loading... |
2705 | 2705 |
2706 BailoutReason dont_optimize_reason_; | 2706 BailoutReason dont_optimize_reason_; |
2707 | 2707 |
2708 int materialized_literal_count_; | 2708 int materialized_literal_count_; |
2709 int expected_property_count_; | 2709 int expected_property_count_; |
2710 int parameter_count_; | 2710 int parameter_count_; |
2711 int function_token_position_; | 2711 int function_token_position_; |
2712 int yield_count_; | 2712 int yield_count_; |
2713 | 2713 |
2714 const AstString* raw_name_; | 2714 const AstString* raw_name_; |
2715 Scope* scope_; | 2715 DeclarationScope* scope_; |
2716 ZoneList<Statement*>* body_; | 2716 ZoneList<Statement*>* body_; |
2717 const AstString* raw_inferred_name_; | 2717 const AstString* raw_inferred_name_; |
2718 Handle<String> inferred_name_; | 2718 Handle<String> inferred_name_; |
2719 AstProperties ast_properties_; | 2719 AstProperties ast_properties_; |
2720 }; | 2720 }; |
2721 | 2721 |
2722 | 2722 |
2723 class ClassLiteral final : public Expression { | 2723 class ClassLiteral final : public Expression { |
2724 public: | 2724 public: |
2725 typedef ObjectLiteralProperty Property; | 2725 typedef ObjectLiteralProperty Property; |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3385 if (!expression) expression = NewUndefinedLiteral(pos); | 3385 if (!expression) expression = NewUndefinedLiteral(pos); |
3386 return new (zone_) | 3386 return new (zone_) |
3387 Yield(zone_, generator_object, expression, pos, on_exception); | 3387 Yield(zone_, generator_object, expression, pos, on_exception); |
3388 } | 3388 } |
3389 | 3389 |
3390 Throw* NewThrow(Expression* exception, int pos) { | 3390 Throw* NewThrow(Expression* exception, int pos) { |
3391 return new (zone_) Throw(zone_, exception, pos); | 3391 return new (zone_) Throw(zone_, exception, pos); |
3392 } | 3392 } |
3393 | 3393 |
3394 FunctionLiteral* NewFunctionLiteral( | 3394 FunctionLiteral* NewFunctionLiteral( |
3395 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body, | 3395 const AstRawString* name, DeclarationScope* scope, |
3396 int materialized_literal_count, int expected_property_count, | 3396 ZoneList<Statement*>* body, int materialized_literal_count, |
3397 int parameter_count, | 3397 int expected_property_count, int parameter_count, |
3398 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3398 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
3399 FunctionLiteral::FunctionType function_type, | 3399 FunctionLiteral::FunctionType function_type, |
3400 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, | 3400 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, |
3401 int position) { | 3401 int position) { |
3402 return new (zone_) FunctionLiteral( | 3402 return new (zone_) FunctionLiteral( |
3403 zone_, name, ast_value_factory_, scope, body, | 3403 zone_, name, ast_value_factory_, scope, body, |
3404 materialized_literal_count, expected_property_count, parameter_count, | 3404 materialized_literal_count, expected_property_count, parameter_count, |
3405 function_type, has_duplicate_parameters, eager_compile_hint, kind, | 3405 function_type, has_duplicate_parameters, eager_compile_hint, kind, |
3406 position, true); | 3406 position, true); |
3407 } | 3407 } |
3408 | 3408 |
3409 // Creates a FunctionLiteral representing a top-level script, the | 3409 // Creates a FunctionLiteral representing a top-level script, the |
3410 // result of an eval (top-level or otherwise), or the result of calling | 3410 // result of an eval (top-level or otherwise), or the result of calling |
3411 // the Function constructor. | 3411 // the Function constructor. |
3412 FunctionLiteral* NewScriptOrEvalFunctionLiteral( | 3412 FunctionLiteral* NewScriptOrEvalFunctionLiteral( |
3413 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, | 3413 DeclarationScope* scope, ZoneList<Statement*>* body, |
3414 int expected_property_count) { | 3414 int materialized_literal_count, int expected_property_count) { |
3415 return new (zone_) FunctionLiteral( | 3415 return new (zone_) FunctionLiteral( |
3416 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, | 3416 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, |
3417 body, materialized_literal_count, expected_property_count, 0, | 3417 body, materialized_literal_count, expected_property_count, 0, |
3418 FunctionLiteral::kAnonymousExpression, | 3418 FunctionLiteral::kAnonymousExpression, |
3419 FunctionLiteral::kNoDuplicateParameters, | 3419 FunctionLiteral::kNoDuplicateParameters, |
3420 FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0, | 3420 FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0, |
3421 false); | 3421 false); |
3422 } | 3422 } |
3423 | 3423 |
3424 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, | 3424 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3530 : NULL; \ | 3530 : NULL; \ |
3531 } | 3531 } |
3532 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3532 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3533 #undef DECLARE_NODE_FUNCTIONS | 3533 #undef DECLARE_NODE_FUNCTIONS |
3534 | 3534 |
3535 | 3535 |
3536 } // namespace internal | 3536 } // namespace internal |
3537 } // namespace v8 | 3537 } // namespace v8 |
3538 | 3538 |
3539 #endif // V8_AST_AST_H_ | 3539 #endif // V8_AST_AST_H_ |
OLD | NEW |