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

Unified Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.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
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | pkg/compiler/lib/src/use_unused_api.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
diff --git a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
index ecd4c441f97ec9e481b82f676ccfe736294e5a94..a696d65fbc5547dba9d8171439e184d2737dba42 100644
--- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -564,20 +564,6 @@ class KernelAstAdapter extends KernelElementAdapterMixin {
getClass(cls), getDartTypes(typeArguments));
}
- /// Converts [annotations] into a list of [ConstantExpression]s.
- List<ConstantExpression> getMetadata(List<ir.Expression> annotations) {
- List<ConstantExpression> metadata = <ConstantExpression>[];
- annotations.forEach((ir.Expression node) {
- ConstantExpression constant = node.accept(new Constantifier(this));
- if (constant == null) {
- throw new UnsupportedError(
- 'No constant for ${DebugPrinter.prettyPrint(node)}');
- }
- metadata.add(constant);
- });
- return metadata;
- }
-
@override
LibraryEntity lookupLibrary(Uri uri) {
return _compiler.libraryLoader.lookupLibrary(uri);
@@ -730,60 +716,6 @@ class DartTypeConverter extends ir.DartTypeVisitor<ResolutionDartType> {
}
}
-/// Visitor that converts a kernel constant expression into a
-/// [ConstantExpression].
-class Constantifier extends ir.ExpressionVisitor<ConstantExpression> {
- final KernelAstAdapter astAdapter;
-
- Constantifier(this.astAdapter);
-
- @override
- ConstantExpression visitConstructorInvocation(ir.ConstructorInvocation node) {
- ConstructorElement constructor =
- astAdapter.getElement(node.target).declaration;
- List<ResolutionDartType> typeArguments = <ResolutionDartType>[];
- for (ir.DartType type in node.arguments.types) {
- typeArguments.add(astAdapter.getDartType(type));
- }
- List<ConstantExpression> arguments = <ConstantExpression>[];
- List<String> argumentNames = <String>[];
- for (ir.Expression argument in node.arguments.positional) {
- ConstantExpression constant = argument.accept(this);
- if (constant == null) return null;
- arguments.add(constant);
- }
- for (ir.NamedExpression argument in node.arguments.named) {
- argumentNames.add(argument.name);
- ConstantExpression constant = argument.value.accept(this);
- if (constant == null) return null;
- arguments.add(constant);
- }
- return new ConstructedConstantExpression(
- constructor.enclosingClass.thisType.createInstantiation(typeArguments),
- constructor,
- new CallStructure(
- node.arguments.positional.length + argumentNames.length,
- argumentNames),
- arguments);
- }
-
- @override
- ConstantExpression visitStaticGet(ir.StaticGet node) {
- Element element = astAdapter.getMember(node.target);
- if (element.isField) {
- return new VariableConstantExpression(element);
- }
- astAdapter.reporter.internalError(
- CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element.");
- return null;
- }
-
- @override
- ConstantExpression visitStringLiteral(ir.StringLiteral node) {
- return new StringConstantExpression(node.value);
- }
-}
-
class KernelJumpTarget extends JumpTarget {
static int index = 0;
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | pkg/compiler/lib/src/use_unused_api.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698