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

Side by Side Diff: runtime/vm/parser.cc

Issue 2951803005: Set and keep parent function of signature functions. (Closed)
Patch Set: address review comments Created 3 years, 6 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 | « runtime/vm/object.cc ('k') | runtime/vm/runtime_entry.cc » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 if (!var_seen && !final_seen) { 2228 if (!var_seen && !final_seen) {
2229 // The parsed parameter type is actually the function result type. 2229 // The parsed parameter type is actually the function result type.
2230 AbstractType& result_type = 2230 AbstractType& result_type =
2231 AbstractType::Handle(Z, parameter.type->raw()); 2231 AbstractType::Handle(Z, parameter.type->raw());
2232 2232
2233 // In top-level and mixin functions, the source may be in a different 2233 // In top-level and mixin functions, the source may be in a different
2234 // script than the script of the current class. However, we never reparse 2234 // script than the script of the current class. However, we never reparse
2235 // signature functions (except typedef signature functions), therefore 2235 // signature functions (except typedef signature functions), therefore
2236 // we do not need to keep the correct script via a patch class. Use the 2236 // we do not need to keep the correct script via a patch class. Use the
2237 // actual current class as owner of the signature function. 2237 // actual current class as owner of the signature function.
2238 Function& signature_function = 2238 Function& signature_function = Function::Handle(
2239 Function::Handle(Z, Function::NewSignatureFunction( 2239 Z,
2240 current_class(), TokenPosition::kNoSource)); 2240 Function::NewSignatureFunction(current_class(), innermost_function(),
2241 signature_function.set_parent_function(innermost_function()); 2241 TokenPosition::kNoSource));
2242 innermost_function_ = signature_function.raw(); 2242 innermost_function_ = signature_function.raw();
2243 2243
2244 // Finish parsing the function type parameter. 2244 // Finish parsing the function type parameter.
2245 if (CurrentToken() == Token::kLT) { 2245 if (CurrentToken() == Token::kLT) {
2246 if (!FLAG_generic_method_syntax) { 2246 if (!FLAG_generic_method_syntax) {
2247 ReportError("generic function types not supported"); 2247 ReportError("generic function types not supported");
2248 } 2248 }
2249 ParseTypeParameters(false); // Not parameterizing class, but function. 2249 ParseTypeParameters(false); // Not parameterizing class, but function.
2250 } 2250 }
2251 2251
(...skipping 3179 matching lines...) Expand 10 before | Expand all | Expand 10 after
5431 ASSERT(innermost_function().IsNull()); 5431 ASSERT(innermost_function().IsNull());
5432 if (use_function_type_syntax) { 5432 if (use_function_type_syntax) {
5433 ExpectToken(Token::kASSIGN); 5433 ExpectToken(Token::kASSIGN);
5434 ASSERT(result_type.IsNull()); // Not parsed yet. 5434 ASSERT(result_type.IsNull()); // Not parsed yet.
5435 // Do not resolve types before the function type alias can be recognized as 5435 // Do not resolve types before the function type alias can be recognized as
5436 // a typedef class, so that correct promotion of function types can occur. 5436 // a typedef class, so that correct promotion of function types can occur.
5437 const Type& function_type = Type::Handle( 5437 const Type& function_type = Type::Handle(
5438 Z, ParseFunctionType(result_type, ClassFinalizer::kDoNotResolve)); 5438 Z, ParseFunctionType(result_type, ClassFinalizer::kDoNotResolve));
5439 signature_function = function_type.signature(); 5439 signature_function = function_type.signature();
5440 } else { 5440 } else {
5441 signature_function = 5441 signature_function = Function::NewSignatureFunction(
5442 Function::NewSignatureFunction(function_type_alias, alias_name_pos); 5442 function_type_alias, Function::Handle(Z), alias_name_pos);
5443 innermost_function_ = signature_function.raw(); 5443 innermost_function_ = signature_function.raw();
5444 ParamList params; 5444 ParamList params;
5445 // Parse the formal parameters of the function type. 5445 // Parse the formal parameters of the function type.
5446 CheckToken(Token::kLPAREN, "formal parameter list expected"); 5446 CheckToken(Token::kLPAREN, "formal parameter list expected");
5447 // Add implicit closure object parameter. 5447 // Add implicit closure object parameter.
5448 params.AddFinalParameter(TokenPos(), &Symbols::ClosureParameter(), 5448 params.AddFinalParameter(TokenPos(), &Symbols::ClosureParameter(),
5449 &Object::dynamic_type()); 5449 &Object::dynamic_type());
5450 const bool allow_explicit_default_values = false; 5450 const bool allow_explicit_default_values = false;
5451 const bool evaluate_metadata = false; 5451 const bool evaluate_metadata = false;
5452 ParseFormalParameterList(use_function_type_syntax, 5452 ParseFormalParameterList(use_function_type_syntax,
(...skipping 7851 matching lines...) Expand 10 before | Expand all | Expand 10 after
13304 // It is too early to resolve the type here, since it can 13304 // It is too early to resolve the type here, since it can
13305 // refer to a not yet declared function type parameter. 13305 // refer to a not yet declared function type parameter.
13306 type = ParseType(ClassFinalizer::kDoNotResolve); 13306 type = ParseType(ClassFinalizer::kDoNotResolve);
13307 } 13307 }
13308 } 13308 }
13309 if (!IsSymbol(Symbols::Function())) { 13309 if (!IsSymbol(Symbols::Function())) {
13310 ReportError("'Function' expected"); 13310 ReportError("'Function' expected");
13311 } 13311 }
13312 do { 13312 do {
13313 ConsumeToken(); 13313 ConsumeToken();
13314 const Function& signature_function = 13314 const Function& signature_function = Function::Handle(
13315 Function::Handle(Z, Function::NewSignatureFunction( 13315 Z, Function::NewSignatureFunction(current_class(), innermost_function(),
13316 current_class(), TokenPosition::kNoSource)); 13316 TokenPosition::kNoSource));
13317 signature_function.set_parent_function(innermost_function());
13318 innermost_function_ = signature_function.raw(); 13317 innermost_function_ = signature_function.raw();
13319 signature_function.set_result_type(type); 13318 signature_function.set_result_type(type);
13320 // Parse optional type parameters. 13319 // Parse optional type parameters.
13321 if (CurrentToken() == Token::kLT) { 13320 if (CurrentToken() == Token::kLT) {
13322 if (!FLAG_generic_method_syntax) { 13321 if (!FLAG_generic_method_syntax) {
13323 ReportError("generic type arguments not supported."); 13322 ReportError("generic type arguments not supported.");
13324 } 13323 }
13325 ParseTypeParameters(false); // Not parameterizing class, but function. 13324 ParseTypeParameters(false); // Not parameterizing class, but function.
13326 } 13325 }
13327 ParamList params; 13326 ParamList params;
(...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after
15348 TokenPosition* start, 15347 TokenPosition* start,
15349 TokenPosition* end) { 15348 TokenPosition* end) {
15350 UNREACHABLE(); 15349 UNREACHABLE();
15351 return false; 15350 return false;
15352 } 15351 }
15353 15352
15354 15353
15355 } // namespace dart 15354 } // namespace dart
15356 15355
15357 #endif // DART_PRECOMPILED_RUNTIME 15356 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/runtime_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698