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

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

Issue 795933005: Create a Tree IR builder for JavaScript specific nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move identicalFunction. Created 6 years 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/dart_backend/backend.dart ('k') | 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/js_tree_builder.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/js_tree_builder.dart b/pkg/compiler/lib/src/js_backend/codegen/js_tree_builder.dart
new file mode 100644
index 0000000000000000000000000000000000000000..32dde10d0725e8135eba27812b8f0af8cf3040a1
--- /dev/null
+++ b/pkg/compiler/lib/src/js_backend/codegen/js_tree_builder.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library js_tree_ir_builder;
+
+import '../../tree_ir/tree_ir_builder.dart' show Builder;
+import 'glue.dart' show Glue;
+import '../../dart2jslib.dart' show Selector, InternalErrorFunction;
+import '../../elements/elements.dart';
+import '../../cps_ir/cps_ir_nodes.dart' as cps_ir;
+import '../../tree_ir/tree_ir_nodes.dart';
+
+/// Subclass of [Builder] that can translate nodes which are specific to the
+/// JavaScript backend.
+class JsTreeBuilder extends Builder {
+ final Glue _glue;
+ final Element identicalFunction;
+
+ JsTreeBuilder(
+ InternalErrorFunction internalError,
+ this.identicalFunction,
+ this._glue,
+ [Builder parent])
+ : super(internalError, parent);
+
+ JsTreeBuilder createInnerBuilder() {
+ return new JsTreeBuilder(internalError, identicalFunction, _glue, this);
+ }
+
+ Selector get identicalSelector {
+ return new Selector.call('identical', null, 2);
+ }
+
+ Expression visitIdentical(cps_ir.Identical node) {
+ return new InvokeStatic(
+ identicalFunction,
+ identicalSelector,
+ <Expression>[getVariableReference(node.left),
+ getVariableReference(node.right)]);
+ }
+
+ Expression visitInterceptor(cps_ir.Interceptor node) {
+ Element getInterceptor = _glue.getInterceptorMethod;
+ _glue.registerUseInterceptorInCodegen();
+ return new InvokeStatic(
+ getInterceptor,
+ new Selector.fromElement(getInterceptor),
+ <Expression>[getVariableReference(node.input)]);
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698