Index: src/parser.h |
diff --git a/src/parser.h b/src/parser.h |
index 1974f296f0756b0739ff6970453d1cbad7534a9a..046d580bc0047bbce62b7519c35e1d4cf5371e49 100644 |
--- a/src/parser.h |
+++ b/src/parser.h |
@@ -558,6 +558,8 @@ struct ParserFormalParameters : public PreParserFormalParameters { |
params.Add(Parameter(name, pattern, is_rest), scope->zone()); |
DCHECK(arity == params.length()); |
adamk
2015/08/03 18:43:51
This code could be responsible for keeping arity i
|
} |
+ |
+ const Parameter& at(int i) { return params[i]; } |
}; |
@@ -782,13 +784,19 @@ class ParserTraits { |
V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
FunctionKind kind = kNormalFunction); |
+ V8_INLINE void AddFormalParameter( |
+ ParserFormalParameters* parameters, Expression* pattern, bool is_rest); |
V8_INLINE void DeclareFormalParameter( |
- ParserFormalParameters* parameters, Expression* pattern, bool is_rest, |
- ExpressionClassifier* classifier); |
+ Scope* scope, const ParserFormalParameters::Parameter& parameter, |
+ bool is_simple, ExpressionClassifier* classifier); |
void ParseArrowFunctionFormalParameters( |
ParserFormalParameters* parameters, Expression* params, |
const Scanner::Location& params_loc, |
Scanner::Location* duplicate_loc, bool* ok); |
+ void ParseArrowFunctionFormalParameterList( |
+ ParserFormalParameters* parameters, Expression* params, |
+ const Scanner::Location& params_loc, |
+ Scanner::Location* duplicate_loc, bool* ok); |
void ReindexLiterals(const ParserFormalParameters& parameters); |
@@ -1311,24 +1319,33 @@ Expression* ParserTraits::SpreadCallNew( |
} |
-void ParserTraits::DeclareFormalParameter( |
- ParserFormalParameters* parameters, Expression* pattern, bool is_rest, |
- ExpressionClassifier* classifier) { |
- bool is_duplicate = false; |
+void ParserTraits::AddFormalParameter( |
+ ParserFormalParameters* parameters, Expression* pattern, bool is_rest) { |
bool is_simple = pattern->IsVariableProxy(); |
- DCHECK(parser_->allow_harmony_destructuring() || is_simple); |
- |
+ DCHECK(parser_->allow_harmony_destructuring() || |
+ parser_->allow_harmony_rest_parameters() || is_simple); |
const AstRawString* name = is_simple |
? pattern->AsVariableProxy()->raw_name() |
: parser_->ast_value_factory()->empty_string(); |
- Variable* var = |
- parameters->scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); |
- parameters->AddParameter(name, is_simple ? nullptr : pattern, is_rest); |
+ parameters->AddParameter(name, pattern, is_rest); |
+ DCHECK(parameters->arity == parameters->params.length()); |
adamk
2015/08/03 18:43:52
Nit: DCHECK_EQ
rossberg
2015/08/04 15:31:19
Done.
|
+} |
+ |
+ |
+void ParserTraits::DeclareFormalParameter( |
+ Scope* scope, const ParserFormalParameters::Parameter& parameter, |
+ bool is_simple, ExpressionClassifier* classifier) { |
+ bool is_duplicate = false; |
+ Variable* var = scope->DeclareParameter( |
+ // TODO(caitp): Remove special handling for rest once desugaring is in. |
+ is_simple || parameter.is_rest |
+ ? parameter.name : parser_->ast_value_factory()->empty_string(), |
+ VAR, parameter.is_rest, &is_duplicate); |
if (is_duplicate) { |
classifier->RecordDuplicateFormalParameterError( |
parser_->scanner()->location()); |
} |
- if (is_sloppy(parameters->scope->language_mode())) { |
+ if (is_sloppy(scope->language_mode())) { |
// TODO(sigurds) Mark every parameter as maybe assigned. This is a |
// conservative approximation necessary to account for parameters |
// that are assigned via the arguments array. |