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

Unified Diff: pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart

Issue 1126423002: Avoid reparsing metadata expressions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
Index: pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
index 23646b7d6436cf3c52d6c31c6a86da2415abb94e..6cd675129657828cf0d7e8f49a6a2d572b8c8d7b 100644
--- a/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
@@ -134,7 +134,8 @@ class ModelEmitter {
// deferred hash (which depends on the output) when emitting the main
// fragment.
fragments.skip(1).forEach((DeferredFragment deferredUnit) {
- List<String> types = program.metadataTypes[deferredUnit.outputUnit];
+ List<js.Expression> types =
+ program.metadataTypes[deferredUnit.outputUnit];
js.Expression ast = emitDeferredFragment(types, deferredUnit,
program.holders);
String code = js.prettyPrint(ast, compiler).getText();
@@ -417,26 +418,19 @@ class ModelEmitter {
}
List<js.Property> emitMetadata(Program program) {
-
List<js.Property> metadataGlobals = <js.Property>[];
-
- js.Property createGlobal(List<String> list, String global) {
- String listAsString = "[${list.join(",")}]";
- js.Expression metadata =
- js.js.uncachedExpressionTemplate(listAsString).instantiate([]);
- return new js.Property(js.string(global), metadata);
- }
-
- metadataGlobals.add(createGlobal(program.metadata, METADATA));
- List<String> types =
+ metadataGlobals.add(new js.Property(
+ js.string(METADATA), new js.ArrayInitializer(program.metadata)));
+ List<js.Expression> types =
program.metadataTypes[program.fragments.first.outputUnit];
- if (types == null) types = <String>[];
- metadataGlobals.add(createGlobal(types, TYPES));
+ if (types == null) types = <js.Expression>[];
+ metadataGlobals.add(new js.Property(
+ js.string(TYPES), new js.ArrayInitializer(types)));
return metadataGlobals;
}
- js.Expression emitDeferredFragment(List<String> types,
+ js.Expression emitDeferredFragment(List<js.Expression> types,
DeferredFragment fragment,
List<Holder> holders) {
// TODO(floitsch): initialize eager classes.
@@ -462,7 +456,7 @@ class ModelEmitter {
js.Expression deferredTypes = types == null
? js.string("[]")
- : js.string("[${types.join(",")}]");
+ : unparse(compiler, new js.ArrayInitializer(types));
js.ArrayInitializer hunk =
new js.ArrayInitializer([deferredArray, immediateString,
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/model.dart ('k') | pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698