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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart

Issue 360493002: Emit declarations for typedefs that are needed by reflection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 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: sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
index e3856a964693ed5b2519a9b3a41645cbcd99f84a..277917ee30edae6d7943c39a87f29751ad00f2d2 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
@@ -80,32 +80,10 @@ class ClassEmitter extends CodeEmitterHelper {
// [ constructorName, fields,
// fields.map(
// (name) => js('this.# = #', [name, name]))]));
- task.precompiledFunction.add(
- new jsAst.FunctionDeclaration(
- new jsAst.VariableDeclaration(constructorName),
- js('function(#) { #; }',
- [fields,
- fields.map((name) => js('this.# = #', [name, name]))])));
- // TODO(floitsch): do we actually need the name field?
- // TODO(floitsch): these should all go through the namer.
-
- task.precompiledFunction.add(
- js.statement(r'''{
- #.builtin$cls = #;
- if (!"name" in #)
- #.name = #;
- $desc=$collectedClasses.#;
- if ($desc instanceof Array) $desc = $desc[1];
- #.prototype = $desc;
- }''',
- [ constructorName, js.string(constructorName),
- constructorName,
- constructorName, js.string(constructorName),
- constructorName,
- constructorName
- ]));
-
- task.precompiledConstructorNames.add(js('#', constructorName));
+ jsAst.Expression constructorAst = js('function(#) { #; }',
+ [fields,
+ fields.map((name) => js('this.# = #', [name, name]))]);
+ task.emitPrecompiledConstructor(constructorName, constructorAst);
}
/// Returns `true` if fields added.

Powered by Google App Engine
This is Rietveld 408576698