modifiablebytecodevisitor.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 80 行
JAVA
80 行
/*
* $Id: ModifiableBytecodeVisitor.java,v 1.1 2003/11/25 11:42:13 epr Exp $
*/
package org.jnode.vm.bytecode;
/**
* Utility class used for bytecode visitors that modify the bytecode during
* the visit.
*
* @author Ewout Prangsma (epr@users.sourceforge.net)
*/
public class ModifiableBytecodeVisitor extends BytecodeVisitorSupport {
private final BytecodeModifier modifier;
private int noLocals;
private int maxStack;
public ModifiableBytecodeVisitor(BytecodeModifier modifier, int noLocals, int maxStack) {
this.modifier = modifier;
this.noLocals = noLocals;
this.maxStack = maxStack;
}
protected final void insert(int bcOfs, int skipLen, byte[] src) {
modifier.insert(bcOfs, skipLen, src, 0, src.length, noLocals, maxStack);
final byte[] code = modifier.getNewCode();
final BytecodeParser parser = getParser();
parser.setCode(code);
parser.adjustEndPC(src.length - skipLen);
}
protected final void remove(int bcOfs, int len) {
modifier.remove(bcOfs, len, noLocals, maxStack);
final byte[] code = modifier.getNewCode();
final BytecodeParser parser = getParser();
parser.setCode(code);
parser.adjustEndPC(-len);
}
protected byte[] getNewCode() {
return modifier.getNewCode();
}
/**
* @return The bytecode modifier
*/
protected final BytecodeModifier getModifier() {
return this.modifier;
}
/**
* @return The maximum stack size
*/
public int getMaxStack() {
return this.maxStack;
}
/**
* @param maxStack
*/
public void setMaxStack(int maxStack) {
this.maxStack = maxStack;
}
/**
* @return The number of locals
*/
public int getNoLocals() {
return this.noLocals;
}
/**
* @param noLocals
*/
public void setNoLocals(int noLocals) {
this.noLocals = noLocals;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?