| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index 08941f501f333511f612603e597e627327fc9373..f1633b6dff7db5518ed1ef294bd9fde9b69586a4 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,11 @@ 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);
|
| +
|
| + // TODO(caitp): support intrinsics
|
| + DCHECK(!spread_pos.IsValid());
|
|
|
| if (extension_ != NULL) {
|
| // The extension structures are only accessible while parsing the
|
| @@ -5474,4 +5481,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;
|
| + Expression* thisArg;
|
| +
|
| + if (function->IsProperty()) {
|
| + 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());
|
| + }
|
| + }
|
| +
|
| + 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
|
|
|