Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart |
| index 2b4d152cf5b7a733fdfe80a5d18f9694c3b4fa97..3ddaed6d5d8db10cb3a1c8b38fd231b670a43fcf 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart |
| @@ -209,11 +209,12 @@ class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { |
| } |
| jsAst.Expression visitList(ListConstant constant) { |
| - return new jsAst.Call( |
| + jsAst.Expression value = new jsAst.Call( |
| new jsAst.PropertyAccess.field( |
| new jsAst.VariableUse(namer.isolateName), |
| 'makeConstantList'), |
| [new jsAst.ArrayInitializer.from(_array(constant.entries))]); |
| + return maybeAddTypeArguments(constant.type, value); |
| } |
| String getJsConstructor(ClassElement element) { |
| @@ -276,23 +277,27 @@ class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { |
| badFieldCountError(); |
| } |
| - return new jsAst.New( |
| + jsAst.Expression value = new jsAst.New( |
| new jsAst.VariableUse(getJsConstructor(classElement)), |
| arguments); |
| + return maybeAddTypeArguments(constant.type, value); |
| } |
| - jsAst.Expression visitType(TypeConstant constant) { |
| - JavaScriptBackend backend = compiler.backend; |
| - Element helper = backend.getCreateRuntimeType(); |
| + JavaScriptBackend get backend => compiler.backend; |
| + |
| + jsAst.PropertyAccess getHelperProperty(Element helper) { |
| String helperName = backend.namer.getName(helper); |
| + return new jsAst.PropertyAccess.field( |
| + new jsAst.VariableUse(namer.CURRENT_ISOLATE), |
| + helperName); |
| + } |
| + |
| + jsAst.Expression visitType(TypeConstant constant) { |
| DartType type = constant.representedType; |
| String name = namer.getRuntimeTypeName(type.element); |
| jsAst.Expression typeName = new jsAst.LiteralString("'$name'"); |
| - return new jsAst.Call( |
| - new jsAst.PropertyAccess.field( |
| - new jsAst.VariableUse(namer.CURRENT_ISOLATE), |
| - helperName), |
| - [typeName]); |
| + return new jsAst.Call(getHelperProperty(backend.getCreateRuntimeType()), |
| + [typeName]); |
| } |
| jsAst.Expression visitInterceptor(InterceptorConstant constant) { |
| @@ -303,9 +308,10 @@ class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { |
| } |
| jsAst.Expression visitConstructed(ConstructedConstant constant) { |
| - return new jsAst.New( |
| + jsAst.New instantiation = new jsAst.New( |
| new jsAst.VariableUse(getJsConstructor(constant.type.element)), |
| _array(constant.fields)); |
| + return maybeAddTypeArguments(constant.type, instantiation); |
| } |
| List<jsAst.Expression> _array(List<Constant> values) { |
| @@ -315,4 +321,21 @@ class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { |
| } |
| return valueList; |
| } |
| + |
| + jsAst.Expression maybeAddTypeArguments(InterfaceType type, |
| + jsAst.Expression value) { |
| + if (type is InterfaceType && !type.isRaw && |
|
ngeoffray
2013/06/19 19:55:48
nit: move && !type.isRaw to a new line.
karlklose
2013/06/20 09:25:23
Why?
ngeoffray
2013/06/20 09:31:56
http://www.dartlang.org/articles/style-guide/: DO
karlklose
2013/06/20 10:23:28
But your comment was about moving every part expre
ngeoffray
2013/06/20 10:32:07
The guide does not explicitly say it, but if you l
karlklose
2013/06/20 12:49:21
Done.
|
| + backend.needsRti(type.element)) { |
| + InterfaceType interface = type; |
| + RuntimeTypes rti = backend.rti; |
| + Iterable<String> arguments = interface.typeArguments |
| + .toList(growable: false) |
| + .map((DartType type) => rti.getTypeRepresentation(type, (_){})); |
| + jsAst.Expression argumentList = |
| + new jsAst.LiteralString('[${arguments.join(', ')}]'); |
| + return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), |
| + [value, argumentList]); |
| + } |
| + return value; |
| + } |
| } |