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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart

Issue 11299009: Support type literals as compile-time constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month 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: 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 a9e49c0f3a94f4bd2e4135cc72eef5626c55527f..e8621a5d91c28c3d0ddf9cfba946603834757f0c 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart
@@ -196,6 +196,28 @@ class ConstantEmitter implements ConstantVisitor {
}
}
+ void visitType(TypeConstant constant) {
+ if (shouldEmitCanonicalVersion) {
+ emitCanonicalVersion(constant);
+ } else {
+ SourceString helperSourceName =
+ const SourceString('createRuntimeType');
+ Element helper = compiler.findHelper(helperSourceName);
+ JavaScriptBackend backend = compiler.backend;
+ String helperName = backend.namer.getName(helper);
+ DartType type = constant.representedType;
+ Element element = type.element;
+ String typeName;
+ if (type.kind == TypeKind.INTERFACE) {
+ typeName = backend.rti.generateRuntimeTypeString(element, 0);
+ } else {
+ assert(type.kind == TypeKind.TYPEDEF);
+ typeName = element.name.slowToString();
floitsch 2012/11/20 16:25:43 Discuss with Erik if (and potentially how) this sh
+ }
+ buffer.add("${namer.CURRENT_ISOLATE}.$helperName('$typeName')");
+ }
+ }
+
void visitConstructed(ConstructedConstant constant) {
if (shouldEmitCanonicalVersion) {
emitCanonicalVersion(constant);

Powered by Google App Engine
This is Rietveld 408576698