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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 11415168: Revert "Emit constants using ASTs" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/namer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
index b397568913861727b4e025a242f7565cd9c8f769..7e364c094b0b6bf319dfd1934609c1a740583e22 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
@@ -1812,11 +1812,44 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
void generateConstant(Constant constant) {
- if (constant.isFunction()) {
- FunctionConstant function = constant;
- world.registerStaticUse(function.element);
+ Namer namer = backend.namer;
+ // TODO(floitsch): should we use the ConstantVisitor here?
+ if (!constant.isObject()) {
+ if (constant.isBool()) {
+ BoolConstant boolConstant = constant;
+ push(newLiteralBool(boolConstant.value));
+ } else if (constant.isNum()) {
+ // TODO(floitsch): get rid of the code buffer.
+ CodeBuffer buffer = new CodeBuffer();
+ backend.emitter.writeConstantToBuffer(constant, buffer);
+ push(new js.LiteralNumber(buffer.toString()));
+ } else if (constant.isNull()) {
+ push(new js.LiteralNull());
+ } else if (constant.isString()) {
+ // TODO(floitsch): get rid of the code buffer.
+ CodeBuffer buffer = new CodeBuffer();
+ backend.emitter.writeConstantToBuffer(constant, buffer);
+ push(new js.LiteralString(buffer.toString()));
+ } else if (constant.isFunction()) {
+ FunctionConstant function = constant;
+ world.registerStaticUse(function.element);
+ push(new js.VariableUse(namer.isolateAccess(function.element)));
+ } else if (constant.isSentinel()) {
+ // TODO(floitsch): get rid of the code buffer.
+ CodeBuffer buffer = new CodeBuffer();
+ backend.emitter.writeConstantToBuffer(constant, buffer);
+ push(new js.VariableUse(buffer.toString()));
+ } else {
+ compiler.internalError(
+ "The compiler does not know how generate code for "
+ "constant $constant");
+ }
+ } else {
+ String name = namer.constantName(constant);
+ js.VariableUse currentIsolateUse =
+ new js.VariableUse(backend.namer.CURRENT_ISOLATE);
+ push(new js.PropertyAccess.field(currentIsolateUse, name));
}
- push(backend.emitter.constantReference(constant));
}
visitConstant(HConstant node) {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/namer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698