Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix exception handler code-gen.
  • Loading branch information
jnthn committed Apr 7, 2013
1 parent 8a972fd commit f6b38e8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/org/perl6/nqp/jast2bc/JASTToJVMBytecode.java
Expand Up @@ -132,6 +132,7 @@ private static boolean processMethod(BufferedReader in, ClassWriter c, String cl
Map<String, VariableDef> localVariables = new HashMap<String, VariableDef>();
Map<String, Label> labelMap = new HashMap<String, Label>();
Stack<Label> tryStartStack = new Stack<Label>();
Stack<Label> tryEndStack = new Stack<Label>();
int curArgIndex = 1;

MethodVisitor m = null;
Expand Down Expand Up @@ -260,7 +261,15 @@ else if (curLine.equals(".try")) {
tryStartStack.push(start);
}
else if (curLine.startsWith(".catch ")) {
String typeName = curLine.substring(".catch ".length());
Label afterCatch = new Label();
m.visitJumpInsn(Opcodes.GOTO, afterCatch);
tryEndStack.push(afterCatch);

String typeName = curLine.substring(".catch ".length());
if (typeName.equals(""))
typeName = null;
else
typeName = typeName.substring(1, typeName.length() - 1);
Label start = tryStartStack.peek();
Label end = new Label();
Label handler = new Label();
Expand All @@ -270,6 +279,7 @@ else if (curLine.startsWith(".catch ")) {
}
else if (curLine.equals(".endtry")) {
tryStartStack.pop();
m.visitLabel(tryEndStack.pop());
}
else {
throw new Exception("Don't understand directive: " + curLine);
Expand Down

0 comments on commit f6b38e8

Please sign in to comment.