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

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

Issue 2545153002: Handle synthetic nodes use to throw exceptions (Closed)
Patch Set: Also handle malformed type Created 4 years 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
index a392ec8bd077f5545fdb1d39eb9e5b080d4acce2..3bcb363e0cf2ca4b0025d770c52dbecd45b7ea36 100644
--- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -72,6 +72,9 @@ class KernelAstAdapter {
_compiler.globalInference.results.resultOf(e);
ConstantValue getConstantForSymbol(ir.SymbolLiteral node) {
+ if (kernel.syntheticNodes.contains(node)) {
+ return _backend.constantSystem.createSymbol(_compiler, node.value);
+ }
ast.Node astNode = getNode(node);
ConstantValue constantValue = _backend.constants
.getConstantValueForNode(astNode, _resolvedAst.elements);
@@ -103,6 +106,16 @@ class KernelAstAdapter {
return result;
}
+ ast.Node getNodeOrNull(ir.Node node) {
+ return _nodeToAst[node];
+ }
+
+ void assertNodeIsSynthetic(ir.Node node) {
+ assert(invariant(
+ CURRENT_ELEMENT_SPANNABLE, kernel.syntheticNodes.contains(node),
+ message: "No synthetic marker found for $node"));
+ }
+
Local getLocal(ir.VariableDeclaration variable) {
// If this is a synthetic local, return the synthetic local
if (variable.name == null) {
@@ -206,7 +219,12 @@ class KernelAstAdapter {
return _resultOf(_target).typeOfSend(getNode(send));
}
- TypeMask typeOfNewList(Element owner, ir.ListLiteral listLiteral) {
+ TypeMask typeOfListLiteral(Element owner, ir.ListLiteral listLiteral) {
+ ast.Node node = getNodeOrNull(listLiteral);
+ if (node == null) {
+ assertNodeIsSynthetic(listLiteral);
+ return _compiler.closedWorld.commonMasks.growableListType;
+ }
return _resultOf(owner).typeOfNewList(getNode(listLiteral)) ??
_compiler.closedWorld.commonMasks.dynamicType;
}
@@ -404,6 +422,21 @@ class KernelAstAdapter {
return types.map(getDartType).toList();
}
+ DartType getDartTypeOfListLiteral(ir.ListLiteral list) {
+ ast.Node node = getNodeOrNull(list);
+ if (node != null) return elements.getType(node);
+ assertNodeIsSynthetic(list);
+ return _compiler.coreTypes.listType(getDartType(list.typeArgument));
+ }
+
+ DartType getDartTypeOfMapLiteral(ir.MapLiteral literal) {
+ ast.Node node = getNodeOrNull(literal);
+ if (node != null) return elements.getType(node);
+ assertNodeIsSynthetic(literal);
+ return _compiler.coreTypes
+ .mapType(getDartType(literal.keyType), getDartType(literal.valueType));
+ }
+
DartType getFunctionReturnType(ir.FunctionNode node) {
return getDartType(node.returnType);
}

Powered by Google App Engine
This is Rietveld 408576698