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

Side by Side Diff: src/ast.h

Issue 1053773006: [es6] implement default/optional parameters (WIP / comments) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Experimental not-quite-TDZ support Created 5 years, 8 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
« no previous file with comments | « no previous file | src/ast-numbering.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/assembler.h" 10 #include "src/assembler.h"
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 const AstRawString* AsRawPropertyName() { 1341 const AstRawString* AsRawPropertyName() {
1342 DCHECK(IsPropertyName()); 1342 DCHECK(IsPropertyName());
1343 return value_->AsString(); 1343 return value_->AsString();
1344 } 1344 }
1345 1345
1346 bool ToBooleanIsTrue() const OVERRIDE { return value()->BooleanValue(); } 1346 bool ToBooleanIsTrue() const OVERRIDE { return value()->BooleanValue(); }
1347 bool ToBooleanIsFalse() const OVERRIDE { return !value()->BooleanValue(); } 1347 bool ToBooleanIsFalse() const OVERRIDE { return !value()->BooleanValue(); }
1348 1348
1349 Handle<Object> value() const { return value_->value(); } 1349 Handle<Object> value() const { return value_->value(); }
1350 const AstValue* raw_value() const { return value_; } 1350 const AstValue* raw_value() const { return value_; }
1351 bool IsUndefined() const { return value_->IsUndefined(); }
1351 1352
1352 // Support for using Literal as a HashMap key. NOTE: Currently, this works 1353 // Support for using Literal as a HashMap key. NOTE: Currently, this works
1353 // only for string and number literals! 1354 // only for string and number literals!
1354 uint32_t Hash(); 1355 uint32_t Hash();
1355 static bool Match(void* literal1, void* literal2); 1356 static bool Match(void* literal1, void* literal2);
1356 1357
1357 static int num_ids() { return parent_num_ids() + 1; } 1358 static int num_ids() { return parent_num_ids() + 1; }
1358 TypeFeedbackId LiteralFeedbackId() const { 1359 TypeFeedbackId LiteralFeedbackId() const {
1359 return TypeFeedbackId(local_id(0)); 1360 return TypeFeedbackId(local_id(0));
1360 } 1361 }
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 GETTER_ARITY, 2499 GETTER_ARITY,
2499 SETTER_ARITY 2500 SETTER_ARITY
2500 }; 2501 };
2501 2502
2502 DECLARE_NODE_TYPE(FunctionLiteral) 2503 DECLARE_NODE_TYPE(FunctionLiteral)
2503 2504
2504 Handle<String> name() const { return raw_name_->string(); } 2505 Handle<String> name() const { return raw_name_->string(); }
2505 const AstRawString* raw_name() const { return raw_name_; } 2506 const AstRawString* raw_name() const { return raw_name_; }
2506 Scope* scope() const { return scope_; } 2507 Scope* scope() const { return scope_; }
2507 ZoneList<Statement*>* body() const { return body_; } 2508 ZoneList<Statement*>* body() const { return body_; }
2509 ZoneList<Expression*>* default_values() const { return default_values_; }
2508 void set_function_token_position(int pos) { function_token_position_ = pos; } 2510 void set_function_token_position(int pos) { function_token_position_ = pos; }
2509 int function_token_position() const { return function_token_position_; } 2511 int function_token_position() const { return function_token_position_; }
2510 int start_position() const; 2512 int start_position() const;
2511 int end_position() const; 2513 int end_position() const;
2512 int SourceSize() const { return end_position() - start_position(); } 2514 int SourceSize() const { return end_position() - start_position(); }
2513 bool is_expression() const { return IsExpression::decode(bitfield_); } 2515 bool is_expression() const { return IsExpression::decode(bitfield_); }
2514 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } 2516 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
2515 LanguageMode language_mode() const; 2517 LanguageMode language_mode() const;
2516 bool uses_super_property() const; 2518 bool uses_super_property() const;
2517 2519
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { 2600 const ZoneFeedbackVectorSpec* feedback_vector_spec() const {
2599 return ast_properties_.get_spec(); 2601 return ast_properties_.get_spec();
2600 } 2602 }
2601 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2603 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2602 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2604 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2603 void set_dont_optimize_reason(BailoutReason reason) { 2605 void set_dont_optimize_reason(BailoutReason reason) {
2604 dont_optimize_reason_ = reason; 2606 dont_optimize_reason_ = reason;
2605 } 2607 }
2606 2608
2607 protected: 2609 protected:
2608 FunctionLiteral(Zone* zone, const AstRawString* name, 2610 FunctionLiteral(
2609 AstValueFactory* ast_value_factory, Scope* scope, 2611 Zone* zone, const AstRawString* name, AstValueFactory* ast_value_factory,
2610 ZoneList<Statement*>* body, int materialized_literal_count, 2612 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
2611 int expected_property_count, int handler_count, 2613 int expected_property_count, int handler_count, int parameter_count,
2612 int parameter_count, FunctionType function_type, 2614 ZoneList<Expression*>* default_values, FunctionType function_type,
2613 ParameterFlag has_duplicate_parameters, 2615 ParameterFlag has_duplicate_parameters, IsFunctionFlag is_function,
2614 IsFunctionFlag is_function, 2616 IsParenthesizedFlag is_parenthesized, FunctionKind kind, int position)
2615 IsParenthesizedFlag is_parenthesized, FunctionKind kind,
2616 int position)
2617 : Expression(zone, position), 2617 : Expression(zone, position),
2618 raw_name_(name), 2618 raw_name_(name),
2619 scope_(scope), 2619 scope_(scope),
2620 body_(body), 2620 body_(body),
2621 raw_inferred_name_(ast_value_factory->empty_string()), 2621 raw_inferred_name_(ast_value_factory->empty_string()),
2622 ast_properties_(zone), 2622 ast_properties_(zone),
2623 dont_optimize_reason_(kNoReason), 2623 dont_optimize_reason_(kNoReason),
2624 materialized_literal_count_(materialized_literal_count), 2624 materialized_literal_count_(materialized_literal_count),
2625 expected_property_count_(expected_property_count), 2625 expected_property_count_(expected_property_count),
2626 handler_count_(handler_count), 2626 handler_count_(handler_count),
2627 parameter_count_(parameter_count), 2627 parameter_count_(parameter_count),
2628 default_values_(default_values),
2628 function_token_position_(RelocInfo::kNoPosition) { 2629 function_token_position_(RelocInfo::kNoPosition) {
2629 bitfield_ = IsExpression::encode(function_type != DECLARATION) | 2630 bitfield_ = IsExpression::encode(function_type != DECLARATION) |
2630 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2631 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2631 Pretenure::encode(false) | 2632 Pretenure::encode(false) |
2632 HasDuplicateParameters::encode(has_duplicate_parameters) | 2633 HasDuplicateParameters::encode(has_duplicate_parameters) |
2633 IsFunction::encode(is_function) | 2634 IsFunction::encode(is_function) |
2634 IsParenthesized::encode(is_parenthesized) | 2635 IsParenthesized::encode(is_parenthesized) |
2635 FunctionKindBits::encode(kind); 2636 FunctionKindBits::encode(kind);
2636 DCHECK(IsValidFunctionKind(kind)); 2637 DCHECK(IsValidFunctionKind(kind));
2637 } 2638 }
2638 2639
2639 private: 2640 private:
2640 const AstRawString* raw_name_; 2641 const AstRawString* raw_name_;
2641 Handle<String> name_; 2642 Handle<String> name_;
2642 Handle<SharedFunctionInfo> shared_info_; 2643 Handle<SharedFunctionInfo> shared_info_;
2643 Scope* scope_; 2644 Scope* scope_;
2644 ZoneList<Statement*>* body_; 2645 ZoneList<Statement*>* body_;
2645 const AstString* raw_inferred_name_; 2646 const AstString* raw_inferred_name_;
2646 Handle<String> inferred_name_; 2647 Handle<String> inferred_name_;
2647 AstProperties ast_properties_; 2648 AstProperties ast_properties_;
2648 BailoutReason dont_optimize_reason_; 2649 BailoutReason dont_optimize_reason_;
2649 2650
2650 int materialized_literal_count_; 2651 int materialized_literal_count_;
2651 int expected_property_count_; 2652 int expected_property_count_;
2652 int handler_count_; 2653 int handler_count_;
2653 int parameter_count_; 2654 int parameter_count_;
2655 ZoneList<Expression*>* default_values_;
2654 int function_token_position_; 2656 int function_token_position_;
2655 2657
2656 unsigned bitfield_; 2658 unsigned bitfield_;
2657 class IsExpression : public BitField<bool, 0, 1> {}; 2659 class IsExpression : public BitField<bool, 0, 1> {};
2658 class IsAnonymous : public BitField<bool, 1, 1> {}; 2660 class IsAnonymous : public BitField<bool, 1, 1> {};
2659 class Pretenure : public BitField<bool, 2, 1> {}; 2661 class Pretenure : public BitField<bool, 2, 1> {};
2660 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; 2662 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
2661 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; 2663 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
2662 class IsParenthesized : public BitField<IsParenthesizedFlag, 5, 1> {}; 2664 class IsParenthesized : public BitField<IsParenthesizedFlag, 5, 1> {};
2663 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; 2665 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {};
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
3532 } 3534 }
3533 3535
3534 Throw* NewThrow(Expression* exception, int pos) { 3536 Throw* NewThrow(Expression* exception, int pos) {
3535 return new (zone_) Throw(zone_, exception, pos); 3537 return new (zone_) Throw(zone_, exception, pos);
3536 } 3538 }
3537 3539
3538 FunctionLiteral* NewFunctionLiteral( 3540 FunctionLiteral* NewFunctionLiteral(
3539 const AstRawString* name, AstValueFactory* ast_value_factory, 3541 const AstRawString* name, AstValueFactory* ast_value_factory,
3540 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3542 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3541 int expected_property_count, int handler_count, int parameter_count, 3543 int expected_property_count, int handler_count, int parameter_count,
3544 ZoneList<Expression*>* default_parameters,
3542 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3545 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3543 FunctionLiteral::FunctionType function_type, 3546 FunctionLiteral::FunctionType function_type,
3544 FunctionLiteral::IsFunctionFlag is_function, 3547 FunctionLiteral::IsFunctionFlag is_function,
3545 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, 3548 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
3546 int position) { 3549 int position) {
3547 return new (zone_) FunctionLiteral( 3550 return new (zone_) FunctionLiteral(
3548 zone_, name, ast_value_factory, scope, body, materialized_literal_count, 3551 zone_, name, ast_value_factory, scope, body, materialized_literal_count,
3549 expected_property_count, handler_count, parameter_count, function_type, 3552 expected_property_count, handler_count, parameter_count,
3550 has_duplicate_parameters, is_function, is_parenthesized, kind, 3553 default_parameters, function_type, has_duplicate_parameters,
3551 position); 3554 is_function, is_parenthesized, kind, position);
3552 } 3555 }
3553 3556
3554 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope, 3557 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope,
3555 VariableProxy* proxy, Expression* extends, 3558 VariableProxy* proxy, Expression* extends,
3556 FunctionLiteral* constructor, 3559 FunctionLiteral* constructor,
3557 ZoneList<ObjectLiteral::Property*>* properties, 3560 ZoneList<ObjectLiteral::Property*>* properties,
3558 int start_position, int end_position) { 3561 int start_position, int end_position) {
3559 return new (zone_) 3562 return new (zone_)
3560 ClassLiteral(zone_, name, scope, proxy, extends, constructor, 3563 ClassLiteral(zone_, name, scope, proxy, extends, constructor,
3561 properties, start_position, end_position); 3564 properties, start_position, end_position);
(...skipping 15 matching lines...) Expand all
3577 3580
3578 private: 3581 private:
3579 Zone* zone_; 3582 Zone* zone_;
3580 AstValueFactory* ast_value_factory_; 3583 AstValueFactory* ast_value_factory_;
3581 }; 3584 };
3582 3585
3583 3586
3584 } } // namespace v8::internal 3587 } } // namespace v8::internal
3585 3588
3586 #endif // V8_AST_H_ 3589 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast-numbering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698