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

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

Issue 9351020: Implement try/catch without finally, and without type checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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
Index: frog/leg/ssa/codegen.dart
===================================================================
--- frog/leg/ssa/codegen.dart (revision 3986)
+++ frog/leg/ssa/codegen.dart (working copy)
@@ -220,7 +220,7 @@
HInstruction instruction = node.first;
while (instruction != null) {
- if (instruction is HGoto || instruction is HExit) {
+ if (instruction is HGoto || instruction is HExit || instruction is HTry) {
visit(instruction);
return;
} else if (!instruction.generateAtUseSite()) {
@@ -350,6 +350,39 @@
visitBasicBlock(dominated[0]);
}
+ visitTry(HTry node) {
+ addIndentation();
+ buffer.add('try {\n');
+ indent++;
+ List<HBasicBlock> successors = node.block.successors;
+ visitBasicBlock(successors[0]);
+ indent--;
+
+ if (node.finallyBlock != successors[1]) {
+ addIndentation();
+ buffer.add('} catch (e) {\n');
+ indent++;
+ }
+
+ for (int i = 1; i < successors.length - 1; i++) {
+ // TODO(ngeoffray): add the type check.
+ visitBasicBlock(successors[i]);
+ }
+
+ if (node.finallyBlock == null) {
+ // TODO(ngeoffray): add the type check.
+ visitBasicBlock(successors[successors.length - 1]);
+ } else {
+ addIndentation();
+ buffer.add('} finally {\n');
+ indent++;
+ visitBasicBlock(node.finallyBlock);
+ }
+ indent--;
+ addIndentation();
+ buffer.add('}\n');
+ }
+
visitIf(HIf node) {
startIf(node);
assert(!node.generateAtUseSite());
@@ -477,6 +510,10 @@
if (node.receiver != null) {
use(node.receiver);
buffer.add('.');
+ } else {
+ // TODO(ngeoffray): Remove the 'var' once we don't globally box
+ // variables used in a try/catch.
+ buffer.add('var ');
}
String name = JsNames.getValid('${node.element.name}');
buffer.add(name);

Powered by Google App Engine
This is Rietveld 408576698