X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FParser.java;fp=src%2Forg%2Fxwt%2Fjs%2FParser.java;h=0583202e6a3759e24715c629d24aff969114c923;hb=87c3b60d5ad529a02a85aaa184ac98779b967463;hp=ee04b7eb484be47d59c1234de5a0072868931c26;hpb=91fa07eeabb1c256410385947e6a76f1e45c8b48;p=org.ibex.core.git diff --git a/src/org/xwt/js/Parser.java b/src/org/xwt/js/Parser.java index ee04b7e..0583202 100644 --- a/src/org/xwt/js/Parser.java +++ b/src/org/xwt/js/Parser.java @@ -727,20 +727,57 @@ class Parser extends Lexer implements ByteCodes { int catchJMPDistance = -1; if (peekToken() == CATCH) { catchJMPDistance = b.size - tryInsn; - String exceptionVar; - getToken(); - consume(LP); - consume(NAME); - exceptionVar = string; - consume(RP); - b.add(parserLine, TOPSCOPE); // the exception is on top of the stack; put it to the chosen name - b.add(parserLine, SWAP); - b.add(parserLine, LITERAL,exceptionVar); - b.add(parserLine, SWAP); - b.add(parserLine, PUT); - b.add(parserLine, POP); - b.add(parserLine, POP); - parseStatement(b, null); + while(peekToken() == CATCH) { + String exceptionVar; + getToken(); + consume(LP); + consume(NAME); + exceptionVar = string; + int[] writebacks = new int[] { -1, -1, -1 }; + if (peekToken() != RP) { + // extended XWT catch block: catch(e faultCode "foo.bar.baz") + consume(NAME); + String propName = string; + b.add(parserLine, DUP); + b.add(parserLine, LITERAL, string); + b.add(parserLine, GET); + b.add(parserLine, DUP); + b.add(parserLine, LITERAL, null); + b.add(parserLine, EQ); + b.add(parserLine, JT); + writebacks[0] = b.size - 1; + if (peekToken() == STRING) { + consume(STRING); + b.add(parserLine, DUP); + b.add(parserLine, LITERAL, string); + b.add(parserLine, LT); + b.add(parserLine, JT); + writebacks[1] = b.size - 1; + b.add(parserLine, LITERAL, string + "/"); // (slash is ASCII after dot) + b.add(parserLine, GE); + b.add(parserLine, JT); + writebacks[2] = b.size - 1; + } else { + consume(NUMBER); + b.add(parserLine, LITERAL, number); + b.add(parserLine, EQ); + b.add(parserLine, JF); + writebacks[1] = b.size - 1; + } + } + consume(RP); + // the exception is on top of the stack; put it to the chosen name + b.add(parserLine, TOPSCOPE); + b.add(parserLine, SWAP); + b.add(parserLine, LITERAL,exceptionVar); + b.add(parserLine, SWAP); + b.add(parserLine, PUT); + b.add(parserLine, POP); + b.add(parserLine, POP); + parseStatement(b, null); + b.add(parserLine, LITERAL, null); // so we have something to pop + for(int i=0; i<3; i++) if (writebacks[i] != -1) b.set(i, JS.N(b.size - i)); + } // pop the try and catch markers b.add(parserLine,POP); b.add(parserLine,POP);