OLD | NEW |
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/parser.h" | 5 #include "src/parser.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/ast-literal-reindexer.h" | 9 #include "src/ast-literal-reindexer.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2215 // TODO(1240846): It's weird that native function declarations are | 2215 // TODO(1240846): It's weird that native function declarations are |
2216 // introduced dynamically when we meet their declarations, whereas | 2216 // introduced dynamically when we meet their declarations, whereas |
2217 // other functions are set up when entering the surrounding scope. | 2217 // other functions are set up when entering the surrounding scope. |
2218 VariableProxy* proxy = NewUnresolved(name, VAR); | 2218 VariableProxy* proxy = NewUnresolved(name, VAR); |
2219 Declaration* declaration = | 2219 Declaration* declaration = |
2220 factory()->NewVariableDeclaration(proxy, VAR, scope_, pos); | 2220 factory()->NewVariableDeclaration(proxy, VAR, scope_, pos); |
2221 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); | 2221 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); |
2222 NativeFunctionLiteral* lit = factory()->NewNativeFunctionLiteral( | 2222 NativeFunctionLiteral* lit = factory()->NewNativeFunctionLiteral( |
2223 name, extension_, RelocInfo::kNoPosition); | 2223 name, extension_, RelocInfo::kNoPosition); |
2224 return factory()->NewExpressionStatement( | 2224 return factory()->NewExpressionStatement( |
2225 factory()->NewAssignment( | 2225 factory()->NewAssignment(Token::INIT, proxy, lit, RelocInfo::kNoPosition), |
2226 Token::INIT_VAR, proxy, lit, RelocInfo::kNoPosition), | |
2227 pos); | 2226 pos); |
2228 } | 2227 } |
2229 | 2228 |
2230 | 2229 |
2231 Statement* Parser::ParseFunctionDeclaration( | 2230 Statement* Parser::ParseFunctionDeclaration( |
2232 ZoneList<const AstRawString*>* names, bool* ok) { | 2231 ZoneList<const AstRawString*>* names, bool* ok) { |
2233 // FunctionDeclaration :: | 2232 // FunctionDeclaration :: |
2234 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' | 2233 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' |
2235 // GeneratorDeclaration :: | 2234 // GeneratorDeclaration :: |
2236 // 'function' '*' Identifier '(' FormalParameterListopt ')' | 2235 // 'function' '*' Identifier '(' FormalParameterListopt ')' |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 // this happens e.g., for lazy methods. They are excluded from strong mode | 2333 // this happens e.g., for lazy methods. They are excluded from strong mode |
2335 // checks for now. TODO(marja, rossberg): re-create variables with the | 2334 // checks for now. TODO(marja, rossberg): re-create variables with the |
2336 // correct Kind and remove this hack. | 2335 // correct Kind and remove this hack. |
2337 value->class_variable_proxy() | 2336 value->class_variable_proxy() |
2338 ->var() | 2337 ->var() |
2339 ->AsClassVariable() | 2338 ->AsClassVariable() |
2340 ->set_declaration_group_start( | 2339 ->set_declaration_group_start( |
2341 outer_class_variable->AsClassVariable()->declaration_group_start()); | 2340 outer_class_variable->AsClassVariable()->declaration_group_start()); |
2342 } | 2341 } |
2343 | 2342 |
2344 Token::Value init_op = | 2343 Assignment* assignment = |
2345 is_strong(language_mode()) ? Token::INIT_CONST : Token::INIT_LET; | 2344 factory()->NewAssignment(Token::INIT, proxy, value, pos); |
2346 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); | |
2347 Statement* assignment_statement = | 2345 Statement* assignment_statement = |
2348 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 2346 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
2349 if (names) names->Add(name, zone()); | 2347 if (names) names->Add(name, zone()); |
2350 return assignment_statement; | 2348 return assignment_statement; |
2351 } | 2349 } |
2352 | 2350 |
2353 | 2351 |
2354 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { | 2352 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { |
2355 if (is_strict(language_mode()) || allow_harmony_sloppy()) { | 2353 if (is_strict(language_mode()) || allow_harmony_sloppy()) { |
2356 return ParseScopedBlock(labels, ok); | 2354 return ParseScopedBlock(labels, ok); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 parsing_result->descriptor.declaration_kind = DeclarationDescriptor::NORMAL; | 2479 parsing_result->descriptor.declaration_kind = DeclarationDescriptor::NORMAL; |
2482 parsing_result->descriptor.declaration_pos = peek_position(); | 2480 parsing_result->descriptor.declaration_pos = peek_position(); |
2483 parsing_result->descriptor.initialization_pos = peek_position(); | 2481 parsing_result->descriptor.initialization_pos = peek_position(); |
2484 parsing_result->descriptor.mode = VAR; | 2482 parsing_result->descriptor.mode = VAR; |
2485 // True if the binding needs initialization. 'let' and 'const' declared | 2483 // True if the binding needs initialization. 'let' and 'const' declared |
2486 // bindings are created uninitialized by their declaration nodes and | 2484 // bindings are created uninitialized by their declaration nodes and |
2487 // need initialization. 'var' declared bindings are always initialized | 2485 // need initialization. 'var' declared bindings are always initialized |
2488 // immediately by their declaration nodes. | 2486 // immediately by their declaration nodes. |
2489 parsing_result->descriptor.needs_init = false; | 2487 parsing_result->descriptor.needs_init = false; |
2490 parsing_result->descriptor.is_const = false; | 2488 parsing_result->descriptor.is_const = false; |
2491 parsing_result->descriptor.init_op = Token::INIT_VAR; | |
2492 if (peek() == Token::VAR) { | 2489 if (peek() == Token::VAR) { |
2493 if (is_strong(language_mode())) { | 2490 if (is_strong(language_mode())) { |
2494 Scanner::Location location = scanner()->peek_location(); | 2491 Scanner::Location location = scanner()->peek_location(); |
2495 ReportMessageAt(location, MessageTemplate::kStrongVar); | 2492 ReportMessageAt(location, MessageTemplate::kStrongVar); |
2496 *ok = false; | 2493 *ok = false; |
2497 return; | 2494 return; |
2498 } | 2495 } |
2499 Consume(Token::VAR); | 2496 Consume(Token::VAR); |
2500 } else if (peek() == Token::CONST && allow_const()) { | 2497 } else if (peek() == Token::CONST && allow_const()) { |
2501 Consume(Token::CONST); | 2498 Consume(Token::CONST); |
2502 if (is_sloppy(language_mode()) && allow_legacy_const()) { | 2499 if (is_sloppy(language_mode()) && allow_legacy_const()) { |
2503 parsing_result->descriptor.mode = CONST_LEGACY; | 2500 parsing_result->descriptor.mode = CONST_LEGACY; |
2504 parsing_result->descriptor.init_op = Token::INIT_CONST_LEGACY; | |
2505 ++use_counts_[v8::Isolate::kLegacyConst]; | 2501 ++use_counts_[v8::Isolate::kLegacyConst]; |
2506 } else { | 2502 } else { |
2507 DCHECK(is_strict(language_mode()) || allow_harmony_sloppy()); | 2503 DCHECK(is_strict(language_mode()) || allow_harmony_sloppy()); |
2508 DCHECK(var_context != kStatement); | 2504 DCHECK(var_context != kStatement); |
2509 parsing_result->descriptor.mode = CONST; | 2505 parsing_result->descriptor.mode = CONST; |
2510 parsing_result->descriptor.init_op = Token::INIT_CONST; | |
2511 } | 2506 } |
2512 parsing_result->descriptor.is_const = true; | 2507 parsing_result->descriptor.is_const = true; |
2513 parsing_result->descriptor.needs_init = true; | 2508 parsing_result->descriptor.needs_init = true; |
2514 } else if (peek() == Token::LET && allow_let()) { | 2509 } else if (peek() == Token::LET && allow_let()) { |
2515 Consume(Token::LET); | 2510 Consume(Token::LET); |
2516 DCHECK(var_context != kStatement); | 2511 DCHECK(var_context != kStatement); |
2517 parsing_result->descriptor.mode = LET; | 2512 parsing_result->descriptor.mode = LET; |
2518 parsing_result->descriptor.needs_init = true; | 2513 parsing_result->descriptor.needs_init = true; |
2519 parsing_result->descriptor.init_op = Token::INIT_LET; | |
2520 } else { | 2514 } else { |
2521 UNREACHABLE(); // by current callers | 2515 UNREACHABLE(); // by current callers |
2522 } | 2516 } |
2523 | 2517 |
2524 parsing_result->descriptor.declaration_scope = | 2518 parsing_result->descriptor.declaration_scope = |
2525 DeclarationScope(parsing_result->descriptor.mode); | 2519 DeclarationScope(parsing_result->descriptor.mode); |
2526 parsing_result->descriptor.scope = scope_; | 2520 parsing_result->descriptor.scope = scope_; |
2527 parsing_result->descriptor.hoist_scope = nullptr; | 2521 parsing_result->descriptor.hoist_scope = nullptr; |
2528 | 2522 |
2529 | 2523 |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; | 3200 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; |
3207 descriptor.parser = this; | 3201 descriptor.parser = this; |
3208 descriptor.declaration_scope = scope_; | 3202 descriptor.declaration_scope = scope_; |
3209 descriptor.scope = scope_; | 3203 descriptor.scope = scope_; |
3210 descriptor.hoist_scope = nullptr; | 3204 descriptor.hoist_scope = nullptr; |
3211 descriptor.mode = LET; | 3205 descriptor.mode = LET; |
3212 descriptor.is_const = false; | 3206 descriptor.is_const = false; |
3213 descriptor.needs_init = true; | 3207 descriptor.needs_init = true; |
3214 descriptor.declaration_pos = pattern->position(); | 3208 descriptor.declaration_pos = pattern->position(); |
3215 descriptor.initialization_pos = pattern->position(); | 3209 descriptor.initialization_pos = pattern->position(); |
3216 descriptor.init_op = Token::INIT_LET; | |
3217 | 3210 |
3218 DeclarationParsingResult::Declaration decl( | 3211 DeclarationParsingResult::Declaration decl( |
3219 pattern, pattern->position(), | 3212 pattern, pattern->position(), |
3220 factory()->NewVariableProxy(catch_variable)); | 3213 factory()->NewVariableProxy(catch_variable)); |
3221 | 3214 |
3222 PatternRewriter::DeclareAndInitializeVariables( | 3215 PatternRewriter::DeclareAndInitializeVariables( |
3223 catch_block, &descriptor, &decl, nullptr, CHECK_OK); | 3216 catch_block, &descriptor, &decl, nullptr, CHECK_OK); |
3224 } | 3217 } |
3225 | 3218 |
3226 Expect(Token::LBRACE, CHECK_OK); | 3219 Expect(Token::LBRACE, CHECK_OK); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3533 // For each let variable x: | 3526 // For each let variable x: |
3534 // make statement: let/const x = temp_x. | 3527 // make statement: let/const x = temp_x. |
3535 VariableMode mode = is_const ? CONST : LET; | 3528 VariableMode mode = is_const ? CONST : LET; |
3536 for (int i = 0; i < names->length(); i++) { | 3529 for (int i = 0; i < names->length(); i++) { |
3537 VariableProxy* proxy = NewUnresolved(names->at(i), mode); | 3530 VariableProxy* proxy = NewUnresolved(names->at(i), mode); |
3538 Declaration* declaration = factory()->NewVariableDeclaration( | 3531 Declaration* declaration = factory()->NewVariableDeclaration( |
3539 proxy, mode, scope_, RelocInfo::kNoPosition); | 3532 proxy, mode, scope_, RelocInfo::kNoPosition); |
3540 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); | 3533 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); |
3541 inner_vars.Add(declaration->proxy()->var(), zone()); | 3534 inner_vars.Add(declaration->proxy()->var(), zone()); |
3542 VariableProxy* temp_proxy = factory()->NewVariableProxy(temps.at(i)); | 3535 VariableProxy* temp_proxy = factory()->NewVariableProxy(temps.at(i)); |
3543 Assignment* assignment = | 3536 Assignment* assignment = factory()->NewAssignment( |
3544 factory()->NewAssignment(is_const ? Token::INIT_CONST : Token::INIT_LET, | 3537 Token::INIT, proxy, temp_proxy, RelocInfo::kNoPosition); |
3545 proxy, temp_proxy, RelocInfo::kNoPosition); | |
3546 Statement* assignment_statement = | 3538 Statement* assignment_statement = |
3547 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 3539 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
3548 DCHECK(init->position() != RelocInfo::kNoPosition); | 3540 DCHECK(init->position() != RelocInfo::kNoPosition); |
3549 proxy->var()->set_initializer_position(init->position()); | 3541 proxy->var()->set_initializer_position(init->position()); |
3550 ignore_completion_block->statements()->Add(assignment_statement, zone()); | 3542 ignore_completion_block->statements()->Add(assignment_statement, zone()); |
3551 } | 3543 } |
3552 | 3544 |
3553 // Make statement: if (first == 1) { first = 0; } else { next; } | 3545 // Make statement: if (first == 1) { first = 0; } else { next; } |
3554 if (next) { | 3546 if (next) { |
3555 DCHECK(first); | 3547 DCHECK(first); |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4579 descriptor.declaration_kind = DeclarationDescriptor::PARAMETER; | 4571 descriptor.declaration_kind = DeclarationDescriptor::PARAMETER; |
4580 descriptor.parser = this; | 4572 descriptor.parser = this; |
4581 descriptor.declaration_scope = scope_; | 4573 descriptor.declaration_scope = scope_; |
4582 descriptor.scope = scope_; | 4574 descriptor.scope = scope_; |
4583 descriptor.hoist_scope = nullptr; | 4575 descriptor.hoist_scope = nullptr; |
4584 descriptor.mode = LET; | 4576 descriptor.mode = LET; |
4585 descriptor.is_const = false; | 4577 descriptor.is_const = false; |
4586 descriptor.needs_init = true; | 4578 descriptor.needs_init = true; |
4587 descriptor.declaration_pos = parameter.pattern->position(); | 4579 descriptor.declaration_pos = parameter.pattern->position(); |
4588 descriptor.initialization_pos = parameter.pattern->position(); | 4580 descriptor.initialization_pos = parameter.pattern->position(); |
4589 descriptor.init_op = Token::INIT_LET; | |
4590 Expression* initial_value = | 4581 Expression* initial_value = |
4591 factory()->NewVariableProxy(parameters.scope->parameter(i)); | 4582 factory()->NewVariableProxy(parameters.scope->parameter(i)); |
4592 if (parameter.initializer != nullptr) { | 4583 if (parameter.initializer != nullptr) { |
4593 // IS_UNDEFINED($param) ? initializer : $param | 4584 // IS_UNDEFINED($param) ? initializer : $param |
4594 DCHECK(!parameter.is_rest); | 4585 DCHECK(!parameter.is_rest); |
4595 auto condition = factory()->NewCompareOperation( | 4586 auto condition = factory()->NewCompareOperation( |
4596 Token::EQ_STRICT, | 4587 Token::EQ_STRICT, |
4597 factory()->NewVariableProxy(parameters.scope->parameter(i)), | 4588 factory()->NewVariableProxy(parameters.scope->parameter(i)), |
4598 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | 4589 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), |
4599 RelocInfo::kNoPosition); | 4590 RelocInfo::kNoPosition); |
(...skipping 13 matching lines...) Expand all Loading... |
4613 DCHECK_EQ(i, parameters.params.length() - 1); | 4604 DCHECK_EQ(i, parameters.params.length() - 1); |
4614 | 4605 |
4615 int pos = parameter.pattern->position(); | 4606 int pos = parameter.pattern->position(); |
4616 Variable* temp_var = parameters.scope->parameter(i); | 4607 Variable* temp_var = parameters.scope->parameter(i); |
4617 auto empty_values = new (zone()) ZoneList<Expression*>(0, zone()); | 4608 auto empty_values = new (zone()) ZoneList<Expression*>(0, zone()); |
4618 auto empty_array = factory()->NewArrayLiteral( | 4609 auto empty_array = factory()->NewArrayLiteral( |
4619 empty_values, parameters.rest_array_literal_index, | 4610 empty_values, parameters.rest_array_literal_index, |
4620 is_strong(language_mode()), RelocInfo::kNoPosition); | 4611 is_strong(language_mode()), RelocInfo::kNoPosition); |
4621 | 4612 |
4622 auto init_array = factory()->NewAssignment( | 4613 auto init_array = factory()->NewAssignment( |
4623 Token::INIT_VAR, factory()->NewVariableProxy(temp_var), empty_array, | 4614 Token::INIT, factory()->NewVariableProxy(temp_var), empty_array, |
4624 RelocInfo::kNoPosition); | 4615 RelocInfo::kNoPosition); |
4625 | 4616 |
4626 auto loop = factory()->NewForStatement(NULL, RelocInfo::kNoPosition); | 4617 auto loop = factory()->NewForStatement(NULL, RelocInfo::kNoPosition); |
4627 | 4618 |
4628 auto argument_index = | 4619 auto argument_index = |
4629 parameters.scope->NewTemporary(ast_value_factory()->empty_string()); | 4620 parameters.scope->NewTemporary(ast_value_factory()->empty_string()); |
4630 auto init = factory()->NewExpressionStatement( | 4621 auto init = factory()->NewExpressionStatement( |
4631 factory()->NewAssignment( | 4622 factory()->NewAssignment( |
4632 Token::INIT_VAR, factory()->NewVariableProxy(argument_index), | 4623 Token::INIT, factory()->NewVariableProxy(argument_index), |
4633 factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), | 4624 factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), |
4634 RelocInfo::kNoPosition), | 4625 RelocInfo::kNoPosition), |
4635 RelocInfo::kNoPosition); | 4626 RelocInfo::kNoPosition); |
4636 | 4627 |
4637 auto empty_arguments = new (zone()) ZoneList<Expression*>(0, zone()); | 4628 auto empty_arguments = new (zone()) ZoneList<Expression*>(0, zone()); |
4638 | 4629 |
4639 // $arguments_index < arguments.length | 4630 // $arguments_index < arguments.length |
4640 auto cond = factory()->NewCompareOperation( | 4631 auto cond = factory()->NewCompareOperation( |
4641 Token::LT, factory()->NewVariableProxy(argument_index), | 4632 Token::LT, factory()->NewVariableProxy(argument_index), |
4642 factory()->NewCallRuntime(Runtime::kInlineArgumentsLength, | 4633 factory()->NewCallRuntime(Runtime::kInlineArgumentsLength, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4751 | 4742 |
4752 // For generators, allocate and yield an iterator on function entry. | 4743 // For generators, allocate and yield an iterator on function entry. |
4753 if (IsGeneratorFunction(kind)) { | 4744 if (IsGeneratorFunction(kind)) { |
4754 ZoneList<Expression*>* arguments = | 4745 ZoneList<Expression*>* arguments = |
4755 new(zone()) ZoneList<Expression*>(0, zone()); | 4746 new(zone()) ZoneList<Expression*>(0, zone()); |
4756 CallRuntime* allocation = factory()->NewCallRuntime( | 4747 CallRuntime* allocation = factory()->NewCallRuntime( |
4757 Runtime::kCreateJSGeneratorObject, arguments, pos); | 4748 Runtime::kCreateJSGeneratorObject, arguments, pos); |
4758 VariableProxy* init_proxy = factory()->NewVariableProxy( | 4749 VariableProxy* init_proxy = factory()->NewVariableProxy( |
4759 function_state_->generator_object_variable()); | 4750 function_state_->generator_object_variable()); |
4760 Assignment* assignment = factory()->NewAssignment( | 4751 Assignment* assignment = factory()->NewAssignment( |
4761 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition); | 4752 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); |
4762 VariableProxy* get_proxy = factory()->NewVariableProxy( | 4753 VariableProxy* get_proxy = factory()->NewVariableProxy( |
4763 function_state_->generator_object_variable()); | 4754 function_state_->generator_object_variable()); |
4764 Yield* yield = factory()->NewYield( | 4755 Yield* yield = factory()->NewYield( |
4765 get_proxy, assignment, Yield::kInitial, RelocInfo::kNoPosition); | 4756 get_proxy, assignment, Yield::kInitial, RelocInfo::kNoPosition); |
4766 body->Add(factory()->NewExpressionStatement( | 4757 body->Add(factory()->NewExpressionStatement( |
4767 yield, RelocInfo::kNoPosition), zone()); | 4758 yield, RelocInfo::kNoPosition), zone()); |
4768 } | 4759 } |
4769 | 4760 |
4770 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 4761 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
4771 | 4762 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4809 result->Add(init_block, zone()); | 4800 result->Add(init_block, zone()); |
4810 result->Add(inner_block, zone()); | 4801 result->Add(inner_block, zone()); |
4811 } | 4802 } |
4812 | 4803 |
4813 if (function_type == FunctionLiteral::NAMED_EXPRESSION) { | 4804 if (function_type == FunctionLiteral::NAMED_EXPRESSION) { |
4814 // Now that we know the language mode, we can create the const assignment | 4805 // Now that we know the language mode, we can create the const assignment |
4815 // in the previously reserved spot. | 4806 // in the previously reserved spot. |
4816 // NOTE: We create a proxy and resolve it here so that in the | 4807 // NOTE: We create a proxy and resolve it here so that in the |
4817 // future we can change the AST to only refer to VariableProxies | 4808 // future we can change the AST to only refer to VariableProxies |
4818 // instead of Variables and Proxies as is the case now. | 4809 // instead of Variables and Proxies as is the case now. |
4819 const bool use_strict_const = is_strict(scope_->language_mode()); | 4810 VariableMode fvar_mode = is_strict(language_mode()) ? CONST : CONST_LEGACY; |
4820 Token::Value fvar_init_op = | |
4821 use_strict_const ? Token::INIT_CONST : Token::INIT_CONST_LEGACY; | |
4822 VariableMode fvar_mode = use_strict_const ? CONST : CONST_LEGACY; | |
4823 Variable* fvar = new (zone()) | 4811 Variable* fvar = new (zone()) |
4824 Variable(scope_, function_name, fvar_mode, Variable::NORMAL, | 4812 Variable(scope_, function_name, fvar_mode, Variable::NORMAL, |
4825 kCreatedInitialized, kNotAssigned); | 4813 kCreatedInitialized, kNotAssigned); |
4826 VariableProxy* proxy = factory()->NewVariableProxy(fvar); | 4814 VariableProxy* proxy = factory()->NewVariableProxy(fvar); |
4827 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration( | 4815 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration( |
4828 proxy, fvar_mode, scope_, RelocInfo::kNoPosition); | 4816 proxy, fvar_mode, scope_, RelocInfo::kNoPosition); |
4829 scope_->DeclareFunctionVar(fvar_declaration); | 4817 scope_->DeclareFunctionVar(fvar_declaration); |
4830 | 4818 |
4831 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); | 4819 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); |
4832 result->Set(kFunctionNameAssignmentIndex, | 4820 result->Set(kFunctionNameAssignmentIndex, |
4833 factory()->NewExpressionStatement( | 4821 factory()->NewExpressionStatement( |
4834 factory()->NewAssignment(fvar_init_op, fproxy, | 4822 factory()->NewAssignment(Token::INIT, fproxy, |
4835 factory()->NewThisFunction(pos), | 4823 factory()->NewThisFunction(pos), |
4836 RelocInfo::kNoPosition), | 4824 RelocInfo::kNoPosition), |
4837 RelocInfo::kNoPosition)); | 4825 RelocInfo::kNoPosition)); |
4838 } | 4826 } |
4839 | 4827 |
4840 return result; | 4828 return result; |
4841 } | 4829 } |
4842 | 4830 |
4843 | 4831 |
4844 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( | 4832 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( |
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6453 } | 6441 } |
6454 | 6442 |
6455 | 6443 |
6456 void Parser::RaiseLanguageMode(LanguageMode mode) { | 6444 void Parser::RaiseLanguageMode(LanguageMode mode) { |
6457 SetLanguageMode(scope_, | 6445 SetLanguageMode(scope_, |
6458 static_cast<LanguageMode>(scope_->language_mode() | mode)); | 6446 static_cast<LanguageMode>(scope_->language_mode() | mode)); |
6459 } | 6447 } |
6460 | 6448 |
6461 } // namespace internal | 6449 } // namespace internal |
6462 } // namespace v8 | 6450 } // namespace v8 |
OLD | NEW |