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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 737353002: cps-ir: Implement boolean conversion in and use it to implement '&&', '||', and '?:'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' as values show ConstantValue; 10 import '../constants/values.dart' as values show ConstantValue;
11 import '../dart2jslib.dart' as dart2js show invariant; 11 import '../dart2jslib.dart' as dart2js show invariant;
12 import '../elements/elements.dart'; 12 import '../elements/elements.dart';
13 import '../universe/universe.dart' show Selector, SelectorKind; 13 import '../universe/universe.dart' show Selector, SelectorKind;
14 import '../dart_types.dart' show DartType, GenericType; 14 import '../dart_types.dart' show DartType, GenericType;
15 import 'package:compiler/src/js_backend/codegen/unsugar.dart';
sigurdm 2014/11/20 12:47:28 Package import
15 16
16 abstract class Node { 17 abstract class Node {
17 static int hashCount = 0; 18 static int hashCount = 0;
18 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff; 19 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff;
19 20
20 /// A pointer to the parent node. Is null until set by optimization passes. 21 /// A pointer to the parent node. Is null until set by optimization passes.
21 Node parent; 22 Node parent;
22 23
23 accept(Visitor visitor); 24 accept(Visitor visitor);
24 } 25 }
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 /// If `true`, [body] and [returnContinuation] are `null` and [localConstants] 574 /// If `true`, [body] and [returnContinuation] are `null` and [localConstants]
574 /// is empty. 575 /// is empty.
575 bool get isAbstract => body == null; 576 bool get isAbstract => body == null;
576 } 577 }
577 578
578 List<Reference<Primitive>> _referenceList(Iterable<Primitive> definitions) { 579 List<Reference<Primitive>> _referenceList(Iterable<Primitive> definitions) {
579 return definitions.map((e) => new Reference<Primitive>(e)).toList(); 580 return definitions.map((e) => new Reference<Primitive>(e)).toList();
580 } 581 }
581 582
582 abstract class Visitor<T> { 583 abstract class Visitor<T> {
584 const Visitor();
585
583 T visit(Node node) => node.accept(this); 586 T visit(Node node) => node.accept(this);
584 // Abstract classes. 587 // Abstract classes.
585 T visitNode(Node node) => null; 588 T visitNode(Node node) => null;
586 T visitExpression(Expression node) => visitNode(node); 589 T visitExpression(Expression node) => visitNode(node);
587 T visitDefinition(Definition node) => visitNode(node); 590 T visitDefinition(Definition node) => visitNode(node);
588 T visitPrimitive(Primitive node) => visitDefinition(node); 591 T visitPrimitive(Primitive node) => visitDefinition(node);
589 T visitCondition(Condition node) => visitNode(node); 592 T visitCondition(Condition node) => visitNode(node);
590 593
591 // Concrete classes. 594 // Concrete classes.
592 T visitFunctionDefinition(FunctionDefinition node) => visitNode(node); 595 T visitFunctionDefinition(FunctionDefinition node) => visitNode(node);
(...skipping 18 matching lines...) Expand all
611 T visitConstant(Constant node) => visitPrimitive(node); 614 T visitConstant(Constant node) => visitPrimitive(node);
612 T visitThis(This node) => visitPrimitive(node); 615 T visitThis(This node) => visitPrimitive(node);
613 T visitReifyTypeVar(ReifyTypeVar node) => visitPrimitive(node); 616 T visitReifyTypeVar(ReifyTypeVar node) => visitPrimitive(node);
614 T visitCreateFunction(CreateFunction node) => visitPrimitive(node); 617 T visitCreateFunction(CreateFunction node) => visitPrimitive(node);
615 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node); 618 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node);
616 T visitParameter(Parameter node) => visitPrimitive(node); 619 T visitParameter(Parameter node) => visitPrimitive(node);
617 T visitContinuation(Continuation node) => visitDefinition(node); 620 T visitContinuation(Continuation node) => visitDefinition(node);
618 621
619 // Conditions. 622 // Conditions.
620 T visitIsTrue(IsTrue node) => visitCondition(node); 623 T visitIsTrue(IsTrue node) => visitCondition(node);
624
625 // JavaScript specific nodes.
626 T visitBoolify(Boolify node) => visitIsTrue(node);
621 } 627 }
622 628
623 /// Recursively visits the entire CPS term, and calls abstract `process*` 629 /// Recursively visits the entire CPS term, and calls abstract `process*`
624 /// (i.e. `processLetPrim`) functions in pre-order. 630 /// (i.e. `processLetPrim`) functions in pre-order.
625 abstract class RecursiveVisitor extends Visitor { 631 abstract class RecursiveVisitor extends Visitor {
sigurdm 2014/11/20 12:47:28 Should implement T visitBoolify(Boolify node) =>
632 const RecursiveVisitor();
633
626 // Ensures that RecursiveVisitor contains overrides for all relevant nodes. 634 // Ensures that RecursiveVisitor contains overrides for all relevant nodes.
627 // As a rule of thumb, nodes with structure to traverse should be overridden 635 // As a rule of thumb, nodes with structure to traverse should be overridden
628 // with the appropriate visits in this class (for example, visitLetCont), 636 // with the appropriate visits in this class (for example, visitLetCont),
629 // while leaving other nodes for subclasses (i.e., visitLiteralList). 637 // while leaving other nodes for subclasses (i.e., visitLiteralList).
630 visitNode(Node node) { 638 visitNode(Node node) {
631 throw "RecursiveVisitor is stale, add missing visit overrides"; 639 throw "RecursiveVisitor is stale, add missing visit overrides";
632 } 640 }
633 641
634 processReference(Reference ref) {} 642 processReference(Reference ref) {}
635 643
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 release(node.parameters[i]); 953 release(node.parameters[i]);
946 } 954 }
947 } 955 }
948 956
949 void visitIsTrue(IsTrue node) { 957 void visitIsTrue(IsTrue node) {
950 visitReference(node.value); 958 visitReference(node.value);
951 } 959 }
952 960
953 } 961 }
954 962
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698