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

Unified Diff: src/parser.cc

Issue 938443002: [es6] implement spread calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add construct support, clean out some gunk Created 5 years, 10 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
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 08941f501f333511f612603e597e627327fc9373..1808d74bae7d45d15cc12038e0f0c0f3e90b0b6c 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -815,6 +815,7 @@ Parser::Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
set_allow_harmony_computed_property_names(
FLAG_harmony_computed_property_names);
set_allow_harmony_rest_params(FLAG_harmony_rest_parameters);
+ set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls);
set_allow_strong_mode(FLAG_strong_mode);
for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
++feature) {
@@ -4043,6 +4044,8 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
allow_harmony_computed_property_names());
reusable_preparser_->set_allow_harmony_rest_params(
allow_harmony_rest_params());
+ reusable_preparser_->set_allow_harmony_spreadcalls(
+ allow_harmony_spreadcalls());
reusable_preparser_->set_allow_strong_mode(allow_strong_mode());
}
PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
@@ -4154,7 +4157,8 @@ Expression* Parser::ParseV8Intrinsic(bool* ok) {
Expect(Token::MOD, CHECK_OK);
// Allow "eval" or "arguments" for backward compatibility.
const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
- ZoneList<Expression*>* args = ParseArguments(CHECK_OK);
+ Scanner::Location spread_pos;
+ ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK);
if (extension_ != NULL) {
// The extension structures are only accessible while parsing the
@@ -5474,4 +5478,49 @@ uint32_t Parser::ComputeTemplateLiteralHash(const TemplateLiteral* lit) {
return running_hash;
}
+
+
+ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadCallArguments(
+ Expression* function, ZoneList<v8::internal::Expression*>* list) {
+ int length = list->length() + 3;
arv (Not doing code reviews) 2015/02/18 15:07:06 Please add a comment explaining "3 is the magic nu
+ Expression* thisArg;
+
+ if (function->IsProperty()) {
arv (Not doing code reviews) 2015/02/18 15:07:06 TODO: IsSuperReference
+ thisArg = function->AsProperty()->obj();
+ } else {
+ thisArg = factory()->NewUndefinedLiteral(RelocInfo::kNoPosition);
+ }
+ list->InsertAt(0, function, zone());
+ list->InsertAt(1, thisArg, zone());
+ list->InsertAt(2, factory()->NewSmiLiteral(length, RelocInfo::kNoPosition),
+ zone());
+
+ for (int i = 3; i < length; ++i) {
+ Expression* arg = list->at(i);
+ if (arg->IsSpreadOperation()) {
+ list->Add(factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), zone());
arv (Not doing code reviews) 2015/02/18 15:07:06 It is not clear to me what the list contains? I th
caitp (gmail) 2015/02/18 15:32:08 I tried to draw a graph of it in a comment, but it
arv (Not doing code reviews) 2015/02/18 15:36:54 I think this is a really good solution but it is n
+ }
+ }
+
+ return list;
+}
+
+
+ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadCallNewArguments(
+ Expression* function, ZoneList<v8::internal::Expression*>* list) {
+ int length = list->length() + 2;
+
+ list->InsertAt(0, function, zone());
+ list->InsertAt(1, factory()->NewSmiLiteral(length, RelocInfo::kNoPosition),
+ zone());
+
+ for (int i = 2; i < length; ++i) {
+ Expression* arg = list->at(i);
+ if (arg->IsSpreadOperation()) {
+ list->Add(factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), zone());
+ }
+ }
+
+ return list;
+}
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698