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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library js_tree_ir_builder;
6
7 import '../../tree_ir/tree_ir_builder.dart' show Builder;
8 import 'glue.dart' show Glue;
9 import '../../dart2jslib.dart' show Selector, InternalErrorFunction;
10 import '../../elements/elements.dart';
11 import '../../cps_ir/cps_ir_nodes.dart' as cps_ir;
12 import '../../tree_ir/tree_ir_nodes.dart';
13
14 /// Subclass of [Builder] that can translate nodes which are specific to the
15 /// JavaScript backend.
16 class JsTreeBuilder extends Builder {
17 final Glue _glue;
18
19 JsTreeBuilder(
20 InternalErrorFunction internalError,
21 Element identicalFunction,
22 this._glue,
23 [Builder parent])
24 : super(internalError, identicalFunction, parent);
25
26 JsTreeBuilder createInnerBuilder() {
27 return new JsTreeBuilder(internalError, identicalFunction, _glue, this);
28 }
29
30 Selector get identicalSelector {
31 return new Selector.call('identical', null, 2);
32 }
33
34 Expression visitIdentical(cps_ir.Identical node) {
35 return new InvokeStatic(
36 identicalFunction,
37 identicalSelector,
38 <Expression>[getVariableReference(node.left),
39 getVariableReference(node.right)]);
40 }
41
42 Expression visitInterceptor(cps_ir.Interceptor node) {
43 Element getInterceptor = _glue.getInterceptorMethod;
44 _glue.registerUseInterceptorInCodegen();
45 return new InvokeStatic(
46 getInterceptor,
47 new Selector.fromElement(getInterceptor),
48 <Expression>[getVariableReference(node.input)]);
49 }
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698