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

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

Issue 642813005: dart2js: Emit constants in new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 2 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/new_emitter/emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/new_emitter/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/new_emitter/emitter.dart
index 9f7ea0f08ed901142abb4049923f4955383583f9..91b4a399e545526cd65a61bdb9e5cd3afb26636d 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/new_emitter/emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/new_emitter/emitter.dart
@@ -9,9 +9,6 @@ import 'model_emitter.dart';
import '../../common.dart';
import '../../js/js.dart' as js;
-import '../../constants/values.dart' show PrimitiveConstantValue;
-import '../../tree/tree.dart' show DartString;
-
import '../../js_backend/js_backend.dart' show Namer, JavaScriptBackend;
import '../../js_emitter/js_emitter.dart' as emitterTask show
CodeEmitterTask,
@@ -20,11 +17,15 @@ import '../../js_emitter/js_emitter.dart' as emitterTask show
class Emitter implements emitterTask.Emitter {
final Compiler _compiler;
final Namer namer;
+ final ModelEmitter _emitter;
- Emitter(this._compiler, this.namer);
+ Emitter(Compiler compiler, Namer namer)
+ : this._compiler = compiler,
+ this.namer = namer,
+ _emitter = new ModelEmitter(compiler, namer);
void emitProgram(Program program) {
- new ModelEmitter(_compiler).emitProgram(program);
+ _emitter.emitProgram(program);
}
// TODO(floitsch): copied from OldEmitter. Adjust or share.
@@ -68,16 +69,7 @@ class Emitter implements emitterTask.Emitter {
}
js.Expression constantReference(ConstantValue value) {
- if (!value.isPrimitive) return js.string("<<unimplemented>>");
- PrimitiveConstantValue constant = value;
- if (constant.isBool) return new js.LiteralBool(constant.isTrue);
- if (constant.isString) {
- DartString dartString = constant.primitiveValue;
- return js.string(dartString.slowToString());
- }
- if (constant.isNum) return js.number(constant.primitiveValue);
- if (constant.isNull) return new js.LiteralNull();
- return js.string("<<unimplemented>>");
+ return _emitter.constantEmitter.reference(value);
}
void invalidateCaches() {}

Powered by Google App Engine
This is Rietveld 408576698