📄 executionvisitor.java
字号:
if (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)){
UninitializedObjectType t = (UninitializedObjectType) stack().peek(o.getArgumentTypes(cpg).length);
if (t == Frame._this){
Frame._this = null;
}
stack().initializeObject(t);
locals().initializeObject(t);
}
stack().pop(); //objectref
for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
stack().pop();
}
// We are sure the invoked method will xRETURN eventually
// We simulate xRETURNs functionality here because we
// don't really "jump into" and simulate the invoked
// method.
if (o.getReturnType(cpg) != Type.VOID){
Type t = o.getReturnType(cpg);
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
t.equals(Type.SHORT) )
t = Type.INT;
stack().push(t);
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitINVOKESTATIC(INVOKESTATIC o){
for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
stack().pop();
}
// We are sure the invoked method will xRETURN eventually
// We simulate xRETURNs functionality here because we
// don't really "jump into" and simulate the invoked
// method.
if (o.getReturnType(cpg) != Type.VOID){
Type t = o.getReturnType(cpg);
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
t.equals(Type.SHORT) )
t = Type.INT;
stack().push(t);
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){
stack().pop(); //objectref
for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
stack().pop();
}
// We are sure the invoked method will xRETURN eventually
// We simulate xRETURNs functionality here because we
// don't really "jump into" and simulate the invoked
// method.
if (o.getReturnType(cpg) != Type.VOID){
Type t = o.getReturnType(cpg);
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
t.equals(Type.SHORT) )
t = Type.INT;
stack().push(t);
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitIOR(IOR o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitIREM(IREM o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitIRETURN(IRETURN o){
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitISHL(ISHL o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitISHR(ISHR o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitISTORE(ISTORE o){
locals().set(o.getIndex(), stack().pop());
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitISUB(ISUB o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitIUSHR(IUSHR o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitIXOR(IXOR o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitJSR(JSR o){
stack().push(new ReturnaddressType(o.physicalSuccessor()));
//System.err.println("TODO-----------:"+o.physicalSuccessor());
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitJSR_W(JSR_W o){
stack().push(new ReturnaddressType(o.physicalSuccessor()));
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitL2D(L2D o){
stack().pop();
stack().push(Type.DOUBLE);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitL2F(L2F o){
stack().pop();
stack().push(Type.FLOAT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitL2I(L2I o){
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLADD(LADD o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLALOAD(LALOAD o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLAND(LAND o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLASTORE(LASTORE o){
stack().pop();
stack().pop();
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLCMP(LCMP o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLCONST(LCONST o){
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLDC(LDC o){
Constant c = cpg.getConstant(o.getIndex());
if (c instanceof ConstantInteger){
stack().push(Type.INT);
}
if (c instanceof ConstantFloat){
stack().push(Type.FLOAT);
}
if (c instanceof ConstantString){
stack().push(Type.STRING);
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLDC_W(LDC_W o){
Constant c = cpg.getConstant(o.getIndex());
if (c instanceof ConstantInteger){
stack().push(Type.INT);
}
if (c instanceof ConstantFloat){
stack().push(Type.FLOAT);
}
if (c instanceof ConstantString){
stack().push(Type.STRING);
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLDC2_W(LDC2_W o){
Constant c = cpg.getConstant(o.getIndex());
if (c instanceof ConstantLong){
stack().push(Type.LONG);
}
if (c instanceof ConstantDouble){
stack().push(Type.DOUBLE);
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLDIV(LDIV o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLLOAD(LLOAD o){
stack().push(locals().get(o.getIndex()));
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLMUL(LMUL o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLNEG(LNEG o){
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLOOKUPSWITCH(LOOKUPSWITCH o){
stack().pop(); //key
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLOR(LOR o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLREM(LREM o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLRETURN(LRETURN o){
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLSHL(LSHL o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLSHR(LSHR o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLSTORE(LSTORE o){
locals().set(o.getIndex(), stack().pop());
locals().set(o.getIndex()+1, Type.UNKNOWN);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLSUB(LSUB o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLUSHR(LUSHR o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitLXOR(LXOR o){
stack().pop();
stack().pop();
stack().push(Type.LONG);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitMONITORENTER(MONITORENTER o){
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitMONITOREXIT(MONITOREXIT o){
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitMULTIANEWARRAY(MULTIANEWARRAY o){
for (int i=0; i<o.getDimensions(); i++){
stack().pop();
}
stack().push(o.getType(cpg));
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitNEW(NEW o){
stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg))));
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitNEWARRAY(NEWARRAY o){
stack().pop();
stack().push(o.getType());
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitNOP(NOP o){
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitPOP(POP o){
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitPOP2(POP2 o){
Type t = stack().pop();
if (t.getSize() == 1){
stack().pop();
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitPUTFIELD(PUTFIELD o){
stack().pop();
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitPUTSTATIC(PUTSTATIC o){
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitRET(RET o){
// do nothing, return address
// is in in the local variables.
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitRETURN(RETURN o){
// do nothing.
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitSALOAD(SALOAD o){
stack().pop();
stack().pop();
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitSASTORE(SASTORE o){
stack().pop();
stack().pop();
stack().pop();
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitSIPUSH(SIPUSH o){
stack().push(Type.INT);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitSWAP(SWAP o){
Type t = stack().pop();
Type u = stack().pop();
stack().push(t);
stack().push(u);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitTABLESWITCH(TABLESWITCH o){
stack().pop();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -