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

Unified Diff: dart/frog/leg/ssa/builder.dart

Issue 9539009: Generate code that throws an exception on unimplemented features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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 | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/leg/ssa/closure.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/ssa/builder.dart
diff --git a/dart/frog/leg/ssa/builder.dart b/dart/frog/leg/ssa/builder.dart
index 54dc67bbbeab5b57c390a96e5af19677b15aa208..7ceeae0e28885e3cd7c04b347c65b60f7e376cd2 100644
--- a/dart/frog/leg/ssa/builder.dart
+++ b/dart/frog/leg/ssa/builder.dart
@@ -329,7 +329,8 @@ class LocalsHandler {
HInstruction readLocal(Element element) {
if (isAccessedDirectly(element)) {
if (directLocals[element] == null) {
- builder.compiler.internalError("Cannot find value", element: element);
+ builder.compiler.internalError("Cannot find value $element",
+ element: element);
}
return directLocals[element];
} else if (isStoredInClosureField(element)) {
@@ -2068,9 +2069,7 @@ class SsaBuilder implements Visitor {
visitContinueStatement(ContinueStatement node) {
// TODO(lrn): Replace this with a real implementation of continue.
compiler.reportWarning(node, 'continue not implemented');
- DartString string = new DartString.literal('continue not implemented');
- HInstruction message = graph.addNewLiteralString(string);
- close(new HThrow(message));
+ generateUnimplemented('continue not implemented');
}
BreakHandler getLoopBreakHandler(Loop node) {
@@ -2219,7 +2218,7 @@ class SsaBuilder implements Visitor {
}
visitLiteralMap(LiteralMap node) {
- compiler.unimplemented('SsaBuilder.visitLiteralMap', node: node);
+ generateUnimplemented('literal map not implemented', isExpression: true);
}
visitLiteralMapEntry(LiteralMapEntry node) {
@@ -2231,7 +2230,7 @@ class SsaBuilder implements Visitor {
}
visitSwitchStatement(SwitchStatement node) {
- compiler.unimplemented('SsaBuilder.visitSwitchStatement', node: node);
+ generateUnimplemented('switch statement not implemented');
}
visitTryStatement(TryStatement node) {
@@ -2341,4 +2340,18 @@ class SsaBuilder implements Visitor {
visitTypedef(Typedef node) {
compiler.unimplemented('SsaBuilder.visitTypedef', node: node);
}
+
+ generateUnimplemented(String reason, [bool isExpression = false]) {
+ DartString string = new DartString.literal(reason);
+ HInstruction message = graph.addNewLiteralString(string);
+
+ // Normally, we would call [close] here. However, then we hit
+ // another unimplemented feature: aborting loop body. Simply
+ // calling [add] does not work as it asserts that the instruction
+ // isn't a control flow instruction. So we inline parts of [add].
+ current.addAfter(current.last, new HThrow(message));
+ if (isExpression) {
+ stack.add(graph.addNewLiteralNull());
+ }
+ }
}
« no previous file with comments | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/leg/ssa/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698