当前位置: 首页>>代码示例>>Java>>正文


Java MethodVisitor.visitJumpInsn方法代码示例

本文整理汇总了Java中org.springframework.asm.MethodVisitor.visitJumpInsn方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitJumpInsn方法的具体用法?Java MethodVisitor.visitJumpInsn怎么用?Java MethodVisitor.visitJumpInsn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.asm.MethodVisitor的用法示例。


在下文中一共展示了MethodVisitor.visitJumpInsn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateCode

import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	// Pseudo: if (!leftOperandValue) { result=false; } else { result=rightOperandValue; }
	Label elseTarget = new Label();
	Label endOfIf = new Label();
	cf.enterCompilationScope();
	getLeftOperand().generateCode(mv, cf);
	cf.unboxBooleanIfNecessary(mv);
	cf.exitCompilationScope();
	mv.visitJumpInsn(IFNE, elseTarget);
	mv.visitLdcInsn(0); // FALSE
	mv.visitJumpInsn(GOTO,endOfIf);
	mv.visitLabel(elseTarget);
	cf.enterCompilationScope();
	getRightOperand().generateCode(mv, cf);
	cf.unboxBooleanIfNecessary(mv);
	cf.exitCompilationScope();
	mv.visitLabel(endOfIf);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:OpAnd.java

示例2: generateCode

import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	// pseudo: if (leftOperandValue) { result=true; } else { result=rightOperandValue; }
	Label elseTarget = new Label();
	Label endOfIf = new Label();
	cf.enterCompilationScope();
	getLeftOperand().generateCode(mv, cf);
	cf.unboxBooleanIfNecessary(mv);
	cf.exitCompilationScope();
	mv.visitJumpInsn(IFEQ, elseTarget);
	mv.visitLdcInsn(1); // TRUE
	mv.visitJumpInsn(GOTO,endOfIf);
	mv.visitLabel(elseTarget);
	cf.enterCompilationScope();
	getRightOperand().generateCode(mv, cf);
	cf.unboxBooleanIfNecessary(mv);
	cf.exitCompilationScope();
	mv.visitLabel(endOfIf);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:OpOr.java

示例3: generateCode

import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	// exit type descriptor can be null if both components are literal expressions
	computeExitTypeDescriptor();
	this.children[0].generateCode(mv, cf);
	Label elseTarget = new Label();
	Label endOfIf = new Label();
	mv.visitInsn(DUP);
	mv.visitJumpInsn(IFNULL, elseTarget);
	mv.visitJumpInsn(GOTO, endOfIf);
	mv.visitLabel(elseTarget);
	mv.visitInsn(POP);
	this.children[1].generateCode(mv, cf);
	if (!CodeFlow.isPrimitive(this.exitTypeDescriptor)) {
		CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
	}
	mv.visitLabel(endOfIf);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:Elvis.java

示例4: generateCode

import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	// May reach here without it computed if all elements are literals
	computeExitTypeDescriptor();
	cf.enterCompilationScope();
	this.children[0].generateCode(mv, cf);
	if (!CodeFlow.isPrimitive(cf.lastDescriptor())) {
		CodeFlow.insertUnboxInsns(mv, 'Z', cf.lastDescriptor());
	}
	cf.exitCompilationScope();
	Label elseTarget = new Label();
	Label endOfIf = new Label();
	mv.visitJumpInsn(IFEQ, elseTarget);
	cf.enterCompilationScope();
	this.children[1].generateCode(mv, cf);
	if (!CodeFlow.isPrimitive(this.exitTypeDescriptor)) {
		CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
	}
	cf.exitCompilationScope();
	mv.visitJumpInsn(GOTO, endOfIf);
	mv.visitLabel(elseTarget);
	cf.enterCompilationScope();
	this.children[2].generateCode(mv, cf);
	if (!CodeFlow.isPrimitive(this.exitTypeDescriptor)) {
		CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
	}
	cf.exitCompilationScope();
	mv.visitLabel(endOfIf);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:Ternary.java

示例5: generateCode

import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	this.children[0].generateCode(mv, cf);
	cf.unboxBooleanIfNecessary(mv);
	Label elseTarget = new Label();
	Label endOfIf = new Label();
	mv.visitJumpInsn(IFNE,elseTarget);		
	mv.visitInsn(ICONST_1); // TRUE
	mv.visitJumpInsn(GOTO,endOfIf);
	mv.visitLabel(elseTarget);
	mv.visitInsn(ICONST_0); // FALSE
	mv.visitLabel(endOfIf);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:OperatorNot.java

示例6: generateCode

