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

Unified Diff: src/preparser.h

Issue 387633003: Avoid temporary Vectors for arrow function parameter lists (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 156fd64a2e5db9aa2ea3f7cf8bbe5f75ae97e366..6c6a63ade3d30ba7f5c55aee9aa3dd641f8c0c67 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -1249,11 +1249,13 @@ class PreParserTraits {
bool is_generator, bool* ok);
// Utility functions
- Vector<PreParserIdentifier> ParameterListFromExpression(
- PreParserExpression expression, bool* ok) {
+ unsigned DeclareArrowParametersFromExpression(PreParserExpression expression,
+ PreParserScope* scope,
+ Scanner::Location* dupe_loc,
+ bool* ok) {
// TODO(aperez): Detect duplicated identifiers in paramlists.
*ok = expression.IsValidArrowParamList();
- return Vector<PreParserIdentifier>::empty();
+ return 0;
}
static AstValueFactory* ast_value_factory() { return NULL; }
@@ -2436,16 +2438,6 @@ template <class Traits>
typename ParserBase<Traits>::ExpressionT ParserBase<
Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast,
bool* ok) {
- typename Traits::Type::ParameterIdentifierVector params =
- Traits::ParameterListFromExpression(params_ast, ok);
-
- if (!*ok) {
- ReportMessageAt(Scanner::Location(start_pos, scanner()->location().beg_pos),
- "malformed_arrow_function_parameter_list");
- params.Dispose();
- return this->EmptyExpression();
- }
-
// TODO(aperez): Change this to use ARROW_SCOPE
typename Traits::Type::ScopePtr scope =
this->NewScope(scope_, FUNCTION_SCOPE);
@@ -2453,30 +2445,25 @@ typename ParserBase<Traits>::ExpressionT ParserBase<
FunctionState function_state(&function_state_, &scope_, &scope, zone(),
this->ast_value_factory());
Scanner::Location dupe_error_loc = Scanner::Location::invalid();
+ unsigned num_params = Traits::DeclareArrowParametersFromExpression(
+ params_ast, scope_, &dupe_error_loc, ok);
+ if (!*ok) {
+ ReportMessageAt(Scanner::Location(start_pos, scanner()->location().beg_pos),
+ "malformed_arrow_function_parameter_list");
+ return this->EmptyExpression();
+ }
- if (params.length() > Code::kMaxArguments) {
+ if (num_params > Code::kMaxArguments) {
ReportMessageAt(Scanner::Location(params_ast->position(), position()),
"too_many_parameters");
*ok = false;
- params.Dispose();
return this->EmptyExpression();
}
- for (int i = 0; i < params.length(); ++i) {
- const IdentifierT param_name = params.at(i)->raw_name();
- if (!dupe_error_loc.IsValid() && scope_->IsDeclared(param_name)) {
- int param_pos = params.at(i)->position();
- dupe_error_loc =
- Scanner::Location(param_pos, param_pos + param_name->length());
- }
- scope_->DeclareParameter(param_name, VAR);
- }
-
ExpressionT expression = ParseArrowFunctionLiteralBody(
- &function_state, scope, params.length(), Scanner::Location::invalid(),
+ &function_state, scope, num_params, Scanner::Location::invalid(),
dupe_error_loc, Scanner::Location::invalid(),
FunctionLiteral::kNotParenthesized, start_pos, CHECK_OK);
- params.Dispose();
return expression;
}
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698