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

Unified Diff: pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart

Issue 1140703006: dart2js: Construct the entire output as a single AST before printing. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Comments 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
index 6db7c711f7ee45cabecf472b20817c2a1f1da389..aa43580b9735ba42b9710e4dc28bd6f1dec531d4 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
@@ -13,35 +13,40 @@ class InterceptorEmitter extends CodeEmitterHelper {
}
}
- void emitGetInterceptorMethod(CodeOutput output,
- String key,
- Set<ClassElement> classes) {
+ jsAst.Expression buildGetInterceptorMethod(String key,
+ Set<ClassElement> classes) {
InterceptorStubGenerator stubGenerator =
new InterceptorStubGenerator(compiler, namer, backend);
jsAst.Expression function =
stubGenerator.generateGetInterceptorMethod(classes);
- output.addBuffer(jsAst.prettyPrint(
- js('${namer.globalObjectFor(backend.interceptorsLibrary)}.# = #',
- [key, function]),
- compiler));
- output.add(N);
+ return function;
}
/**
* Emit all versions of the [:getInterceptor:] method.
*/
- void emitGetInterceptorMethods(CodeOutput output) {
- emitter.addComment('getInterceptor methods', output);
+ jsAst.Statement buildGetInterceptorMethods() {
+ List<jsAst.Statement> parts = <jsAst.Statement>[];
+
+ parts.add(js.comment('getInterceptor methods'));
+
Map<String, Set<ClassElement>> specializedGetInterceptors =
backend.specializedGetInterceptors;
for (String name in specializedGetInterceptors.keys.toList()..sort()) {
Set<ClassElement> classes = specializedGetInterceptors[name];
- emitGetInterceptorMethod(output, name, classes);
+ parts.add(
+ js.statement('#.# = #',
+ [namer.globalObjectFor(backend.interceptorsLibrary),
+ name,
+ buildGetInterceptorMethod(name, classes)]));
}
+
+ return new jsAst.Block(parts);
}
- void emitOneShotInterceptors(CodeOutput output) {
+ jsAst.Statement buildOneShotInterceptors() {
+ List<jsAst.Statement> parts = <jsAst.Statement>[];
List<String> names = backend.oneShotInterceptors.keys.toList();
names.sort();
@@ -51,12 +56,10 @@ class InterceptorEmitter extends CodeEmitterHelper {
for (String name in names) {
jsAst.Expression function =
stubGenerator.generateOneShotInterceptor(name);
- jsAst.Expression assignment =
- js('${globalObject}.# = #', [name, function]);
-
- output.addBuffer(jsAst.prettyPrint(assignment, compiler));
- output.add(N);
+ parts.add(js.statement('${globalObject}.# = #', [name, function]));
}
+
+ return new jsAst.Block(parts);
}
/**
@@ -87,15 +90,12 @@ class InterceptorEmitter extends CodeEmitterHelper {
* `findInterceptorForType`. See declaration of `typeToInterceptor` in
* `interceptors.dart`.
*/
- void emitTypeToInterceptorMap(Program program, CodeOutput output) {
+ jsAst.Statement buildTypeToInterceptorMap(Program program) {
jsAst.Expression array = program.typeToInterceptorMap;
- if (array == null) return;
+ if (array == null) return js.comment("Empty type-to-interceptor map.");
jsAst.Expression typeToInterceptorMap = emitter
.generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP);
- jsAst.Expression assignment = js('# = #', [typeToInterceptorMap, array]);
-
- output.addBuffer(jsAst.prettyPrint(assignment, compiler));
- output.add(N);
+ return js.statement('# = #', [typeToInterceptorMap, array]);
}
}
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698