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

Side by Side Diff: src/parser.cc

Issue 919703003: WIP: Implement ES6 Spread-calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Flag calls as spread calls in parser, error on spread intrinsics/construct calls 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner, 729 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner,
730 AstNodeFactory* factory) { 730 AstNodeFactory* factory) {
731 const AstRawString* symbol = GetSymbol(scanner); 731 const AstRawString* symbol = GetSymbol(scanner);
732 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); 732 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol);
733 return factory->NewStringLiteral(symbol, pos); 733 return factory->NewStringLiteral(symbol, pos);
734 } 734 }
735 735
736 736
737 Expression* ParserTraits::GetIterator(Expression* iterable, 737 Expression* ParserTraits::GetIterator(Expression* iterable,
738 AstNodeFactory* factory) { 738 AstNodeFactory* factory) {
739 Expression* iterator_symbol_literal = 739 return factory->GetIterator(iterable);
740 factory->NewSymbolLiteral("iterator_symbol", RelocInfo::kNoPosition);
741 int pos = iterable->position();
742 Expression* prop =
743 factory->NewProperty(iterable, iterator_symbol_literal, pos);
744 Zone* zone = parser_->zone();
745 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(0, zone);
746 return factory->NewCall(prop, args, pos);
747 } 740 }
748 741
749 742
750 Literal* ParserTraits::GetLiteralTheHole(int position, 743 Literal* ParserTraits::GetLiteralTheHole(int position,
751 AstNodeFactory* factory) { 744 AstNodeFactory* factory) {
752 return factory->NewTheHoleLiteral(RelocInfo::kNoPosition); 745 return factory->NewTheHoleLiteral(RelocInfo::kNoPosition);
753 } 746 }
754 747
755 748
756 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) { 749 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) {
(...skipping 3359 matching lines...) Expand 10 before | Expand all | Expand 10 after
4116 4109
4117 4110
4118 Expression* Parser::ParseV8Intrinsic(bool* ok) { 4111 Expression* Parser::ParseV8Intrinsic(bool* ok) {
4119 // CallRuntime :: 4112 // CallRuntime ::
4120 // '%' Identifier Arguments 4113 // '%' Identifier Arguments
4121 4114
4122 int pos = peek_position(); 4115 int pos = peek_position();
4123 Expect(Token::MOD, CHECK_OK); 4116 Expect(Token::MOD, CHECK_OK);
4124 // Allow "eval" or "arguments" for backward compatibility. 4117 // Allow "eval" or "arguments" for backward compatibility.
4125 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 4118 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
4126 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); 4119 Scanner::Location spread_pos;
4120 ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK);
4121
4122 if (spread_pos.IsValid()) {
4123 // Maybe support spread calls for intrinsics/runtime calls?
4124 ParserTraits::ReportMessageAt(spread_pos, "spreadcall_intrinsic");
4125 *ok = false;
4126 return NULL;
4127 }
4127 4128
4128 if (extension_ != NULL) { 4129 if (extension_ != NULL) {
4129 // The extension structures are only accessible while parsing the 4130 // The extension structures are only accessible while parsing the
4130 // very first time not when reparsing because of lazy compilation. 4131 // very first time not when reparsing because of lazy compilation.
4131 scope_->DeclarationScope()->ForceEagerCompilation(); 4132 scope_->DeclarationScope()->ForceEagerCompilation();
4132 } 4133 }
4133 4134
4134 const Runtime::Function* function = Runtime::FunctionForName(name->string()); 4135 const Runtime::Function* function = Runtime::FunctionForName(name->string());
4135 4136
4136 // Check for built-in IS_VAR macro. 4137 // Check for built-in IS_VAR macro.
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
5419 } else { 5420 } else {
5420 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5421 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5421 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5422 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5422 raw_string->length()); 5423 raw_string->length());
5423 } 5424 }
5424 } 5425 }
5425 5426
5426 return running_hash; 5427 return running_hash;
5427 } 5428 }
5428 } } // namespace v8::internal 5429 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698