executionvisitor.java

来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 1,127 行 · 第 1/3 页

JAVA
1,127
字号
			stack().push(w1);			stack().push(w3);			stack().push(w2);			stack().push(w1);		}	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitDUP2(DUP2 o){		Type t = stack().pop();		if (t.getSize() == 2){			stack().push(t);			stack().push(t);		}		else{ // t.getSize() is 1			Type u = stack().pop();			stack().push(u);			stack().push(t);			stack().push(u);			stack().push(t);		}	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitDUP2_X1(DUP2_X1 o){		Type t = stack().pop();		if (t.getSize() == 2){			Type u = stack().pop();			stack().push(t);			stack().push(u);			stack().push(t);		}		else{ //t.getSize() is1			Type u = stack().pop();			Type v = stack().pop();			stack().push(u);			stack().push(t);			stack().push(v);			stack().push(u);			stack().push(t);		}	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitDUP2_X2(DUP2_X2 o){		Type t = stack().pop();		if (t.getSize() == 2){			Type u = stack().pop();			if (u.getSize() == 2){				stack().push(t);				stack().push(u);				stack().push(t);			}else{				Type v = stack().pop();				stack().push(t);				stack().push(v);				stack().push(u);				stack().push(t);			}		}		else{ //t.getSize() is 1			Type u = stack().pop();			Type v = stack().pop();			if (v.getSize() == 2){				stack().push(u);				stack().push(t);				stack().push(v);				stack().push(u);				stack().push(t);			}else{				Type w = stack().pop();				stack().push(u);				stack().push(t);				stack().push(w);				stack().push(v);				stack().push(u);				stack().push(t);			}		}	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitF2D(F2D o){		stack().pop();		stack().push(Type.DOUBLE);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitF2I(F2I o){		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitF2L(F2L o){		stack().pop();		stack().push(Type.LONG);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFADD(FADD o){		stack().pop();		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFALOAD(FALOAD o){		stack().pop();		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFASTORE(FASTORE o){		stack().pop();		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFCMPG(FCMPG o){		stack().pop();		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFCMPL(FCMPL o){		stack().pop();		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFCONST(FCONST o){		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFDIV(FDIV o){		stack().pop();		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFLOAD(FLOAD o){		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFMUL(FMUL o){		stack().pop();		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFNEG(FNEG o){		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFREM(FREM o){		stack().pop();		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFRETURN(FRETURN o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFSTORE(FSTORE o){		locals().set(o.getIndex(), stack().pop());	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitFSUB(FSUB o){		stack().pop();		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitGETFIELD(GETFIELD o){		stack().pop();		Type t = o.getFieldType(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 visitGETSTATIC(GETSTATIC o){		Type t = o.getFieldType(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 visitGOTO(GOTO o){		// no stack changes.	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitGOTO_W(GOTO_W o){		// no stack changes.	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitI2B(I2B o){		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitI2C(I2C o){		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitI2D(I2D o){		stack().pop();		stack().push(Type.DOUBLE);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitI2F(I2F o){		stack().pop();		stack().push(Type.FLOAT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitI2L(I2L o){		stack().pop();		stack().push(Type.LONG);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitI2S(I2S o){		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIADD(IADD o){		stack().pop();		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIALOAD(IALOAD o){		stack().pop();		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIAND(IAND o){		stack().pop();		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIASTORE(IASTORE o){		stack().pop();		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitICONST(ICONST o){		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIDIV(IDIV o){		stack().pop();		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ACMPEQ(IF_ACMPEQ o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ACMPNE(IF_ACMPNE o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ICMPEQ(IF_ICMPEQ o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ICMPGE(IF_ICMPGE o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ICMPGT(IF_ICMPGT o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ICMPLE(IF_ICMPLE o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ICMPLT(IF_ICMPLT o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIF_ICMPNE(IF_ICMPNE o){		stack().pop();		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFEQ(IFEQ o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFGE(IFGE o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFGT(IFGT o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFLE(IFLE o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFLT(IFLT o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFNE(IFNE o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFNONNULL(IFNONNULL o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIFNULL(IFNULL o){		stack().pop();	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIINC(IINC o){		// stack is not changed.	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitILOAD(ILOAD o){		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitIMUL(IMUL o){		stack().pop();		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitINEG(INEG o){		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitINSTANCEOF(INSTANCEOF o){		stack().pop();		stack().push(Type.INT);	}	/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 	public void visitINVOKEINTERFACE(INVOKEINTERFACE 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);		}	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?