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

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

Issue 2369293003: [ast] Make FunctionLiteral delegate to its Scope for FunctionKind (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « src/ast/ast.cc ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 materialized_literal_count = function_state.materialized_literal_count(); 277 materialized_literal_count = function_state.materialized_literal_count();
278 expected_property_count = function_state.expected_property_count(); 278 expected_property_count = function_state.expected_property_count();
279 } 279 }
280 280
281 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 281 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
282 name, function_scope, body, materialized_literal_count, 282 name, function_scope, body, materialized_literal_count,
283 expected_property_count, parameter_count, 283 expected_property_count, parameter_count,
284 FunctionLiteral::kNoDuplicateParameters, 284 FunctionLiteral::kNoDuplicateParameters,
285 FunctionLiteral::kAnonymousExpression, 285 FunctionLiteral::kAnonymousExpression,
286 FunctionLiteral::kShouldLazyCompile, kind, pos); 286 FunctionLiteral::kShouldLazyCompile, pos);
287 287
288 function_literal->set_requires_class_field_init(requires_class_field_init); 288 function_literal->set_requires_class_field_init(requires_class_field_init);
289 289
290 return function_literal; 290 return function_literal;
291 } 291 }
292 292
293 293
294 // ---------------------------------------------------------------------------- 294 // ----------------------------------------------------------------------------
295 // Target is a support class to facilitate manipulation of the 295 // Target is a support class to facilitate manipulation of the
296 // Parser's target_stack_ (the stack of potential 'break' and 296 // Parser's target_stack_ (the stack of potential 'break' and
(...skipping 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 } // DiscardableZoneScope goes out of scope. 2835 } // DiscardableZoneScope goes out of scope.
2836 2836
2837 FunctionLiteral::ParameterFlag duplicate_parameters = 2837 FunctionLiteral::ParameterFlag duplicate_parameters =
2838 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters 2838 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters
2839 : FunctionLiteral::kNoDuplicateParameters; 2839 : FunctionLiteral::kNoDuplicateParameters;
2840 2840
2841 // Note that the FunctionLiteral needs to be created in the main Zone again. 2841 // Note that the FunctionLiteral needs to be created in the main Zone again.
2842 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 2842 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
2843 function_name, main_scope, body, materialized_literal_count, 2843 function_name, main_scope, body, materialized_literal_count,
2844 expected_property_count, arity, duplicate_parameters, function_type, 2844 expected_property_count, arity, duplicate_parameters, function_type,
2845 eager_compile_hint, kind, pos); 2845 eager_compile_hint, pos);
2846 function_literal->set_function_token_position(function_token_pos); 2846 function_literal->set_function_token_position(function_token_pos);
2847 if (should_be_used_once_hint) 2847 if (should_be_used_once_hint)
2848 function_literal->set_should_be_used_once_hint(); 2848 function_literal->set_should_be_used_once_hint();
2849 2849
2850 if (should_infer_name) { 2850 if (should_infer_name) {
2851 DCHECK_NOT_NULL(fni_); 2851 DCHECK_NOT_NULL(fni_);
2852 fni_->AddFunction(function_literal); 2852 fni_->AddFunction(function_literal);
2853 } 2853 }
2854 return function_literal; 2854 return function_literal;
2855 } 2855 }
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
3505 } 3505 }
3506 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition), 3506 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition),
3507 kNoSourcePosition), 3507 kNoSourcePosition),
3508 zone()); 3508 zone());
3509 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 3509 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
3510 ast_value_factory()->empty_string(), initializer_scope, body, 3510 ast_value_factory()->empty_string(), initializer_scope, body,
3511 initializer_state.materialized_literal_count(), 3511 initializer_state.materialized_literal_count(),
3512 initializer_state.expected_property_count(), 0, 3512 initializer_state.expected_property_count(), 0,
3513 FunctionLiteral::kNoDuplicateParameters, 3513 FunctionLiteral::kNoDuplicateParameters,
3514 FunctionLiteral::kAnonymousExpression, 3514 FunctionLiteral::kAnonymousExpression,
3515 FunctionLiteral::kShouldLazyCompile, kind, 3515 FunctionLiteral::kShouldLazyCompile, initializer_scope->start_position());
3516 initializer_scope->start_position());
3517 function_literal->set_is_class_field_initializer(true); 3516 function_literal->set_is_class_field_initializer(true);
3518 function_literal->scope()->set_arity(count); 3517 function_literal->scope()->set_arity(count);
3519 return function_literal; 3518 return function_literal;
3520 } 3519 }
3521 3520
3522 FunctionLiteral* Parser::InsertClassFieldInitializer( 3521 FunctionLiteral* Parser::InsertClassFieldInitializer(
3523 FunctionLiteral* constructor) { 3522 FunctionLiteral* constructor) {
3524 Statement* call_initializer = factory()->NewExpressionStatement( 3523 Statement* call_initializer = factory()->NewExpressionStatement(
3525 CallClassFieldInitializer( 3524 CallClassFieldInitializer(
3526 constructor->scope(), 3525 constructor->scope(),
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
5562 5561
5563 return final_loop; 5562 return final_loop;
5564 } 5563 }
5565 5564
5566 #undef CHECK_OK 5565 #undef CHECK_OK
5567 #undef CHECK_OK_VOID 5566 #undef CHECK_OK_VOID
5568 #undef CHECK_FAILED 5567 #undef CHECK_FAILED
5569 5568
5570 } // namespace internal 5569 } // namespace internal
5571 } // namespace v8 5570 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698