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

Unified Diff: pkg/compiler/lib/src/kernel/constant_visitor.dart

Issue 2669703003: Refactor ConstantExpression/ConstantConstructor to use entities. (Closed)
Patch Set: Created 3 years, 11 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
Index: pkg/compiler/lib/src/kernel/constant_visitor.dart
diff --git a/pkg/compiler/lib/src/kernel/constant_visitor.dart b/pkg/compiler/lib/src/kernel/constant_visitor.dart
index 3d0405d8f6a81d6cf8b7419e2b4bc1b1c786f9c7..239bf88c4cd1cf0e3569f9bc6e6b4eead3f1f1a6 100644
--- a/pkg/compiler/lib/src/kernel/constant_visitor.dart
+++ b/pkg/compiler/lib/src/kernel/constant_visitor.dart
@@ -5,6 +5,7 @@
import 'package:kernel/ast.dart' as ir;
import '../constants/expressions.dart';
+import '../elements/elements.dart' show ConstructorElement;
import 'kernel.dart';
/// Visitor that converts a [ConstantExpression] into a kernel constant
@@ -78,11 +79,17 @@ class ConstantVisitor extends ConstantExpressionVisitor<ir.Node, Kernel> {
}
@override
- ir.Node visitVariable(VariableConstantExpression exp, Kernel kernel) {
+ ir.Node visitField(FieldConstantExpression exp, Kernel kernel) {
return new ir.StaticGet(kernel.fieldToIr(exp.element));
}
@override
+ ir.Node visitLocalVariable(
+ LocalVariableConstantExpression exp, Kernel kernel) {
+ throw new UnimplementedError('${exp.toStructuredText()} is not supported.');
+ }
+
+ @override
ir.Node visitType(TypeConstantExpression exp, Kernel kernel) {
throw new UnimplementedError('${exp.toStructuredText()} is not supported.');
}
@@ -114,8 +121,9 @@ class ConstantVisitor extends ConstantExpressionVisitor<ir.Node, Kernel> {
}
}
ir.Arguments arguments = new ir.Arguments(positional, named: named);
+ ConstructorElement constructor = exp.target;
return new ir.ConstructorInvocation(
- kernel.functionToIr(exp.target), arguments,
+ kernel.functionToIr(constructor), arguments,
isConst: true);
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/type_variable_handler.dart ('k') | pkg/compiler/lib/src/kernel/element_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698