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

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

Issue 2290893002: kernel -> ssa: support static invocations and variable gets (Closed)
Patch Set: rename typemask function 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | tests/compiler/dart2js/kernel/helper.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 f5d271f1cf4dd1acf030c4fcb7160aa1485bbb18..20768999e5c928668d8feff6b22daf113a65d026 100644
--- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -9,23 +9,53 @@ import '../diagnostics/invariant.dart';
import '../elements/elements.dart';
import '../js_backend/js_backend.dart';
import '../tree/tree.dart' as ast;
+import '../types/masks.dart';
+import '../universe/side_effects.dart';
+
+import 'types.dart';
/// 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;
+ final JavaScriptBackend _backend;
+ final ResolvedAst _resolvedAst;
+ final Map<ir.Node, ast.Node> _nodeToAst;
+ final Map<ir.Node, Element> _nodeToElement;
- KernelAstAdapter(this.backend, this.resolvedAst, this.nodeToAst);
+ KernelAstAdapter(this._backend, this._resolvedAst, this._nodeToAst,
+ this._nodeToElement, Map<FunctionElement, ir.Member> functions) {
+ for (FunctionElement functionElement in functions.keys) {
+ _nodeToElement[functions[functionElement]] = functionElement;
+ }
+ }
- ConstantValue getConstantFor(ir.Node node) {
- ast.Node astNode = nodeToAst[node];
- ConstantValue constantValue = backend.constants
- .getConstantValueForNode(astNode, resolvedAst.elements);
+ ConstantValue getConstantForSymbol(ir.SymbolLiteral node) {
+ 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;
}
+
+ Element getElement(ir.Node node) {
+ Element result = _nodeToElement[node];
+ assert(result != null);
+ return result;
+ }
+
+ bool getCanThrow(ir.Procedure procedure) {
+ FunctionElement function = getElement(procedure);
+ return !_backend.compiler.world.getCannotThrow(function);
+ }
+
+ TypeMask returnTypeOf(ir.Procedure node) {
+ return TypeMaskFactory.inferredReturnTypeForElement(
+ getElement(node), _backend.compiler);
+ }
+
+ SideEffects getSideEffects(ir.Node node) {
+ return _backend.compiler.world.getSideEffectsOfElement(getElement(node));
+ }
}
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | tests/compiler/dart2js/kernel/helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698