/** * Returns the source file containing the * instanceof expression. * * @return null if this information is not available. */ public String getFileName() { return super.getFileName(); }
/** * Returns the line number of the source line containing the * type-cast expression. * * @return -1 if this information is not available. */ public int getLineNumber() { return super.getLineNumber(); }
/** * Returns the list of exceptions that the expression may throw. * This list includes both the exceptions that the try-catch statements * including the expression can catch and the exceptions that * the throws declaration allows the method to throw. */ public CtClass[] mayThrow() { return super.mayThrow(); }
/** * Replaces this expression with the bytecode derived from * the given source text and <code>ExprEditor</code>. * * @param statement a Java statement except try-catch. * @param recursive if not null, the substituted bytecode * is recursively processed by the given * <code>ExprEditor</code>. * @since 3.1 */ public void replace(String statement, ExprEditor recursive) throws CannotCompileException { replace(statement); if (recursive != null) runEditor(recursive, iterator); }
protected void runEditor(ExprEditor ed, CodeIterator oldIterator) throws CannotCompileException { CodeAttribute codeAttr = oldIterator.get(); int orgLocals = codeAttr.getMaxLocals(); int orgStack = codeAttr.getMaxStack(); int newLocals = locals(); codeAttr.setMaxStack(stack()); codeAttr.setMaxLocals(newLocals); ExprEditor.LoopContext context = new ExprEditor.LoopContext(newLocals); int size = oldIterator.getCodeLength(); int endPos = oldIterator.lookAhead(); oldIterator.move(currentPos); if (ed.doit(thisClass, thisMethod, context, oldIterator, endPos)) edited = true; oldIterator.move(endPos + oldIterator.getCodeLength() - size); codeAttr.setMaxLocals(orgLocals); codeAttr.setMaxStack(orgStack); maxLocals = context.maxLocals; maxStack += context.maxStack; } }
static final void storeStack(CtClass[] params, boolean isStaticCall, int regno, Bytecode bytecode) { storeStack0(0, params.length, params, regno + 1, bytecode); if (isStaticCall) bytecode.addOpcode(ACONST_NULL); bytecode.addAstore(regno); }
/** * Replaces this expression with the bytecode derived from * the given source text and <code>ExprEditor</code>. * * @param statement a Java statement except try-catch. * @param recursive if not null, the substituted bytecode * is recursively processed by the given * <code>ExprEditor</code>. * @since 3.1 */ public void replace(String statement, ExprEditor recursive) throws CannotCompileException { replace(statement); if (recursive != null) runEditor(recursive, iterator); }
protected void runEditor(ExprEditor ed, CodeIterator oldIterator) throws CannotCompileException { CodeAttribute codeAttr = oldIterator.get(); int orgLocals = codeAttr.getMaxLocals(); int orgStack = codeAttr.getMaxStack(); int newLocals = locals(); codeAttr.setMaxStack(stack()); codeAttr.setMaxLocals(newLocals); ExprEditor.LoopContext context = new ExprEditor.LoopContext(newLocals); int size = oldIterator.getCodeLength(); int endPos = oldIterator.lookAhead(); oldIterator.move(currentPos); if (ed.doit(thisClass, thisMethod, context, oldIterator, endPos)) edited = true; oldIterator.move(endPos + oldIterator.getCodeLength() - size); codeAttr.setMaxLocals(orgLocals); codeAttr.setMaxStack(orgStack); maxLocals = context.maxLocals; maxStack += context.maxStack; } }
private static void storeStack0(int i, int n, CtClass[] params, int regno, Bytecode bytecode) { if (i >= n) return; else { CtClass c = params[i]; int size; if (c instanceof CtPrimitiveType) size = ((CtPrimitiveType)c).getDataSize(); else size = 1; storeStack0(i + 1, n, params, regno + size, bytecode); bytecode.addStore(regno, c); } }
/** * Replaces this expression with the bytecode derived from * the given source text and <code>ExprEditor</code>. * * @param statement a Java statement except try-catch. * @param recursive if not null, the substituted bytecode * is recursively processed by the given * <code>ExprEditor</code>. * @since 3.1 */ public void replace(String statement, ExprEditor recursive) throws CannotCompileException { replace(statement); if (recursive != null) runEditor(recursive, iterator); }
protected void runEditor(ExprEditor ed, CodeIterator oldIterator) throws CannotCompileException { CodeAttribute codeAttr = oldIterator.get(); int orgLocals = codeAttr.getMaxLocals(); int orgStack = codeAttr.getMaxStack(); int newLocals = locals(); codeAttr.setMaxStack(stack()); codeAttr.setMaxLocals(newLocals); ExprEditor.LoopContext context = new ExprEditor.LoopContext(newLocals); int size = oldIterator.getCodeLength(); int endPos = oldIterator.lookAhead(); oldIterator.move(currentPos); if (ed.doit(thisClass, thisMethod, context, oldIterator, endPos)) edited = true; oldIterator.move(endPos + oldIterator.getCodeLength() - size); codeAttr.setMaxLocals(orgLocals); codeAttr.setMaxStack(orgStack); maxLocals = context.maxLocals; maxStack += context.maxStack; } }
/** * Returns the source file containing the catch clause. * * @return null if this information is not available. */ public String getFileName() { return super.getFileName(); }
/** * Returns the list of exceptions that the catch clause may throw. */ public CtClass[] mayThrow() { return super.mayThrow(); }
/** * Returns the line number of the source line containing the * method call. * * @return -1 if this information is not available. */ public int getLineNumber() { return super.getLineNumber(); }
static final void storeStack(CtClass[] params, boolean isStaticCall, int regno, Bytecode bytecode) { storeStack0(0, params.length, params, regno + 1, bytecode); if (isStaticCall) bytecode.addOpcode(ACONST_NULL); bytecode.addAstore(regno); }