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 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 bool is_anonymous_expression() const { | 2590 bool is_anonymous_expression() const { |
2591 return function_type() == kAnonymousExpression; | 2591 return function_type() == kAnonymousExpression; |
2592 } | 2592 } |
2593 LanguageMode language_mode() const; | 2593 LanguageMode language_mode() const; |
2594 | 2594 |
2595 static bool NeedsHomeObject(Expression* expr); | 2595 static bool NeedsHomeObject(Expression* expr); |
2596 | 2596 |
2597 int materialized_literal_count() { return materialized_literal_count_; } | 2597 int materialized_literal_count() { return materialized_literal_count_; } |
2598 int expected_property_count() { return expected_property_count_; } | 2598 int expected_property_count() { return expected_property_count_; } |
2599 int parameter_count() { return parameter_count_; } | 2599 int parameter_count() { return parameter_count_; } |
| 2600 int function_length() { return function_length_; } |
2600 | 2601 |
2601 bool AllowsLazyCompilation(); | 2602 bool AllowsLazyCompilation(); |
2602 | 2603 |
2603 Handle<String> debug_name() const { | 2604 Handle<String> debug_name() const { |
2604 if (raw_name_ != NULL && !raw_name_->IsEmpty()) { | 2605 if (raw_name_ != NULL && !raw_name_->IsEmpty()) { |
2605 return raw_name_->string(); | 2606 return raw_name_->string(); |
2606 } | 2607 } |
2607 return inferred_name(); | 2608 return inferred_name(); |
2608 } | 2609 } |
2609 | 2610 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2703 IsClassFieldInitializer::update(bit_field_, is_class_field_initializer); | 2704 IsClassFieldInitializer::update(bit_field_, is_class_field_initializer); |
2704 } | 2705 } |
2705 | 2706 |
2706 private: | 2707 private: |
2707 friend class AstNodeFactory; | 2708 friend class AstNodeFactory; |
2708 | 2709 |
2709 FunctionLiteral(Zone* zone, const AstString* name, | 2710 FunctionLiteral(Zone* zone, const AstString* name, |
2710 AstValueFactory* ast_value_factory, DeclarationScope* scope, | 2711 AstValueFactory* ast_value_factory, DeclarationScope* scope, |
2711 ZoneList<Statement*>* body, int materialized_literal_count, | 2712 ZoneList<Statement*>* body, int materialized_literal_count, |
2712 int expected_property_count, int parameter_count, | 2713 int expected_property_count, int parameter_count, |
2713 FunctionType function_type, | 2714 int function_length, FunctionType function_type, |
2714 ParameterFlag has_duplicate_parameters, | 2715 ParameterFlag has_duplicate_parameters, |
2715 EagerCompileHint eager_compile_hint, int position, | 2716 EagerCompileHint eager_compile_hint, int position, |
2716 bool is_function) | 2717 bool is_function) |
2717 : Expression(position, kFunctionLiteral), | 2718 : Expression(position, kFunctionLiteral), |
2718 materialized_literal_count_(materialized_literal_count), | 2719 materialized_literal_count_(materialized_literal_count), |
2719 expected_property_count_(expected_property_count), | 2720 expected_property_count_(expected_property_count), |
2720 parameter_count_(parameter_count), | 2721 parameter_count_(parameter_count), |
| 2722 function_length_(function_length), |
2721 function_token_position_(kNoSourcePosition), | 2723 function_token_position_(kNoSourcePosition), |
2722 yield_count_(0), | 2724 yield_count_(0), |
2723 raw_name_(name), | 2725 raw_name_(name), |
2724 scope_(scope), | 2726 scope_(scope), |
2725 body_(body), | 2727 body_(body), |
2726 raw_inferred_name_(ast_value_factory->empty_string()), | 2728 raw_inferred_name_(ast_value_factory->empty_string()), |
2727 ast_properties_(zone) { | 2729 ast_properties_(zone) { |
2728 bit_field_ |= | 2730 bit_field_ |= |
2729 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | | 2731 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
2730 HasDuplicateParameters::encode(has_duplicate_parameters == | 2732 HasDuplicateParameters::encode(has_duplicate_parameters == |
(...skipping 16 matching lines...) Expand all Loading... |
2747 class RequiresClassFieldInit | 2749 class RequiresClassFieldInit |
2748 : public BitField<bool, ShouldNotBeUsedOnceHintField::kNext, 1> {}; | 2750 : public BitField<bool, ShouldNotBeUsedOnceHintField::kNext, 1> {}; |
2749 class IsClassFieldInitializer | 2751 class IsClassFieldInitializer |
2750 : public BitField<bool, RequiresClassFieldInit::kNext, 1> {}; | 2752 : public BitField<bool, RequiresClassFieldInit::kNext, 1> {}; |
2751 class DontOptimizeReasonField | 2753 class DontOptimizeReasonField |
2752 : public BitField<BailoutReason, IsClassFieldInitializer::kNext, 8> {}; | 2754 : public BitField<BailoutReason, IsClassFieldInitializer::kNext, 8> {}; |
2753 | 2755 |
2754 int materialized_literal_count_; | 2756 int materialized_literal_count_; |
2755 int expected_property_count_; | 2757 int expected_property_count_; |
2756 int parameter_count_; | 2758 int parameter_count_; |
| 2759 int function_length_; |
2757 int function_token_position_; | 2760 int function_token_position_; |
2758 int yield_count_; | 2761 int yield_count_; |
2759 | 2762 |
2760 const AstString* raw_name_; | 2763 const AstString* raw_name_; |
2761 DeclarationScope* scope_; | 2764 DeclarationScope* scope_; |
2762 ZoneList<Statement*>* body_; | 2765 ZoneList<Statement*>* body_; |
2763 const AstString* raw_inferred_name_; | 2766 const AstString* raw_inferred_name_; |
2764 Handle<String> inferred_name_; | 2767 Handle<String> inferred_name_; |
2765 AstProperties ast_properties_; | 2768 AstProperties ast_properties_; |
2766 }; | 2769 }; |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3446 return new (zone_) Yield(generator_object, expression, pos, on_exception); | 3449 return new (zone_) Yield(generator_object, expression, pos, on_exception); |
3447 } | 3450 } |
3448 | 3451 |
3449 Throw* NewThrow(Expression* exception, int pos) { | 3452 Throw* NewThrow(Expression* exception, int pos) { |
3450 return new (zone_) Throw(exception, pos); | 3453 return new (zone_) Throw(exception, pos); |
3451 } | 3454 } |
3452 | 3455 |
3453 FunctionLiteral* NewFunctionLiteral( | 3456 FunctionLiteral* NewFunctionLiteral( |
3454 const AstRawString* name, DeclarationScope* scope, | 3457 const AstRawString* name, DeclarationScope* scope, |
3455 ZoneList<Statement*>* body, int materialized_literal_count, | 3458 ZoneList<Statement*>* body, int materialized_literal_count, |
3456 int expected_property_count, int parameter_count, | 3459 int expected_property_count, int parameter_count, int function_length, |
3457 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3460 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
3458 FunctionLiteral::FunctionType function_type, | 3461 FunctionLiteral::FunctionType function_type, |
3459 FunctionLiteral::EagerCompileHint eager_compile_hint, int position) { | 3462 FunctionLiteral::EagerCompileHint eager_compile_hint, int position) { |
3460 return new (zone_) FunctionLiteral(zone_, name, ast_value_factory_, scope, | 3463 return new (zone_) FunctionLiteral( |
3461 body, materialized_literal_count, | 3464 zone_, name, ast_value_factory_, scope, body, |
3462 expected_property_count, parameter_count, | 3465 materialized_literal_count, expected_property_count, parameter_count, |
3463 function_type, has_duplicate_parameters, | 3466 function_length, function_type, has_duplicate_parameters, |
3464 eager_compile_hint, position, true); | 3467 eager_compile_hint, position, true); |
3465 } | 3468 } |
3466 | 3469 |
3467 // Creates a FunctionLiteral representing a top-level script, the | 3470 // Creates a FunctionLiteral representing a top-level script, the |
3468 // result of an eval (top-level or otherwise), or the result of calling | 3471 // result of an eval (top-level or otherwise), or the result of calling |
3469 // the Function constructor. | 3472 // the Function constructor. |
3470 FunctionLiteral* NewScriptOrEvalFunctionLiteral( | 3473 FunctionLiteral* NewScriptOrEvalFunctionLiteral( |
3471 DeclarationScope* scope, ZoneList<Statement*>* body, | 3474 DeclarationScope* scope, ZoneList<Statement*>* body, |
3472 int materialized_literal_count, int expected_property_count, | 3475 int materialized_literal_count, int expected_property_count, |
3473 int parameter_count) { | 3476 int parameter_count) { |
3474 return new (zone_) FunctionLiteral( | 3477 return new (zone_) FunctionLiteral( |
3475 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, | 3478 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, |
3476 body, materialized_literal_count, expected_property_count, | 3479 body, materialized_literal_count, expected_property_count, |
3477 parameter_count, FunctionLiteral::kAnonymousExpression, | 3480 parameter_count, parameter_count, FunctionLiteral::kAnonymousExpression, |
3478 FunctionLiteral::kNoDuplicateParameters, | 3481 FunctionLiteral::kNoDuplicateParameters, |
3479 FunctionLiteral::kShouldLazyCompile, 0, false); | 3482 FunctionLiteral::kShouldLazyCompile, 0, false); |
3480 } | 3483 } |
3481 | 3484 |
3482 ClassLiteral::Property* NewClassLiteralProperty( | 3485 ClassLiteral::Property* NewClassLiteralProperty( |
3483 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, | 3486 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, |
3484 bool is_static, bool is_computed_name) { | 3487 bool is_static, bool is_computed_name) { |
3485 return new (zone_) | 3488 return new (zone_) |
3486 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); | 3489 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); |
3487 } | 3490 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3595 : NULL; \ | 3598 : NULL; \ |
3596 } | 3599 } |
3597 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3600 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3598 #undef DECLARE_NODE_FUNCTIONS | 3601 #undef DECLARE_NODE_FUNCTIONS |
3599 | 3602 |
3600 | 3603 |
3601 } // namespace internal | 3604 } // namespace internal |
3602 } // namespace v8 | 3605 } // namespace v8 |
3603 | 3606 |
3604 #endif // V8_AST_AST_H_ | 3607 #endif // V8_AST_AST_H_ |
OLD | NEW |