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

Side by Side Diff: src/ast/ast.h

Issue 2209573002: Separate Scope into DeclarationScope and Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 4 years, 4 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
OLDNEW
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 2525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 2536
2537 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; 2537 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters };
2538 2538
2539 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; 2539 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile };
2540 2540
2541 DECLARE_NODE_TYPE(FunctionLiteral) 2541 DECLARE_NODE_TYPE(FunctionLiteral)
2542 2542
2543 Handle<String> name() const { return raw_name_->string(); } 2543 Handle<String> name() const { return raw_name_->string(); }
2544 const AstString* raw_name() const { return raw_name_; } 2544 const AstString* raw_name() const { return raw_name_; }
2545 void set_raw_name(const AstString* name) { raw_name_ = name; } 2545 void set_raw_name(const AstString* name) { raw_name_ = name; }
2546 Scope* scope() const { return scope_; } 2546 DeclarationScope* scope() const { return scope_; }
2547 ZoneList<Statement*>* body() const { return body_; } 2547 ZoneList<Statement*>* body() const { return body_; }
2548 void set_function_token_position(int pos) { function_token_position_ = pos; } 2548 void set_function_token_position(int pos) { function_token_position_ = pos; }
2549 int function_token_position() const { return function_token_position_; } 2549 int function_token_position() const { return function_token_position_; }
2550 int start_position() const; 2550 int start_position() const;
2551 int end_position() const; 2551 int end_position() const;
2552 int SourceSize() const { return end_position() - start_position(); } 2552 int SourceSize() const { return end_position() - start_position(); }
2553 bool is_declaration() const { return function_type() == kDeclaration; } 2553 bool is_declaration() const { return function_type() == kDeclaration; }
2554 bool is_named_expression() const { 2554 bool is_named_expression() const {
2555 return function_type() == kNamedExpression; 2555 return function_type() == kNamedExpression;
2556 } 2556 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 2653
2654 bool IsAnonymousFunctionDefinition() const { 2654 bool IsAnonymousFunctionDefinition() const {
2655 return is_anonymous_expression(); 2655 return is_anonymous_expression();
2656 } 2656 }
2657 2657
2658 int yield_count() { return yield_count_; } 2658 int yield_count() { return yield_count_; }
2659 void set_yield_count(int yield_count) { yield_count_ = yield_count; } 2659 void set_yield_count(int yield_count) { yield_count_ = yield_count; }
2660 2660
2661 protected: 2661 protected:
2662 FunctionLiteral(Zone* zone, const AstString* name, 2662 FunctionLiteral(Zone* zone, const AstString* name,
2663 AstValueFactory* ast_value_factory, Scope* scope, 2663 AstValueFactory* ast_value_factory, DeclarationScope* scope,
2664 ZoneList<Statement*>* body, int materialized_literal_count, 2664 ZoneList<Statement*>* body, int materialized_literal_count,
2665 int expected_property_count, int parameter_count, 2665 int expected_property_count, int parameter_count,
2666 FunctionType function_type, 2666 FunctionType function_type,
2667 ParameterFlag has_duplicate_parameters, 2667 ParameterFlag has_duplicate_parameters,
2668 EagerCompileHint eager_compile_hint, FunctionKind kind, 2668 EagerCompileHint eager_compile_hint, FunctionKind kind,
2669 int position, bool is_function) 2669 int position, bool is_function)
2670 : Expression(zone, position, kFunctionLiteral), 2670 : Expression(zone, position, kFunctionLiteral),
2671 dont_optimize_reason_(kNoReason), 2671 dont_optimize_reason_(kNoReason),
2672 materialized_literal_count_(materialized_literal_count), 2672 materialized_literal_count_(materialized_literal_count),
2673 expected_property_count_(expected_property_count), 2673 expected_property_count_(expected_property_count),
(...skipping 30 matching lines...) Expand all
2704 2704
2705 BailoutReason dont_optimize_reason_; 2705 BailoutReason dont_optimize_reason_;
2706 2706
2707 int materialized_literal_count_; 2707 int materialized_literal_count_;
2708 int expected_property_count_; 2708 int expected_property_count_;
2709 int parameter_count_; 2709 int parameter_count_;
2710 int function_token_position_; 2710 int function_token_position_;
2711 int yield_count_; 2711 int yield_count_;
2712 2712
2713 const AstString* raw_name_; 2713 const AstString* raw_name_;
2714 Scope* scope_; 2714 DeclarationScope* scope_;
2715 ZoneList<Statement*>* body_; 2715 ZoneList<Statement*>* body_;
2716 const AstString* raw_inferred_name_; 2716 const AstString* raw_inferred_name_;
2717 Handle<String> inferred_name_; 2717 Handle<String> inferred_name_;
2718 AstProperties ast_properties_; 2718 AstProperties ast_properties_;
2719 }; 2719 };
2720 2720
2721 2721
2722 class ClassLiteral final : public Expression { 2722 class ClassLiteral final : public Expression {
2723 public: 2723 public:
2724 typedef ObjectLiteralProperty Property; 2724 typedef ObjectLiteralProperty Property;
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 if (!expression) expression = NewUndefinedLiteral(pos); 3374 if (!expression) expression = NewUndefinedLiteral(pos);
3375 return new (zone_) 3375 return new (zone_)
3376 Yield(zone_, generator_object, expression, pos, on_exception); 3376 Yield(zone_, generator_object, expression, pos, on_exception);
3377 } 3377 }
3378 3378
3379 Throw* NewThrow(Expression* exception, int pos) { 3379 Throw* NewThrow(Expression* exception, int pos) {
3380 return new (zone_) Throw(zone_, exception, pos); 3380 return new (zone_) Throw(zone_, exception, pos);
3381 } 3381 }
3382 3382
3383 FunctionLiteral* NewFunctionLiteral( 3383 FunctionLiteral* NewFunctionLiteral(
3384 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body, 3384 const AstRawString* name, DeclarationScope* scope,
3385 int materialized_literal_count, int expected_property_count, 3385 ZoneList<Statement*>* body, int materialized_literal_count,
3386 int parameter_count, 3386 int expected_property_count, int parameter_count,
3387 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3387 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3388 FunctionLiteral::FunctionType function_type, 3388 FunctionLiteral::FunctionType function_type,
3389 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, 3389 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
3390 int position) { 3390 int position) {
3391 return new (zone_) FunctionLiteral( 3391 return new (zone_) FunctionLiteral(
3392 zone_, name, ast_value_factory_, scope, body, 3392 zone_, name, ast_value_factory_, scope, body,
3393 materialized_literal_count, expected_property_count, parameter_count, 3393 materialized_literal_count, expected_property_count, parameter_count,
3394 function_type, has_duplicate_parameters, eager_compile_hint, kind, 3394 function_type, has_duplicate_parameters, eager_compile_hint, kind,
3395 position, true); 3395 position, true);
3396 } 3396 }
3397 3397
3398 // Creates a FunctionLiteral representing a top-level script, the 3398 // Creates a FunctionLiteral representing a top-level script, the
3399 // result of an eval (top-level or otherwise), or the result of calling 3399 // result of an eval (top-level or otherwise), or the result of calling
3400 // the Function constructor. 3400 // the Function constructor.
3401 FunctionLiteral* NewScriptOrEvalFunctionLiteral( 3401 FunctionLiteral* NewScriptOrEvalFunctionLiteral(
3402 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3402 DeclarationScope* scope, ZoneList<Statement*>* body,
3403 int expected_property_count) { 3403 int materialized_literal_count, int expected_property_count) {
3404 return new (zone_) FunctionLiteral( 3404 return new (zone_) FunctionLiteral(
3405 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, 3405 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope,
3406 body, materialized_literal_count, expected_property_count, 0, 3406 body, materialized_literal_count, expected_property_count, 0,
3407 FunctionLiteral::kAnonymousExpression, 3407 FunctionLiteral::kAnonymousExpression,
3408 FunctionLiteral::kNoDuplicateParameters, 3408 FunctionLiteral::kNoDuplicateParameters,
3409 FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0, 3409 FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0,
3410 false); 3410 false);
3411 } 3411 }
3412 3412
3413 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, 3413 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3519 : NULL; \ 3519 : NULL; \
3520 } 3520 }
3521 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3521 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3522 #undef DECLARE_NODE_FUNCTIONS 3522 #undef DECLARE_NODE_FUNCTIONS
3523 3523
3524 3524
3525 } // namespace internal 3525 } // namespace internal
3526 } // namespace v8 3526 } // namespace v8
3527 3527
3528 #endif // V8_AST_AST_H_ 3528 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « src/asmjs/asm-wasm-builder.cc ('k') | src/ast/ast-numbering.cc » ('j') | src/ast/scopeinfo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698