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

Unified Diff: pkg/compiler/lib/src/js_emitter/program_builder.dart

Issue 887853004: dart2js: Move parameterStub generation to parameter_stub_generator and add parameter stubs to model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased. Created 5 years, 11 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 | « pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/program_builder.dart
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder.dart
index 01c38363c652c425b6f3f54251a396ed2a68a335..48405265e92e0f480e0c3dd1c243527dfe89a187 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder.dart
@@ -19,6 +19,7 @@ import 'js_emitter.dart' show
ClassStubGenerator,
CodeEmitterTask,
InterceptorStubGenerator,
+ ParameterStubGenerator,
TypeTestGenerator,
TypeTestProperties;
@@ -424,7 +425,6 @@ class ProgramBuilder {
bool isClosure = false;
bool isNotApplyTarget = !element.isFunction || element.isAccessor;
- final bool needsStubs = _methodNeedsStubs(element);
final bool canBeReflected = _methodCanBeReflected(element);
final bool canBeApplied = _methodCanBeApplied(element);
final bool hasSuperAlias = backend.isAliasedSuperMember(element);
@@ -451,10 +451,30 @@ class ProgramBuilder {
assert(invariant(element, !element.isConstructor));
}
- return new InstanceMethod(element, name, code, needsTearOff: canTearOff,
- tearOffName: tearOffName, isClosure: isClosure,
- hasSuperAlias: hasSuperAlias, canBeApplied: canBeApplied,
- canBeReflected: canBeReflected, needsStubs: needsStubs);
+ return new InstanceMethod(element, name, code,
+ _generateParameterStubs(element, canTearOff),
+ needsTearOff: canTearOff, tearOffName: tearOffName,
+ isClosure: isClosure, hasSuperAlias: hasSuperAlias,
+ canBeApplied: canBeApplied, canBeReflected: canBeReflected);
+ }
+
+ List<ParameterStubMethod> _generateParameterStubs(FunctionElement element,
+ bool canTearOff) {
+
+ if (!_methodNeedsStubs(element)) return const <ParameterStubMethod>[];
+
+ List<ParameterStubMethod> parameterStubs = <ParameterStubMethod>[];
+ ParameterStubGenerator generator =
+ new ParameterStubGenerator(_compiler, namer, backend);
+ Map<Selector, js.Expression> parameterStubsForElement =
+ generator.generateParameterStubs(element, canTearOff);
+ parameterStubsForElement.forEach((Selector selector, js.Expression code) {
+ String name = namer.invocationName(selector);
+ parameterStubs.add(
+ _buildParameterStubMethod(name, code, selector, element: element));
+ });
+
+ return parameterStubs;
}
/// Builds a stub method.
@@ -466,6 +486,12 @@ class ProgramBuilder {
return new StubMethod(name, code, element: element);
}
+ Method _buildParameterStubMethod(String name, js.Expression code,
+ Selector selector,
+ {Element element}) {
+ return new ParameterStubMethod(name, code, selector, element: element);
+ }
+
// The getInterceptor methods directly access the prototype of classes.
// We must evaluate these classes eagerly so that the prototype is
// accessible.
@@ -563,7 +589,6 @@ class ProgramBuilder {
js.Expression code = backend.generatedCode[element];
final bool isNotApplyTarget = !element.isConstructor && !element.isAccessor;
- final bool needsStubs = _methodNeedsStubs(element);
final bool canBeApplied = _methodCanBeApplied(element);
final bool canBeReflected = _methodCanBeReflected(element);
@@ -575,11 +600,11 @@ class ProgramBuilder {
return new StaticDartMethod(element,
name, _registry.registerHolder(holder), code,
+ _generateParameterStubs(element, needsTearOff),
needsTearOff: needsTearOff,
tearOffName: tearOffName,
canBeApplied: canBeApplied,
- canBeReflected: canBeReflected,
- needsStubs: needsStubs);
+ canBeReflected: canBeReflected);
}
void _registerConstants(OutputUnit outputUnit,
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698