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

Unified Diff: src/parser.h

Issue 1287063004: [es6] Implement default parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix TODO Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 4a77d91b0ac859aeb6b938c40c36e4b00d5d37f1..3d907184bce0edf52846d40c7535a166f83d6a08 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -541,10 +541,13 @@ class SingletonLogger;
struct ParserFormalParameters : FormalParametersBase {
struct Parameter {
- Parameter(const AstRawString* name, Expression* pattern, bool is_rest)
- : name(name), pattern(pattern), is_rest(is_rest) {}
+ Parameter(const AstRawString* name, Expression* pattern,
+ Expression* initializer, bool is_rest)
+ : name(name), pattern(pattern), initializer(initializer),
+ is_rest(is_rest) {}
const AstRawString* name;
Expression* pattern;
+ Expression* initializer;
bool is_rest;
};
@@ -779,7 +782,8 @@ class ParserTraits {
FunctionKind kind = kNormalFunction);
V8_INLINE void AddFormalParameter(
- ParserFormalParameters* parameters, Expression* pattern, bool is_rest);
+ ParserFormalParameters* parameters, Expression* pattern,
+ Expression* initializer, bool is_rest);
V8_INLINE void DeclareFormalParameter(
Scope* scope, const ParserFormalParameters::Parameter& parameter,
bool is_simple, ExpressionClassifier* classifier);
@@ -1313,15 +1317,17 @@ Expression* ParserTraits::SpreadCallNew(
void ParserTraits::AddFormalParameter(
- ParserFormalParameters* parameters, Expression* pattern, bool is_rest) {
- bool is_simple = pattern->IsVariableProxy();
+ ParserFormalParameters* parameters,
+ Expression* pattern, Expression* initializer, bool is_rest) {
+ bool is_simple = pattern->IsVariableProxy() && initializer == nullptr;
DCHECK(parser_->allow_harmony_destructuring() ||
- parser_->allow_harmony_rest_parameters() || is_simple);
+ parser_->allow_harmony_rest_parameters() ||
+ parser_->allow_harmony_default_parameters() || is_simple);
const AstRawString* name = is_simple
? pattern->AsVariableProxy()->raw_name()
: parser_->ast_value_factory()->empty_string();
parameters->params.Add(
- ParserFormalParameters::Parameter(name, pattern, is_rest),
+ ParserFormalParameters::Parameter(name, pattern, initializer, is_rest),
parameters->scope->zone());
}
« no previous file with comments | « src/flag-definitions.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698