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

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: Forgot to save container_builder 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
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..6bd551b25f4f9970018100f78c61550d6613e4f0 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);
@@ -454,7 +454,27 @@ class ProgramBuilder {
return new InstanceMethod(element, name, code, needsTearOff: canTearOff,
tearOffName: tearOffName, isClosure: isClosure,
hasSuperAlias: hasSuperAlias, canBeApplied: canBeApplied,
- canBeReflected: canBeReflected, needsStubs: needsStubs);
+ canBeReflected: canBeReflected,
+ parameterStubs: _generateParameterStubs(element, canTearOff));
+ }
+
+ List<ParameterStubMethod> _generateParameterStubs(FunctionElement element,
+ bool canTearOff) {
+ List<ParameterStubMethod> parameterStubs = <ParameterStubMethod>[];
herhut 2015/01/30 10:02:22 How about if (!_methodNeedsStubs) return const <
zarah 2015/01/30 12:46:39 Done.
+ if (_methodNeedsStubs(element)) {
+ 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);
@@ -579,7 +604,9 @@ class ProgramBuilder {
tearOffName: tearOffName,
canBeApplied: canBeApplied,
canBeReflected: canBeReflected,
- needsStubs: needsStubs);
+ parameterStubs:
+ _generateParameterStubs(element,
+ needsTearOff));
}
void _registerConstants(OutputUnit outputUnit,

Powered by Google App Engine
This is Rietveld 408576698