Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

exceptions stuff, not working :D

  • Loading branch information...
commit ac8b9417642b4aeca44a8bc2aabe19e16a7f9761 1 parent 8d7388a
@badlogic authored
View
2  jack/src/com/badlogic/jack/generators/StatementGenerator.java
@@ -242,6 +242,7 @@ private void generateStatement(Stmt stmt) {
List<Trap> traps = tries.get(stmt);
for(Trap trap: traps) {
writer.wl("try {");
+ writer.push();
}
}
@@ -366,6 +367,7 @@ else if(rightOp.getType() instanceof NullType) {
// emit catches if any
if(catches.containsKey(stmt)) {
List<Trap> traps = catches.get(stmt);
+ writer.pop();
for(Trap trap: traps) {
writer.wl("} catch(" + Mangling.mangle(trap.getException()) + "* e) { _exception = e; goto " + labels.get(trap.getHandlerUnit()) + "; }");
}
View
42 runtime/jack-tests/src/jack/tests/Exceptions.java
@@ -17,23 +17,53 @@ public void simpleCatch() {
}
}
- public void controlCatch() {
+ public void ifCatch() {
try {
- for(int i = 0; i < 10; i++) {
- if(i == 3) {
- return;
- }
+ int i = 2;
+ if(i == 3) {
+ return;
}
} catch(Throwable t) {
}
}
+ public void forCatch() {
+ try {
+ for(int i = 0; i< 10; i++) {
+ if(i == 0) return;
+ }
+ } catch(Throwable t) {
+ }
+ }
+
+ public void whileCatch() {
+ try {
+ int i = 0;
+ while(true) {
+ if(i == 0) return;
+ }
+ } catch(Throwable t) {
+ }
+ }
+
+ public void doCatch() {
+ try {
+ int i = 0;
+ do {
+ if(i == 0) return;
+ } while(true);
+ } catch(Exception e) {
+
+ }
+ }
+
public void complexCatch() {
try {
try {
try {
checked();
+ return;
} catch(ClassNotFoundException e) {
} catch(Throwable e) {
@@ -41,6 +71,8 @@ public void complexCatch() {
}
} catch(NullPointerException e) {
+ } catch(Throwable e) {
+
}
} catch(Exception e) {
Please sign in to comment.
Something went wrong with that request. Please try again.