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

Unified Diff: pkg/compiler/lib/src/js_backend/constant_emitter.dart

Issue 1913033002: dart2js: Pass type information to constructor rather than add later. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: rebase Created 4 years, 4 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_backend/constant_emitter.dart
diff --git a/pkg/compiler/lib/src/js_backend/constant_emitter.dart b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
index 391a35c269e05bd3975edb96c0924206cd9cf34d..d21083f6624610bc266520fc5c57a194369d3138 100644
--- a/pkg/compiler/lib/src/js_backend/constant_emitter.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
@@ -254,6 +254,7 @@ class ConstantEmitter implements ConstantValueVisitor<jsAst.Expression, Null> {
jsAst.Expression constructor =
backend.emitter.constructorAccess(classElement);
jsAst.Expression value = new jsAst.New(constructor, arguments);
+ // Fix. Add an argument.
Siggi Cherem (dart-lang) 2016/08/19 16:39:46 did you indent to fix this one with this CL too?
return maybeAddTypeArguments(constant.type, value);
}
@@ -307,8 +308,11 @@ class ConstantEmitter implements ConstantValueVisitor<jsAst.Expression, Null> {
element.forEachInstanceField((_, FieldElement field) {
fields.add(constantReferenceGenerator(constant.fields[field]));
}, includeSuperAndInjectedMembers: true);
+ if (backend.classNeedsRti(constant.type.element)) {
+ fields.add(_reifiedTypeArguments(constant.type));
+ }
jsAst.New instantiation = new jsAst.New(constructor, fields);
- return maybeAddTypeArguments(constant.type, instantiation);
+ return instantiation;
}
String stripComments(String rawJavaScript) {
@@ -320,20 +324,23 @@ class ConstantEmitter implements ConstantValueVisitor<jsAst.Expression, Null> {
if (type is InterfaceType &&
!type.treatAsRaw &&
backend.classNeedsRti(type.element)) {
- InterfaceType interface = type;
- RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder;
- Iterable<jsAst.Expression> arguments = interface.typeArguments.map(
- (DartType type) =>
- rtiEncoder.getTypeRepresentationWithPlaceholders(type, (_) {}));
- jsAst.Expression argumentList =
- new jsAst.ArrayInitializer(arguments.toList());
return new jsAst.Call(
getHelperProperty(backend.helpers.setRuntimeTypeInfo),
- [value, argumentList]);
+ [value, _reifiedTypeArguments(type)]);
}
return value;
}
+ jsAst.Expression _reifiedTypeArguments(InterfaceType type) {
+ RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder;
+ Iterable<jsAst.Expression> arguments = type.typeArguments.map(
+ (DartType type) =>
+ rtiEncoder.getTypeRepresentationWithPlaceholders(type, (_) {}));
+ jsAst.Expression argumentList =
+ new jsAst.ArrayInitializer(arguments.toList());
+ return argumentList;
+ }
+
@override
jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
return constantReferenceGenerator(constant.referenced);

Powered by Google App Engine
This is Rietveld 408576698