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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 733053004: cps-ir: Add a test for codegeneration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix two checked mode issues. Created 6 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 | « no previous file | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index 967080ab36f49e0f2ca12392319abab4df14d3e9..39602ce2d7daba5dff3c472e30f7990cd5244bac 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -4,10 +4,14 @@
library code_generator;
+import 'glue.dart';
+
import '../../tree_ir/tree_ir_nodes.dart' as tree_ir;
import '../../js/js.dart' as js;
import '../../elements/elements.dart';
import '../../util/maplet.dart';
+import '../../constants/values.dart';
+import '../../dart2jslib.dart';
class CodegenBailout {
final tree_ir.Node node;
@@ -19,6 +23,10 @@ class CodegenBailout {
}
class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
+ final CodegenRegistry registry;
+
+ final Glue glue;
+
/// Variables to be hoisted at the top of the current function.
List<js.VariableDeclaration> variables = <js.VariableDeclaration>[];
@@ -35,13 +43,15 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
/// Variable names that have already been used. Used to avoid name clashes.
Set<String> usedVariableNames;
- List<js.Parameter> parameters;
+ List<js.Parameter> parameters = new List<js.Parameter>();
List<js.Statement> accumulator = new List<js.Statement>();
js.Block body;
/// Generates JavaScript code for the body of [function].
/// The code will be in [body] and the parameters will be in [parameters].
+ CodeGenerator(this.glue, this.registry);
+
void buildFunction(tree_ir.FunctionDefinition function) {
visitStatement(function.body);
for (tree_ir.Variable parameter in function.parameters) {
@@ -73,8 +83,9 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitConstant(tree_ir.Constant node) {
- return giveup(node);
- // TODO: implement visitConstant
+ ConstantValue constant = node.expression.value;
+ registry.registerCompileTimeConstant(constant);
+ return glue.constantReference(constant);
}
@override
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698