Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart |
| index 1ae6d417c2301834250b65e527a418e92f34ef0a..43edaac419e1530c77d5c09c715b4c8cd4cf6bee 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart |
| @@ -613,7 +613,8 @@ class FragmentEmitter { |
| } |
| allMethods.forEach((Method method) { |
| - emitInstanceMethod(method).forEach((js.Name name, js.Expression code) { |
| + emitInstanceMethod(method) |
| + .forEach((js.Expression name, js.Expression code) { |
| properties.add(new js.Property(name, code)); |
| }); |
| }); |
| @@ -679,17 +680,31 @@ class FragmentEmitter { |
| /// |
| /// If it is a Dart-method, all necessary stub-methods are emitted, too. In |
| /// that case the returned map contains more than just one entry. |
| - Map<js.Name, js.Expression> emitInstanceMethod(Method method) { |
| - Map<js.Name, js.Expression> jsMethods = <js.Name, js.Expression>{}; |
| + /// |
| + /// If the method is a call-method, also returns the necessary properties |
|
Siggi Cherem (dart-lang)
2015/07/23 19:43:42
nit: call-method => closure-call-method
floitsch
2015/07/29 18:26:46
Done.
|
| + /// in case the closure can be applied. |
| + Map<js.Expression, js.Expression> emitInstanceMethod(Method method) { |
| + Map<js.Expression, js.Expression> properties = |
|
Siggi Cherem (dart-lang)
2015/07/23 19:43:42
nit: var?
(I prefer not to repeat the type when w
floitsch
2015/07/29 18:26:46
We always used the full type, but done.
|
| + <js.Expression, js.Expression>{}; |
| - jsMethods[method.name] = method.code; |
| + properties[method.name] = method.code; |
| if (method is InstanceMethod) { |
| for (ParameterStubMethod stubMethod in method.parameterStubs) { |
| - jsMethods[stubMethod.name] = stubMethod.code; |
| + properties[stubMethod.name] = stubMethod.code; |
| + } |
| + |
| + if (method.isClosureCallMethod && method.canBeApplied) { |
| + properties[js.string(namer.callCatchAllName)] = |
| + js.quoteName(method.name); |
| + properties[js.string(namer.requiredParameterField)] = |
| + js.number(method.requiredParameterCount); |
| + properties[js.string(namer.defaultValuesField)] = |
| + js.js('function() { return #; }', |
| + _encodeOptionalParameterDefaultValues(method)); |
| } |
| } |
| - return jsMethods; |
| + return properties; |
| } |
| /// Emits the inheritance block of the fragment. |
| @@ -759,10 +774,16 @@ class FragmentEmitter { |
| Map<String, ConstantValue> defaultValues = |
| method.optionalParameterDefaultValues; |
| List<js.Property> properties = <js.Property>[]; |
| - defaultValues.forEach((String name, ConstantValue value) { |
| + List<String> names = defaultValues.keys.toList(growable: false); |
| + // Sort the names the same way we sort them for the named-argument calling |
| + // convention. |
| + names.sort(); |
| + |
| + for (String name in names) { |
| + ConstantValue value = defaultValues[name]; |
| properties.add(new js.Property(js.string(name), |
| generateConstantReference(value))); |
| - }); |
| + } |
| return new js.ObjectInitializer(properties); |
| } |
| } |
| @@ -816,7 +837,7 @@ class FragmentEmitter { |
| _encodeOptionalParameterDefaultValues(method); |
| } |
| -// TODO(floitsch): this can be more efficient. |
| + // TODO(floitsch): this can be more efficient. |
| return js.js.statement(''' |
| installTearOff(#container, #getterName, #isStatic, #isIntercepted, |
| #requiredParameterCount, #optionalParameterDefaultValues, |