import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	String leftDesc = getLeftOperand().exitTypeDescriptor;
	String rightDesc = getRightOperand().exitTypeDescriptor;
	Label elseTarget = new Label();
	Label endOfIf = new Label();
	boolean leftPrim = CodeFlow.isPrimitive(leftDesc);
	boolean rightPrim = CodeFlow.isPrimitive(rightDesc);

	DescriptorComparison dc = DescriptorComparison.checkNumericCompatibility(leftDesc, rightDesc, leftActualDescriptor, rightActualDescriptor);
	
	if (dc.areNumbers && dc.areCompatible) {
		char targetType = dc.compatibleType;
		
		getLeftOperand().generateCode(mv, cf);
		if (!leftPrim) {
			CodeFlow.insertUnboxInsns(mv, targetType, leftDesc);
		}
	
		cf.enterCompilationScope();
		getRightOperand().generateCode(mv, cf);
		cf.exitCompilationScope();
		if (!rightPrim) {
			CodeFlow.insertUnboxInsns(mv, targetType, rightDesc);
		}
		// assert: SpelCompiler.boxingCompatible(leftDesc, rightDesc)
		if (targetType == 'D') {
			mv.visitInsn(DCMPL);
			mv.visitJumpInsn(IFEQ, elseTarget);
		}
		else if (targetType == 'F') {
			mv.visitInsn(FCMPL);		
			mv.visitJumpInsn(IFEQ, elseTarget);
		}
		else if (targetType == 'J') {
			mv.visitInsn(LCMP);		
			mv.visitJumpInsn(IFEQ, elseTarget);
		}
		else if (targetType == 'I' || targetType == 'Z') {
			mv.visitJumpInsn(IF_ICMPEQ, elseTarget);		
		}
		else {
			throw new IllegalStateException("Unexpected descriptor "+leftDesc);
		}
	}
	else {
		getLeftOperand().generateCode(mv, cf);
		getRightOperand().generateCode(mv, cf);
		mv.visitJumpInsn(IF_ACMPEQ, elseTarget);
	}
	mv.visitInsn(ICONST_1);
	mv.visitJumpInsn(GOTO,endOfIf);
	mv.visitLabel(elseTarget);
	mv.visitInsn(ICONST_0);
	mv.visitLabel(endOfIf);
	cf.pushDescriptor("Z");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:58,代码来源:OpNE.java

示例7: generateComparisonCode

import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
/** 
 * Numeric comparison operators share very similar generated code, only differing in 
 * two comparison instructions.
 */
protected void generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compInstruction1, int compInstruction2) {
	String leftDesc = getLeftOperand().exitTypeDescriptor;
	String rightDesc = getRightOperand().exitTypeDescriptor;
	
	boolean unboxLeft = !CodeFlow.isPrimitive(leftDesc);
	boolean unboxRight = !CodeFlow.isPrimitive(rightDesc);
	DescriptorComparison dc = DescriptorComparison.checkNumericCompatibility(leftDesc, rightDesc,
			this.leftActualDescriptor, this.rightActualDescriptor);
	char targetType = dc.compatibleType;//CodeFlow.toPrimitiveTargetDesc(leftDesc);
	
	getLeftOperand().generateCode(mv, cf);
	if (unboxLeft) {
		CodeFlow.insertUnboxInsns(mv, targetType, leftDesc);
	}

	cf.enterCompilationScope();
	getRightOperand().generateCode(mv, cf);
	cf.exitCompilationScope();
	if (unboxRight) {
		CodeFlow.insertUnboxInsns(mv, targetType, rightDesc);
	}

	// assert: SpelCompiler.boxingCompatible(leftDesc, rightDesc)
	Label elseTarget = new Label();
	Label endOfIf = new Label();
	if (targetType=='D') {
		mv.visitInsn(DCMPG);
		mv.visitJumpInsn(compInstruction1, elseTarget);
	}
	else if (targetType=='F') {
		mv.visitInsn(FCMPG);		
		mv.visitJumpInsn(compInstruction1, elseTarget);
	}
	else if (targetType=='J') {
		mv.visitInsn(LCMP);		
		mv.visitJumpInsn(compInstruction1, elseTarget);
	}
	else if (targetType=='I') {
		mv.visitJumpInsn(compInstruction2, elseTarget);
	}
	else {
		throw new IllegalStateException("Unexpected descriptor "+leftDesc);
	}

	// Other numbers are not yet supported (isCompilable will not have returned true)
	mv.visitInsn(ICONST_1);
	mv.visitJumpInsn(GOTO,endOfIf);
	mv.visitLabel(elseTarget);
	mv.visitInsn(ICONST_0);
	mv.visitLabel(endOfIf);
	cf.pushDescriptor("Z");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:57,代码来源:Operator.java


注:本文中的org.springframework.asm.MethodVisitor.visitJumpInsn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。