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

Unified Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Issue 2280133002: implement kernel -> ssa for literals (Closed)
Patch Set: put ast accesses in separate class Created 4 years, 4 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/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
new file mode 100644
index 0000000000000000000000000000000000000000..f5d271f1cf4dd1acf030c4fcb7160aa1485bbb18
--- /dev/null
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:kernel/ast.dart' as ir;
+
+import '../constants/values.dart';
+import '../diagnostics/invariant.dart';
+import '../elements/elements.dart';
+import '../js_backend/js_backend.dart';
+import '../tree/tree.dart' as ast;
+
+/// A helper class that abstracts all accesses of the AST from Kernel nodes.
+///
+/// The goal is to remove all need for the AST from the Kernel SSA builder.
+class KernelAstAdapter {
+ final JavaScriptBackend backend;
+ final ResolvedAst resolvedAst;
+ final Map<ir.Node, ast.Node> nodeToAst;
+
+ KernelAstAdapter(this.backend, this.resolvedAst, this.nodeToAst);
+
+ ConstantValue getConstantFor(ir.Node node) {
Siggi Cherem (dart-lang) 2016/08/26 20:27:11 it seems to me like you only use this for Symbol,
+ ast.Node astNode = nodeToAst[node];
+ ConstantValue constantValue = backend.constants
+ .getConstantValueForNode(astNode, resolvedAst.elements);
+ assert(invariant(astNode, constantValue != null,
+ message: 'No constant computed for $node'));
+ return constantValue;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698