/** * Adds a finally clause for earch return statement. */ private void addFinally(ArrayList returnList, Stmnt finallyBlock) throws CompileError { Bytecode bc = bytecode; int n = returnList.size(); for (int i = 0; i < n; ++i) { final int[] ret = (int[])returnList.get(i); int pc = ret[0]; bc.write16bit(pc, bc.currentPc() - pc + 1); ReturnHook hook = new JsrHook2(this, ret); finallyBlock.accept(this); hook.remove(this); if (!hasReturned) { bc.addOpcode(Opcode.GOTO); bc.addIndex(pc + 3 - bc.currentPc()); } } }
/** * @param isCons true if super() must be called. * false if the method is a class initializer. */ public void atMethodBody(Stmnt s, boolean isCons, boolean isVoid) throws CompileError { if (s == null) return; if (isCons && needsSuperCall(s)) insertDefaultSuperCall(); hasReturned = false; s.accept(this); if (!hasReturned) if (isVoid) { bytecode.addOpcode(Opcode.RETURN); hasReturned = true; } else throw new CompileError("no return statement"); }
/** * @param isCons true if super() must be called. * false if the method is a class initializer. */ public void atMethodBody(Stmnt s, boolean isCons, boolean isVoid) throws CompileError { if (s == null) return; if (isCons && needsSuperCall(s)) insertDefaultSuperCall(); hasReturned = false; s.accept(this); if (!hasReturned) if (isVoid) { bytecode.addOpcode(Opcode.RETURN); hasReturned = true; } else throw new CompileError("no return statement"); }
/** * Compiles a statement (or a block). * <code>recordParams()</code> must be called before invoking * this method. * * <p>Local variables that are not declared * in the compiled source text might not be accessible within that * source text. Fields and method parameters ($0, $1, ..) are available. */ public void compileStmnt(String src) throws CompileError { Parser p = new Parser(new Lex(src)); SymbolTable stb = new SymbolTable(stable); while (p.hasMore()) { Stmnt s = p.parseStatement(stb); if (s != null) s.accept(gen); } }
/** * Compiles a statement (or a block). * <code>recordParams()</code> must be called before invoking * this method. * * <p>Local variables that are not declared * in the compiled source text might not be accessible within that * source text. Fields and method parameters ($0, $1, ..) are available. */ public void compileStmnt(String src) throws CompileError { Parser p = new Parser(new Lex(src)); SymbolTable stb = new SymbolTable(stable); while (p.hasMore()) { Stmnt s = p.parseStatement(stb); if (s != null) s.accept(gen); } }
body.accept(this);
/** * Adds a finally clause for earch return statement. */ private void addFinally(List<int[]> returnList, Stmnt finallyBlock) throws CompileError { Bytecode bc = bytecode; for (final int[] ret:returnList) { int pc = ret[0]; bc.write16bit(pc, bc.currentPc() - pc + 1); ReturnHook hook = new JsrHook2(this, ret); finallyBlock.accept(this); hook.remove(this); if (!hasReturned) { bc.addOpcode(Opcode.GOTO); bc.addIndex(pc + 3 - bc.currentPc()); } } }
body.accept(this); int end = bc.currentPc(); if (start == end) hasReturned = false; if (block != null) block.accept(this); bc.addAstore(var); hasReturned = false; finallyBlock.accept(this); if (!hasReturned) { bc.addAload(var); if (finallyBlock != null) { if (tryNotReturn) finallyBlock.accept(this);
body.accept(this);
body.accept(this); int end = bc.currentPc(); if (start == end) hasReturned = false; if (block != null) block.accept(this); bc.addAstore(var); hasReturned = false; finallyBlock.accept(this); if (!hasReturned) { bc.addAload(var); if (finallyBlock != null) { if (tryNotReturn) finallyBlock.accept(this);
((Stmnt)label.tail()).accept(this);
((Stmnt)label.tail()).accept(this);
Stmnt body = (Stmnt)st.tail(); if (body != null) body.accept(this);
Stmnt body = (Stmnt)st.tail(); if (body != null) body.accept(this);
/** * Compiles a statement (or a block). * <code>recordParams()</code> must be called before invoking * this method. * * <p>Local variables that are not declared * in the compiled source text might not be accessible within that * source text. Fields and method parameters ($0, $1, ..) are available. */ public void compileStmnt(String src) throws CompileError { Parser p = new Parser(new Lex(src)); SymbolTable stb = new SymbolTable(stable); while (p.hasMore()) { Stmnt s = p.parseStatement(stb); if (s != null) s.accept(gen); } }
/** * Compiles a statement (or a block). * <code>recordParams()</code> must be called before invoking * this method. * * <p>Local variables that are not declared * in the compiled source text might not be accessible within that * source text. Fields and method parameters ($0, $1, ..) are available. */ public void compileStmnt(String src) throws CompileError { Parser p = new Parser(new Lex(src)); SymbolTable stb = new SymbolTable(stable); while (p.hasMore()) { Stmnt s = p.parseStatement(stb); if (s != null) s.accept(gen); } }