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

Side by Side Diff: src/parsing/parser.cc

Issue 2233473002: Redirect most NewUnresolved calls over Parser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 auto constructor_args_name = ast_value_factory()->empty_string(); 268 auto constructor_args_name = ast_value_factory()->empty_string();
269 bool is_duplicate; 269 bool is_duplicate;
270 bool is_rest = true; 270 bool is_rest = true;
271 bool is_optional = false; 271 bool is_optional = false;
272 Variable* constructor_args = function_scope->DeclareParameter( 272 Variable* constructor_args = function_scope->DeclareParameter(
273 constructor_args_name, TEMPORARY, is_optional, is_rest, &is_duplicate, 273 constructor_args_name, TEMPORARY, is_optional, is_rest, &is_duplicate,
274 ast_value_factory()); 274 ast_value_factory());
275 275
276 ZoneList<Expression*>* args = 276 ZoneList<Expression*>* args =
277 new (zone()) ZoneList<Expression*>(2, zone()); 277 new (zone()) ZoneList<Expression*>(2, zone());
278 VariableProxy* this_function_proxy = this->scope()->NewUnresolved( 278 VariableProxy* this_function_proxy = NewUnresolved(
279 factory(), ast_value_factory()->this_function_string(), 279 ast_value_factory()->this_function_string(), Variable::NORMAL, pos);
adamk 2016/08/09 20:11:45 I don't think we want callers like this to have to
280 Variable::NORMAL, pos);
281 ZoneList<Expression*>* tmp = 280 ZoneList<Expression*>* tmp =
282 new (zone()) ZoneList<Expression*>(1, zone()); 281 new (zone()) ZoneList<Expression*>(1, zone());
283 tmp->Add(this_function_proxy, zone()); 282 tmp->Add(this_function_proxy, zone());
284 Expression* super_constructor = factory()->NewCallRuntime( 283 Expression* super_constructor = factory()->NewCallRuntime(
285 Runtime::kInlineGetSuperConstructor, tmp, pos); 284 Runtime::kInlineGetSuperConstructor, tmp, pos);
286 args->Add(super_constructor, zone()); 285 args->Add(super_constructor, zone());
287 Spread* spread_args = factory()->NewSpread( 286 Spread* spread_args = factory()->NewSpread(
288 factory()->NewVariableProxy(constructor_args), pos, pos); 287 factory()->NewVariableProxy(constructor_args), pos, pos);
289 ZoneList<Expression*>* spread_args_expr = 288 ZoneList<Expression*>* spread_args_expr =
290 new (zone()) ZoneList<Expression*>(1, zone()); 289 new (zone()) ZoneList<Expression*>(1, zone());
291 spread_args_expr->Add(spread_args, zone()); 290 spread_args_expr->Add(spread_args, zone());
292 args->AddAll(*PrepareSpreadArguments(spread_args_expr), zone()); 291 args->AddAll(*PrepareSpreadArguments(spread_args_expr), zone());
293 VariableProxy* new_target_proxy = this->scope()->NewUnresolved( 292 VariableProxy* new_target_proxy = NewUnresolved(
294 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, 293 ast_value_factory()->new_target_string(), Variable::NORMAL, pos);
295 pos);
296 args->Add(new_target_proxy, zone()); 294 args->Add(new_target_proxy, zone());
297 CallRuntime* call = factory()->NewCallRuntime( 295 CallRuntime* call = factory()->NewCallRuntime(
298 Context::REFLECT_CONSTRUCT_INDEX, args, pos); 296 Context::REFLECT_CONSTRUCT_INDEX, args, pos);
299 body->Add(factory()->NewReturnStatement(call, pos), zone()); 297 body->Add(factory()->NewReturnStatement(call, pos), zone());
300 } 298 }
301 299
302 materialized_literal_count = function_state.materialized_literal_count(); 300 materialized_literal_count = function_state.materialized_literal_count();
303 expected_property_count = function_state.expected_property_count(); 301 expected_property_count = function_state.expected_property_count();
304 } 302 }
305 303
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 char array[100]; 681 char array[100];
684 const char* string = DoubleToCString(double_value, ArrayVector(array)); 682 const char* string = DoubleToCString(double_value, ArrayVector(array));
685 return parser_->ast_value_factory()->GetOneByteString(string); 683 return parser_->ast_value_factory()->GetOneByteString(string);
686 } 684 }
687 685
688 686
689 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) { 687 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) {
690 return parser_->scanner()->NextSymbol(parser_->ast_value_factory()); 688 return parser_->scanner()->NextSymbol(parser_->ast_value_factory());
691 } 689 }
692 690
693 Expression* ParserTraits::ThisExpression(AstNodeFactory* factory, int pos) { 691 Expression* ParserTraits::ThisExpression(int pos) {
694 return parser_->scope()->NewUnresolved( 692 return parser_->NewUnresolved(parser_->ast_value_factory()->this_string(),
adamk 2016/08/09 20:11:45 I think this is the only caller that should have t
695 factory, parser_->ast_value_factory()->this_string(), Variable::THIS, pos, 693 Variable::THIS, pos, pos + 4);
696 pos + 4);
697 } 694 }
698 695
699 Expression* ParserTraits::NewSuperPropertyReference(AstNodeFactory* factory, 696 Expression* ParserTraits::NewSuperPropertyReference(AstNodeFactory* factory,
700 int pos) { 697 int pos) {
701 // this_function[home_object_symbol] 698 // this_function[home_object_symbol]
702 VariableProxy* this_function_proxy = parser_->scope()->NewUnresolved( 699 VariableProxy* this_function_proxy = parser_->NewUnresolved(
703 factory, parser_->ast_value_factory()->this_function_string(), 700 parser_->ast_value_factory()->this_function_string(), Variable::NORMAL,
704 Variable::NORMAL, pos); 701 pos);
705 Expression* home_object_symbol_literal = 702 Expression* home_object_symbol_literal =
706 factory->NewSymbolLiteral("home_object_symbol", kNoSourcePosition); 703 factory->NewSymbolLiteral("home_object_symbol", kNoSourcePosition);
707 Expression* home_object = factory->NewProperty( 704 Expression* home_object = factory->NewProperty(
708 this_function_proxy, home_object_symbol_literal, pos); 705 this_function_proxy, home_object_symbol_literal, pos);
709 return factory->NewSuperPropertyReference( 706 return factory->NewSuperPropertyReference(
710 ThisExpression(factory, pos)->AsVariableProxy(), home_object, pos); 707 ThisExpression(pos)->AsVariableProxy(), home_object, pos);
711 } 708 }
712 709
713 Expression* ParserTraits::NewSuperCallReference(AstNodeFactory* factory, 710 Expression* ParserTraits::NewSuperCallReference(AstNodeFactory* factory,
714 int pos) { 711 int pos) {
715 VariableProxy* new_target_proxy = parser_->scope()->NewUnresolved( 712 VariableProxy* new_target_proxy = parser_->NewUnresolved(
716 factory, parser_->ast_value_factory()->new_target_string(), 713 parser_->ast_value_factory()->new_target_string(), Variable::NORMAL, pos);
717 Variable::NORMAL, pos); 714 VariableProxy* this_function_proxy = parser_->NewUnresolved(
718 VariableProxy* this_function_proxy = parser_->scope()->NewUnresolved( 715 parser_->ast_value_factory()->this_function_string(), Variable::NORMAL,
719 factory, parser_->ast_value_factory()->this_function_string(), 716 pos);
720 Variable::NORMAL, pos); 717 return factory->NewSuperCallReference(ThisExpression(pos)->AsVariableProxy(),
721 return factory->NewSuperCallReference( 718 new_target_proxy, this_function_proxy,
722 ThisExpression(factory, pos)->AsVariableProxy(), new_target_proxy, 719 pos);
723 this_function_proxy, pos);
724 } 720 }
725 721
726 Expression* ParserTraits::NewTargetExpression(AstNodeFactory* factory, 722 Expression* ParserTraits::NewTargetExpression(int pos) {
727 int pos) {
728 static const int kNewTargetStringLength = 10; 723 static const int kNewTargetStringLength = 10;
729 auto proxy = parser_->scope()->NewUnresolved( 724 auto proxy = parser_->NewUnresolved(
730 factory, parser_->ast_value_factory()->new_target_string(), 725 parser_->ast_value_factory()->new_target_string(), Variable::NORMAL, pos,
731 Variable::NORMAL, pos, pos + kNewTargetStringLength); 726 pos + kNewTargetStringLength);
732 proxy->set_is_new_target(); 727 proxy->set_is_new_target();
733 return proxy; 728 return proxy;
734 } 729 }
735 730
736 Expression* ParserTraits::FunctionSentExpression(AstNodeFactory* factory, 731 Expression* ParserTraits::FunctionSentExpression(AstNodeFactory* factory,
737 int pos) { 732 int pos) {
738 // We desugar function.sent into %_GeneratorGetInputOrDebugPos(generator). 733 // We desugar function.sent into %_GeneratorGetInputOrDebugPos(generator).
739 Zone* zone = parser_->zone(); 734 Zone* zone = parser_->zone();
740 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(1, zone); 735 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(1, zone);
741 VariableProxy* generator = factory->NewVariableProxy( 736 VariableProxy* generator = factory->NewVariableProxy(
(...skipping 22 matching lines...) Expand all
764 bool has_dot = scanner->ContainsDot(); 759 bool has_dot = scanner->ContainsDot();
765 double value = scanner->DoubleValue(); 760 double value = scanner->DoubleValue();
766 return factory->NewNumberLiteral(value, pos, has_dot); 761 return factory->NewNumberLiteral(value, pos, has_dot);
767 } 762 }
768 default: 763 default:
769 DCHECK(false); 764 DCHECK(false);
770 } 765 }
771 return NULL; 766 return NULL;
772 } 767 }
773 768
774
775 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name, 769 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name,
776 int start_position, 770 int start_position,
777 int end_position, 771 int end_position) {
778 AstNodeFactory* factory) {
779 if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name); 772 if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name);
780 return parser_->scope()->NewUnresolved(factory, name, Variable::NORMAL, 773 return parser_->NewUnresolved(name, Variable::NORMAL, start_position,
781 start_position, end_position); 774 end_position);
782 } 775 }
783 776
784 777
785 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner, 778 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner,
786 AstNodeFactory* factory) { 779 AstNodeFactory* factory) {
787 const AstRawString* symbol = GetSymbol(scanner); 780 const AstRawString* symbol = GetSymbol(scanner);
788 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); 781 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol);
789 return factory->NewStringLiteral(symbol, pos); 782 return factory->NewStringLiteral(symbol, pos);
790 } 783 }
791 784
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 1933
1941 case Token::TRY: 1934 case Token::TRY:
1942 return ParseTryStatement(ok); 1935 return ParseTryStatement(ok);
1943 1936
1944 default: 1937 default:
1945 UNREACHABLE(); 1938 UNREACHABLE();
1946 return NULL; 1939 return NULL;
1947 } 1940 }
1948 } 1941 }
1949 1942
1950
1951 VariableProxy* Parser::NewUnresolved(const AstRawString* name, 1943 VariableProxy* Parser::NewUnresolved(const AstRawString* name,
1952 VariableMode mode) { 1944 Variable::Kind kind, int begin_pos,
1945 int end_pos, VariableMode mode) {
1953 // If we are inside a function, a declaration of a 'var' variable is a 1946 // If we are inside a function, a declaration of a 'var' variable is a
1954 // truly local variable, and the scope of the variable is always the function 1947 // truly local variable, and the scope of the variable is always the function
1955 // scope. 1948 // scope.
1956 // Let/const variables are always added to the immediately enclosing scope. 1949 // Let/const variables are always added to the immediately enclosing scope.
1957 Scope* scope = 1950 Scope* scope =
1958 IsLexicalVariableMode(mode) ? this->scope() : GetDeclarationScope(); 1951 IsLexicalVariableMode(mode) ? this->scope() : GetDeclarationScope();
1959 return scope->NewUnresolved(factory(), name, Variable::NORMAL, 1952 return scope->NewUnresolved(factory(), name, kind, begin_pos, end_pos);
1960 scanner()->location().beg_pos, 1953 }
1961 scanner()->location().end_pos); 1954
1955 VariableProxy* Parser::NewUnresolved(const AstRawString* name,
1956 VariableMode mode) {
1957 return NewUnresolved(name, Variable::NORMAL, scanner()->location().beg_pos,
Toon Verwaest 2016/08/09 19:20:03 Not exactly sure about redirecting this through th
1958 scanner()->location().end_pos, mode);
1962 } 1959 }
1963 1960
1964 InitializationFlag Parser::DefaultInitializationFlag(VariableMode mode) { 1961 InitializationFlag Parser::DefaultInitializationFlag(VariableMode mode) {
1965 DCHECK(IsDeclaredVariableMode(mode)); 1962 DCHECK(IsDeclaredVariableMode(mode));
1966 return mode == VAR ? kCreatedInitialized : kNeedsInitialization; 1963 return mode == VAR ? kCreatedInitialized : kNeedsInitialization;
1967 } 1964 }
1968 1965
1969 Declaration* Parser::DeclareVariable(const AstRawString* name, 1966 Declaration* Parser::DeclareVariable(const AstRawString* name,
1970 VariableMode mode, int pos, bool* ok) { 1967 VariableMode mode, int pos, bool* ok) {
1971 return DeclareVariable(name, mode, DefaultInitializationFlag(mode), pos, ok); 1968 return DeclareVariable(name, mode, DefaultInitializationFlag(mode), pos, ok);
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 Scanner::Location loc = scanner()->location(); 2706 Scanner::Location loc = scanner()->location();
2710 2707
2711 Token::Value tok = peek(); 2708 Token::Value tok = peek();
2712 Statement* result; 2709 Statement* result;
2713 Expression* return_value; 2710 Expression* return_value;
2714 if (scanner()->HasAnyLineTerminatorBeforeNext() || 2711 if (scanner()->HasAnyLineTerminatorBeforeNext() ||
2715 tok == Token::SEMICOLON || 2712 tok == Token::SEMICOLON ||
2716 tok == Token::RBRACE || 2713 tok == Token::RBRACE ||
2717 tok == Token::EOS) { 2714 tok == Token::EOS) {
2718 if (IsSubclassConstructor(function_state_->kind())) { 2715 if (IsSubclassConstructor(function_state_->kind())) {
2719 return_value = ThisExpression(factory(), loc.beg_pos); 2716 return_value = ThisExpression(loc.beg_pos);
2720 } else { 2717 } else {
2721 return_value = GetLiteralUndefined(position()); 2718 return_value = GetLiteralUndefined(position());
2722 } 2719 }
2723 } else { 2720 } else {
2724 int pos = peek_position(); 2721 int pos = peek_position();
2725 2722
2726 if (IsSubclassConstructor(function_state_->kind())) { 2723 if (IsSubclassConstructor(function_state_->kind())) {
2727 // Because of the return code rewriting that happens in case of a subclass 2724 // Because of the return code rewriting that happens in case of a subclass
2728 // constructor we don't want to accept tail calls, therefore we don't set 2725 // constructor we don't want to accept tail calls, therefore we don't set
2729 // ReturnExprScope to kInsideValidReturnStatement here. 2726 // ReturnExprScope to kInsideValidReturnStatement here.
(...skipping 26 matching lines...) Expand all
2756 Expression* is_object_conditional = factory()->NewConditional( 2753 Expression* is_object_conditional = factory()->NewConditional(
2757 is_spec_object_call, factory()->NewVariableProxy(temp), 2754 is_spec_object_call, factory()->NewVariableProxy(temp),
2758 factory()->NewSmiLiteral(1, pos), pos); 2755 factory()->NewSmiLiteral(1, pos), pos);
2759 2756
2760 // temp === undefined 2757 // temp === undefined
2761 Expression* is_undefined = factory()->NewCompareOperation( 2758 Expression* is_undefined = factory()->NewCompareOperation(
2762 Token::EQ_STRICT, assign, 2759 Token::EQ_STRICT, assign,
2763 factory()->NewUndefinedLiteral(kNoSourcePosition), pos); 2760 factory()->NewUndefinedLiteral(kNoSourcePosition), pos);
2764 2761
2765 // is_undefined ? this : is_object_conditional 2762 // is_undefined ? this : is_object_conditional
2766 return_value = factory()->NewConditional(is_undefined, 2763 return_value = factory()->NewConditional(
2767 ThisExpression(factory(), pos), 2764 is_undefined, ThisExpression(pos), is_object_conditional, pos);
2768 is_object_conditional, pos);
2769 } else { 2765 } else {
2770 ReturnExprScope maybe_allow_tail_calls( 2766 ReturnExprScope maybe_allow_tail_calls(
2771 function_state_, ReturnExprContext::kInsideValidReturnStatement); 2767 function_state_, ReturnExprContext::kInsideValidReturnStatement);
2772 return_value = ParseExpression(true, CHECK_OK); 2768 return_value = ParseExpression(true, CHECK_OK);
2773 2769
2774 if (allow_tailcalls() && !is_sloppy(language_mode())) { 2770 if (allow_tailcalls() && !is_sloppy(language_mode())) {
2775 // ES6 14.6.1 Static Semantics: IsInTailPosition 2771 // ES6 14.6.1 Static Semantics: IsInTailPosition
2776 function_state_->AddImplicitTailCallExpression(return_value); 2772 function_state_->AddImplicitTailCallExpression(return_value);
2777 } 2773 }
2778 } 2774 }
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after
4751 4747
4752 block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 4748 block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
4753 block->statements()->Add(try_catch_statement, zone()); 4749 block->statements()->Add(try_catch_statement, zone());
4754 return block; 4750 return block;
4755 } 4751 }
4756 4752
4757 Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) { 4753 Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) {
4758 DCHECK_NOT_NULL(function_state_->generator_object_variable()); 4754 DCHECK_NOT_NULL(function_state_->generator_object_variable());
4759 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); 4755 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone());
4760 args->Add(factory()->NewThisFunction(pos), zone()); 4756 args->Add(factory()->NewThisFunction(pos), zone());
4761 args->Add(IsArrowFunction(kind) 4757 args->Add(IsArrowFunction(kind) ? GetLiteralUndefined(pos)
4762 ? GetLiteralUndefined(pos) 4758 : ThisExpression(kNoSourcePosition),
4763 : ThisExpression(factory(), kNoSourcePosition),
4764 zone()); 4759 zone());
4765 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, 4760 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args,
4766 pos); 4761 pos);
4767 } 4762 }
4768 4763
4769 Expression* Parser::BuildPromiseResolve(Expression* value, int pos) { 4764 Expression* Parser::BuildPromiseResolve(Expression* value, int pos) {
4770 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); 4765 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
4771 args->Add(value, zone()); 4766 args->Add(value, zone());
4772 return factory()->NewCallRuntime(Context::PROMISE_CREATE_RESOLVED_INDEX, args, 4767 return factory()->NewCallRuntime(Context::PROMISE_CREATE_RESOLVED_INDEX, args,
4773 pos); 4768 pos);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
4874 } else if (IsAsyncFunction(kind)) { 4869 } else if (IsAsyncFunction(kind)) {
4875 const bool accept_IN = true; 4870 const bool accept_IN = true;
4876 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind, 4871 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind,
4877 FunctionBody::Normal, accept_IN, pos, CHECK_OK); 4872 FunctionBody::Normal, accept_IN, pos, CHECK_OK);
4878 } else { 4873 } else {
4879 ParseStatementList(body, Token::RBRACE, CHECK_OK); 4874 ParseStatementList(body, Token::RBRACE, CHECK_OK);
4880 } 4875 }
4881 4876
4882 if (IsSubclassConstructor(kind)) { 4877 if (IsSubclassConstructor(kind)) {
4883 body->Add(factory()->NewReturnStatement( 4878 body->Add(factory()->NewReturnStatement(
4884 this->ThisExpression(factory(), kNoSourcePosition), 4879 this->ThisExpression(kNoSourcePosition), kNoSourcePosition),
4885 kNoSourcePosition),
4886 zone()); 4880 zone());
4887 } 4881 }
4888 } 4882 }
4889 4883
4890 Expect(Token::RBRACE, CHECK_OK); 4884 Expect(Token::RBRACE, CHECK_OK);
4891 scope()->set_end_position(scanner()->location().end_pos); 4885 scope()->set_end_position(scanner()->location().end_pos);
4892 4886
4893 if (!parameters.is_simple) { 4887 if (!parameters.is_simple) {
4894 DCHECK_NOT_NULL(inner_scope); 4888 DCHECK_NOT_NULL(inner_scope);
4895 DCHECK_EQ(function_scope, scope()); 4889 DCHECK_EQ(function_scope, scope());
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
5693 Expression* super_constructor = factory()->NewCallRuntime( 5687 Expression* super_constructor = factory()->NewCallRuntime(
5694 Runtime::kInlineGetSuperConstructor, tmp, pos); 5688 Runtime::kInlineGetSuperConstructor, tmp, pos);
5695 args->InsertAt(0, super_constructor, zone()); 5689 args->InsertAt(0, super_constructor, zone());
5696 args->Add(function->AsSuperCallReference()->new_target_var(), zone()); 5690 args->Add(function->AsSuperCallReference()->new_target_var(), zone());
5697 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, 5691 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args,
5698 pos); 5692 pos);
5699 } else { 5693 } else {
5700 if (function->IsProperty()) { 5694 if (function->IsProperty()) {
5701 // Method calls 5695 // Method calls
5702 if (function->AsProperty()->IsSuperAccess()) { 5696 if (function->AsProperty()->IsSuperAccess()) {
5703 Expression* home = ThisExpression(factory(), kNoSourcePosition); 5697 Expression* home = ThisExpression(kNoSourcePosition);
5704 args->InsertAt(0, function, zone()); 5698 args->InsertAt(0, function, zone());
5705 args->InsertAt(1, home, zone()); 5699 args->InsertAt(1, home, zone());
5706 } else { 5700 } else {
5707 Variable* temp = NewTemporary(ast_value_factory()->empty_string()); 5701 Variable* temp = NewTemporary(ast_value_factory()->empty_string());
5708 VariableProxy* obj = factory()->NewVariableProxy(temp); 5702 VariableProxy* obj = factory()->NewVariableProxy(temp);
5709 Assignment* assign_obj = factory()->NewAssignment( 5703 Assignment* assign_obj = factory()->NewAssignment(
5710 Token::ASSIGN, obj, function->AsProperty()->obj(), 5704 Token::ASSIGN, obj, function->AsProperty()->obj(),
5711 kNoSourcePosition); 5705 kNoSourcePosition);
5712 function = factory()->NewProperty( 5706 function = factory()->NewProperty(
5713 assign_obj, function->AsProperty()->key(), kNoSourcePosition); 5707 assign_obj, function->AsProperty()->key(), kNoSourcePosition);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5938 5932
5939 Expression* Parser::RewriteAssignExponentiation(Expression* left, 5933 Expression* Parser::RewriteAssignExponentiation(Expression* left,
5940 Expression* right, int pos) { 5934 Expression* right, int pos) {
5941 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); 5935 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone());
5942 if (left->IsVariableProxy()) { 5936 if (left->IsVariableProxy()) {
5943 VariableProxy* lhs = left->AsVariableProxy(); 5937 VariableProxy* lhs = left->AsVariableProxy();
5944 5938
5945 Expression* result; 5939 Expression* result;
5946 DCHECK_NOT_NULL(lhs->raw_name()); 5940 DCHECK_NOT_NULL(lhs->raw_name());
5947 result = this->ExpressionFromIdentifier(lhs->raw_name(), lhs->position(), 5941 result = this->ExpressionFromIdentifier(lhs->raw_name(), lhs->position(),
5948 lhs->end_position(), factory()); 5942 lhs->end_position());
5949 args->Add(left, zone()); 5943 args->Add(left, zone());
5950 args->Add(right, zone()); 5944 args->Add(right, zone());
5951 Expression* call = 5945 Expression* call =
5952 factory()->NewCallRuntime(Context::MATH_POW_INDEX, args, pos); 5946 factory()->NewCallRuntime(Context::MATH_POW_INDEX, args, pos);
5953 return factory()->NewAssignment(Token::ASSIGN, result, call, pos); 5947 return factory()->NewAssignment(Token::ASSIGN, result, call, pos);
5954 } else if (left->IsProperty()) { 5948 } else if (left->IsProperty()) {
5955 Property* prop = left->AsProperty(); 5949 Property* prop = left->AsProperty();
5956 auto temp_obj = NewTemporary(ast_value_factory()->empty_string()); 5950 auto temp_obj = NewTemporary(ast_value_factory()->empty_string());
5957 auto temp_key = NewTemporary(ast_value_factory()->empty_string()); 5951 auto temp_key = NewTemporary(ast_value_factory()->empty_string());
5958 Expression* assign_obj = factory()->NewAssignment( 5952 Expression* assign_obj = factory()->NewAssignment(
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
7093 node->Print(Isolate::Current()); 7087 node->Print(Isolate::Current());
7094 } 7088 }
7095 #endif // DEBUG 7089 #endif // DEBUG
7096 7090
7097 #undef CHECK_OK 7091 #undef CHECK_OK
7098 #undef CHECK_OK_VOID 7092 #undef CHECK_OK_VOID
7099 #undef CHECK_FAILED 7093 #undef CHECK_FAILED
7100 7094
7101 } // namespace internal 7095 } // namespace internal
7102 } // namespace v8 7096 } // namespace v8
OLDNEW
« src/parsing/parser.h ('K') | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698