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

Unified Diff: runtime/vm/parser.cc

Issue 1271343003: Reuse constructor closures (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 017963360f5ba8671cfe777df352e28a2d80fd48..f85523d2a54d427325978a71d84d06bce4e8932e 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -12865,9 +12865,17 @@ AstNode* Parser::ParseSymbolLiteral() {
RawFunction* Parser::BuildConstructorClosureFunction(const Function& ctr,
intptr_t token_pos) {
ASSERT(ctr.kind() == RawFunction::kConstructor);
+ Function& closure = Function::Handle(Z);
+ closure = current_class().LookupClosureFunction(token_pos);
+ if (!closure.IsNull()) {
+ ASSERT(closure.IsConstructorClosureFunction());
+ return closure.raw();
+ }
+
String& closure_name = String::Handle(Z, ctr.name());
closure_name = Symbols::FromConcat(Symbols::ConstructorClosurePrefix(),
closure_name);
+
ParamList params;
params.AddFinalParameter(token_pos,
&Symbols::ClosureParameter(),
@@ -12878,11 +12886,11 @@ RawFunction* Parser::BuildConstructorClosureFunction(const Function& ctr,
// Replace the types parsed from the constructor.
params.EraseParameterTypes();
- Function& closure = Function::Handle(Z);
closure = Function::NewClosureFunction(closure_name,
innermost_function(),
token_pos);
closure.set_is_generated_body(true);
+ closure.set_is_debuggable(false);
closure.set_result_type(AbstractType::Handle(Type::DynamicType()));
AddFormalParamsToFunction(&params, closure);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698