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

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: 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') | src/ast-numbering.cc » ('J')
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_; }
arv (Not doing code reviews) 2015/04/10 15:08:48 I'm not sure we want a parallel list for this. It
caitp (gmail) 2015/04/10 15:28:00 I agree with you, see other comment. It's a quick
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(Zone* zone, const AstRawString* name,
2609 AstValueFactory* ast_value_factory, Scope* scope, 2611 AstValueFactory* ast_value_factory, Scope* scope,
2610 ZoneList<Statement*>* body, int materialized_literal_count, 2612 ZoneList<Statement*>* body, int materialized_literal_count,
2611 int expected_property_count, int handler_count, 2613 int expected_property_count, int handler_count,
2612 int parameter_count, FunctionType function_type, 2614 int parameter_count, ZoneList<Expression*>* default_values,
2615 FunctionType function_type,
2613 ParameterFlag has_duplicate_parameters, 2616 ParameterFlag has_duplicate_parameters,
2614 IsFunctionFlag is_function, 2617 IsFunctionFlag is_function,
2615 IsParenthesizedFlag is_parenthesized, FunctionKind kind, 2618 IsParenthesizedFlag is_parenthesized, FunctionKind kind,
2616 int position) 2619 int position)
2617 : Expression(zone, position), 2620 : Expression(zone, position),
2618 raw_name_(name), 2621 raw_name_(name),
2619 scope_(scope), 2622 scope_(scope),
2620 body_(body), 2623 body_(body),
2621 raw_inferred_name_(ast_value_factory->empty_string()), 2624 raw_inferred_name_(ast_value_factory->empty_string()),
2622 ast_properties_(zone), 2625 ast_properties_(zone),
2623 dont_optimize_reason_(kNoReason), 2626 dont_optimize_reason_(kNoReason),
2624 materialized_literal_count_(materialized_literal_count), 2627 materialized_literal_count_(materialized_literal_count),
2625 expected_property_count_(expected_property_count), 2628 expected_property_count_(expected_property_count),
2626 handler_count_(handler_count), 2629 handler_count_(handler_count),
2627 parameter_count_(parameter_count), 2630 parameter_count_(parameter_count),
2631 default_values_(default_values),
2628 function_token_position_(RelocInfo::kNoPosition) { 2632 function_token_position_(RelocInfo::kNoPosition) {
2629 bitfield_ = IsExpression::encode(function_type != DECLARATION) | 2633 bitfield_ = IsExpression::encode(function_type != DECLARATION) |
2630 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2634 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2631 Pretenure::encode(false) | 2635 Pretenure::encode(false) |
2632 HasDuplicateParameters::encode(has_duplicate_parameters) | 2636 HasDuplicateParameters::encode(has_duplicate_parameters) |
2633 IsFunction::encode(is_function) | 2637 IsFunction::encode(is_function) |
2634 IsParenthesized::encode(is_parenthesized) | 2638 IsParenthesized::encode(is_parenthesized) |
2635 FunctionKindBits::encode(kind); 2639 FunctionKindBits::encode(kind);
2636 DCHECK(IsValidFunctionKind(kind)); 2640 DCHECK(IsValidFunctionKind(kind));
2637 } 2641 }
2638 2642
2639 private: 2643 private:
2640 const AstRawString* raw_name_; 2644 const AstRawString* raw_name_;
2641 Handle<String> name_; 2645 Handle<String> name_;
2642 Handle<SharedFunctionInfo> shared_info_; 2646 Handle<SharedFunctionInfo> shared_info_;
2643 Scope* scope_; 2647 Scope* scope_;
2644 ZoneList<Statement*>* body_; 2648 ZoneList<Statement*>* body_;
2645 const AstString* raw_inferred_name_; 2649 const AstString* raw_inferred_name_;
2646 Handle<String> inferred_name_; 2650 Handle<String> inferred_name_;
2647 AstProperties ast_properties_; 2651 AstProperties ast_properties_;
2648 BailoutReason dont_optimize_reason_; 2652 BailoutReason dont_optimize_reason_;
2649 2653
2650 int materialized_literal_count_; 2654 int materialized_literal_count_;
2651 int expected_property_count_; 2655 int expected_property_count_;
2652 int handler_count_; 2656 int handler_count_;
2653 int parameter_count_; 2657 int parameter_count_;
2658 ZoneList<Expression*>* default_values_;
2654 int function_token_position_; 2659 int function_token_position_;
2655 2660
2656 unsigned bitfield_; 2661 unsigned bitfield_;
2657 class IsExpression : public BitField<bool, 0, 1> {}; 2662 class IsExpression : public BitField<bool, 0, 1> {};
2658 class IsAnonymous : public BitField<bool, 1, 1> {}; 2663 class IsAnonymous : public BitField<bool, 1, 1> {};
2659 class Pretenure : public BitField<bool, 2, 1> {}; 2664 class Pretenure : public BitField<bool, 2, 1> {};
2660 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; 2665 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
2661 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; 2666 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
2662 class IsParenthesized : public BitField<IsParenthesizedFlag, 5, 1> {}; 2667 class IsParenthesized : public BitField<IsParenthesizedFlag, 5, 1> {};
2663 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; 2668 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {};
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
3532 } 3537 }
3533 3538
3534 Throw* NewThrow(Expression* exception, int pos) { 3539 Throw* NewThrow(Expression* exception, int pos) {
3535 return new (zone_) Throw(zone_, exception, pos); 3540 return new (zone_) Throw(zone_, exception, pos);
3536 } 3541 }
3537 3542
3538 FunctionLiteral* NewFunctionLiteral( 3543 FunctionLiteral* NewFunctionLiteral(
3539 const AstRawString* name, AstValueFactory* ast_value_factory, 3544 const AstRawString* name, AstValueFactory* ast_value_factory,
3540 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3545 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3541 int expected_property_count, int handler_count, int parameter_count, 3546 int expected_property_count, int handler_count, int parameter_count,
3547 ZoneList<Expression*>* default_parameters,
3542 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3548 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3543 FunctionLiteral::FunctionType function_type, 3549 FunctionLiteral::FunctionType function_type,
3544 FunctionLiteral::IsFunctionFlag is_function, 3550 FunctionLiteral::IsFunctionFlag is_function,
3545 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, 3551 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
3546 int position) { 3552 int position) {
3547 return new (zone_) FunctionLiteral( 3553 return new (zone_) FunctionLiteral(
3548 zone_, name, ast_value_factory, scope, body, materialized_literal_count, 3554 zone_, name, ast_value_factory, scope, body, materialized_literal_count,
3549 expected_property_count, handler_count, parameter_count, function_type, 3555 expected_property_count, handler_count, parameter_count,
3550 has_duplicate_parameters, is_function, is_parenthesized, kind, 3556 default_parameters, function_type, has_duplicate_parameters,
3551 position); 3557 is_function, is_parenthesized, kind, position);
3552 } 3558 }
3553 3559
3554 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope, 3560 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope,
3555 VariableProxy* proxy, Expression* extends, 3561 VariableProxy* proxy, Expression* extends,
3556 FunctionLiteral* constructor, 3562 FunctionLiteral* constructor,
3557 ZoneList<ObjectLiteral::Property*>* properties, 3563 ZoneList<ObjectLiteral::Property*>* properties,
3558 int start_position, int end_position) { 3564 int start_position, int end_position) {
3559 return new (zone_) 3565 return new (zone_)
3560 ClassLiteral(zone_, name, scope, proxy, extends, constructor, 3566 ClassLiteral(zone_, name, scope, proxy, extends, constructor,
3561 properties, start_position, end_position); 3567 properties, start_position, end_position);
(...skipping 15 matching lines...) Expand all
3577 3583
3578 private: 3584 private:
3579 Zone* zone_; 3585 Zone* zone_;
3580 AstValueFactory* ast_value_factory_; 3586 AstValueFactory* ast_value_factory_;
3581 }; 3587 };
3582 3588
3583 3589
3584 } } // namespace v8::internal 3590 } } // namespace v8::internal
3585 3591
3586 #endif // V8_AST_H_ 3592 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast-numbering.cc » ('j') | src/ast-numbering.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698