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

Unified Diff: lib/src/compiler/code_generator.dart

Issue 1968193002: avoid spread args (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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 | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/classes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/code_generator.dart
diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart
index a69a05247f8dec77814a9d883cb41e17382c9106..23e36750e5d2f921c9d29526d888b309ccd2db0f 100644
--- a/lib/src/compiler/code_generator.dart
+++ b/lib/src/compiler/code_generator.dart
@@ -556,8 +556,18 @@ class CodeGenerator extends GeneralizingAstVisitor
if (!supertype.isObject) {
for (var ctor in element.constructors) {
var parentCtor = supertype.lookUpConstructor(ctor.name, ctor.library);
- var fun = js.call('function() { super.#(...arguments); }',
- [_constructorName(parentCtor)]) as JS.Fun;
+ // TODO(jmesserly): this avoids spread args for perf. Revisit.
+ var jsParams = <JS.Identifier>[];
+ for (var p in ctor.parameters) {
+ if (p.parameterKind != ParameterKind.NAMED) {
+ jsParams.add(new JS.Identifier(p.name));
+ } else {
+ jsParams.add(new JS.TemporaryId('namedArgs'));
+ break;
+ }
+ }
+ var fun = js.call('function(#) { super.#(#); }',
+ [jsParams, _constructorName(parentCtor), jsParams]) as JS.Fun;
methods.add(new JS.Method(_constructorName(ctor), fun));
}
}
@@ -1380,7 +1390,7 @@ class CodeGenerator extends GeneralizingAstVisitor
let name = this.constructor.name;
// Call the default constructor.
let result = void 0;
- if (name in this) result = this[name](...arguments);
+ if (name in this) result = this[name].apply(this, arguments);
return result === void 0 ? this : result;
}''') as JS.Block;
} else {
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/classes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698