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

Unified Diff: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart

Issue 1175973005: dart2js cps: Introduce some built-in operators in type propagation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Status files Created 5 years, 6 months 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/tree_ir/tree_ir_builder.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
index 2ca8fdf0c624e8dde3495dda29bd4629fd0d2948..2962837dd758d53d7b918c86bb6b1d78edb742e9 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
@@ -11,6 +11,9 @@ import '../elements/elements.dart';
import '../io/source_information.dart' show SourceInformation;
import '../universe/universe.dart' show Selector;
+import '../cps_ir/builtin_operator.dart';
+export '../cps_ir/builtin_operator.dart';
+
// The Tree language is the target of translation out of the CPS-based IR.
//
// The translation from CPS to Dart consists of several stages. Among the
@@ -344,6 +347,26 @@ class TypeOperator extends Expression {
String get operator => isTypeTest ? 'is' : 'as';
}
+/**
+ * Apply a built-in operator.
+ *
+ * It must be known that the arguments have the proper types.
+ * Null is not a valid argument to any of the built-in operators.
+ */
+class ApplyBuiltinOperator extends Expression {
+ BuiltinOperator operator;
+ List<Expression> arguments;
+
+ ApplyBuiltinOperator(this.operator, this.arguments);
+
+ accept(ExpressionVisitor visitor) {
+ return visitor.visitApplyBuiltinOperator(this);
+ }
+ accept1(ExpressionVisitor1 visitor, arg) {
+ return visitor.visitApplyBuiltinOperator(this, arg);
+ }
+}
+
/// A conditional expression.
class Conditional extends Expression {
Expression condition;
@@ -378,6 +401,8 @@ class LogicalOperator extends Expression {
}
/// Logical negation.
+// TODO(asgerf): Replace this class with the IsFalsy builtin operator?
+// Right now the tree builder compiles IsFalsy to Not.
class Not extends Expression {
Expression operand;
@@ -797,6 +822,7 @@ abstract class ExpressionVisitor<E> {
E visitReadTypeVariable(ReadTypeVariable node);
E visitTypeExpression(TypeExpression node);
E visitCreateInvocationMirror(CreateInvocationMirror node);
+ E visitApplyBuiltinOperator(ApplyBuiltinOperator node);
}
abstract class ExpressionVisitor1<E, A> {
@@ -827,6 +853,7 @@ abstract class ExpressionVisitor1<E, A> {
E visitReadTypeVariable(ReadTypeVariable node, A arg);
E visitTypeExpression(TypeExpression node, A arg);
E visitCreateInvocationMirror(CreateInvocationMirror node, A arg);
+ E visitApplyBuiltinOperator(ApplyBuiltinOperator node, A arg);
}
abstract class StatementVisitor<S> {
@@ -1025,6 +1052,10 @@ abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor {
}
visitUnreachable(Unreachable node) {}
+
+ visitApplyBuiltinOperator(ApplyBuiltinOperator node) {
+ node.arguments.forEach(visitExpression);
+ }
}
abstract class Transformer implements ExpressionVisitor<Expression>,
@@ -1225,4 +1256,9 @@ class RecursiveTransformer extends Transformer {
visitUnreachable(Unreachable node) {
return node;
}
+
+ visitApplyBuiltinOperator(ApplyBuiltinOperator node) {
+ _replaceExpressions(node.arguments);
+ return node;
+ }
}
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698