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

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

Issue 3001213002: [VM generic functions] Support generic async calls. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « runtime/vm/ast_transformer.cc ('k') | no next file » | 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 6962 matching lines...) Expand 10 before | Expand all | Expand 10 after
6973 body = found_func.raw(); 6973 body = found_func.raw();
6974 body_closure_name = body.name(); 6974 body_closure_name = body.name();
6975 } else { 6975 } else {
6976 // Create the closure containing the body of this generator function. 6976 // Create the closure containing the body of this generator function.
6977 String& generator_name = String::Handle(Z, innermost_function().name()); 6977 String& generator_name = String::Handle(Z, innermost_function().name());
6978 body_closure_name = 6978 body_closure_name =
6979 Symbols::NewFormatted(T, "<%s_sync_body>", generator_name.ToCString()); 6979 Symbols::NewFormatted(T, "<%s_sync_body>", generator_name.ToCString());
6980 body = Function::NewClosureFunction(body_closure_name, innermost_function(), 6980 body = Function::NewClosureFunction(body_closure_name, innermost_function(),
6981 func_pos); 6981 func_pos);
6982 body.set_is_generated_body(true); 6982 body.set_is_generated_body(true);
6983 // TODO(regis): Handle generic generator function.
6984 body.set_result_type(Object::dynamic_type()); 6983 body.set_result_type(Object::dynamic_type());
6985 is_new_closure = true; 6984 is_new_closure = true;
6986 } 6985 }
6987 6986
6988 ParamList closure_params; 6987 ParamList closure_params;
6989 AddSyncGenClosureParameters(&closure_params); 6988 AddSyncGenClosureParameters(&closure_params);
6990 6989
6991 if (is_new_closure) { 6990 if (is_new_closure) {
6992 // Add the parameters to the newly created closure. 6991 // Add the parameters to the newly created closure.
6993 AddFormalParamsToFunction(&closure_params, body); 6992 AddFormalParamsToFunction(&closure_params, body);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
7100 } else { 7099 } else {
7101 // Create the closure containing the body of this async function. 7100 // Create the closure containing the body of this async function.
7102 const String& async_func_name = 7101 const String& async_func_name =
7103 String::Handle(Z, innermost_function().name()); 7102 String::Handle(Z, innermost_function().name());
7104 String& closure_name = 7103 String& closure_name =
7105 String::Handle(Z, Symbols::NewFormatted(T, "<%s_async_body>", 7104 String::Handle(Z, Symbols::NewFormatted(T, "<%s_async_body>",
7106 async_func_name.ToCString())); 7105 async_func_name.ToCString()));
7107 closure = Function::NewClosureFunction(closure_name, innermost_function(), 7106 closure = Function::NewClosureFunction(closure_name, innermost_function(),
7108 async_func_pos); 7107 async_func_pos);
7109 closure.set_is_generated_body(true); 7108 closure.set_is_generated_body(true);
7110 // TODO(regis): Handle generic async function.
7111 closure.set_result_type(Object::dynamic_type()); 7109 closure.set_result_type(Object::dynamic_type());
7112 is_new_closure = true; 7110 is_new_closure = true;
7113 } 7111 }
7114 // Create the parameter list for the async body closure. 7112 // Create the parameter list for the async body closure.
7115 ParamList closure_params; 7113 ParamList closure_params;
7116 AddAsyncClosureParameters(&closure_params); 7114 AddAsyncClosureParameters(&closure_params);
7117 if (is_new_closure) { 7115 if (is_new_closure) {
7118 // Add the parameters to the newly created closure. 7116 // Add the parameters to the newly created closure.
7119 AddFormalParamsToFunction(&closure_params, closure); 7117 AddFormalParamsToFunction(&closure_params, closure);
7120 ResolveSignatureTypeParameters(closure); 7118 ResolveSignatureTypeParameters(closure);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
7233 } else { 7231 } else {
7234 // Create the closure containing the body of this async generator function. 7232 // Create the closure containing the body of this async generator function.
7235 const String& async_generator_name = 7233 const String& async_generator_name =
7236 String::Handle(Z, innermost_function().name()); 7234 String::Handle(Z, innermost_function().name());
7237 const String& closure_name = String::Handle( 7235 const String& closure_name = String::Handle(
7238 Z, Symbols::NewFormatted(T, "<%s_async_gen_body>", 7236 Z, Symbols::NewFormatted(T, "<%s_async_gen_body>",
7239 async_generator_name.ToCString())); 7237 async_generator_name.ToCString()));
7240 closure = Function::NewClosureFunction(closure_name, innermost_function(), 7238 closure = Function::NewClosureFunction(closure_name, innermost_function(),
7241 async_func_pos); 7239 async_func_pos);
7242 closure.set_is_generated_body(true); 7240 closure.set_is_generated_body(true);
7243 // TODO(regis): Handle generic async generator function.
7244 closure.set_result_type(Object::dynamic_type()); 7241 closure.set_result_type(Object::dynamic_type());
7245 is_new_closure = true; 7242 is_new_closure = true;
7246 } 7243 }
7247 7244
7248 ParamList closure_params; 7245 ParamList closure_params;
7249 AddAsyncGenClosureParameters(&closure_params); 7246 AddAsyncGenClosureParameters(&closure_params);
7250 7247
7251 if (is_new_closure) { 7248 if (is_new_closure) {
7252 // Add the parameters to the newly created closure. 7249 // Add the parameters to the newly created closure.
7253 AddFormalParamsToFunction(&closure_params, closure); 7250 AddFormalParamsToFunction(&closure_params, closure);
(...skipping 6550 matching lines...) Expand 10 before | Expand all | Expand 10 after
13804 ParseFormalParameters(ctr, &params); 13801 ParseFormalParameters(ctr, &params);
13805 // Per language spec, the type of the closure parameters is dynamic. 13802 // Per language spec, the type of the closure parameters is dynamic.
13806 // Replace the types parsed from the constructor. 13803 // Replace the types parsed from the constructor.
13807 params.EraseParameterTypes(); 13804 params.EraseParameterTypes();
13808 13805
13809 closure = Function::NewClosureFunction(closure_name, innermost_function(), 13806 closure = Function::NewClosureFunction(closure_name, innermost_function(),
13810 token_pos); 13807 token_pos);
13811 closure.set_is_generated_body(true); 13808 closure.set_is_generated_body(true);
13812 closure.set_is_debuggable(false); 13809 closure.set_is_debuggable(false);
13813 closure.set_is_visible(false); 13810 closure.set_is_visible(false);
13814 // TODO(regis): Verify that the closure cannot be generic.
13815 closure.set_result_type(Object::dynamic_type()); 13811 closure.set_result_type(Object::dynamic_type());
13816 AddFormalParamsToFunction(&params, closure); 13812 AddFormalParamsToFunction(&params, closure);
13817 ResolveSignatureTypeParameters(closure); 13813 ResolveSignatureTypeParameters(closure);
13818 13814
13819 // Finalize function type. 13815 // Finalize function type.
13820 Type& signature_type = Type::Handle(Z, closure.SignatureType()); 13816 Type& signature_type = Type::Handle(Z, closure.SignatureType());
13821 signature_type ^= CanonicalizeType(signature_type); 13817 signature_type ^= CanonicalizeType(signature_type);
13822 closure.SetSignatureType(signature_type); 13818 closure.SetSignatureType(signature_type);
13823 // Finalization would be premature when top-level parsing. 13819 // Finalization would be premature when top-level parsing.
13824 ASSERT(!is_top_level_); 13820 ASSERT(!is_top_level_);
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
15106 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field, 15102 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field,
15107 TokenPosition* start, 15103 TokenPosition* start,
15108 TokenPosition* end) { 15104 TokenPosition* end) {
15109 UNREACHABLE(); 15105 UNREACHABLE();
15110 return false; 15106 return false;
15111 } 15107 }
15112 15108
15113 } // namespace dart 15109 } // namespace dart
15114 15110
15115 #endif // DART_PRECOMPILED_RUNTIME 15111 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « runtime/vm/ast_transformer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698