private void addTreCatchInfo(Label start, Label end, Label handler, IClass type) { if (tryCatchInfos == null) { tryCatchInfos = new ArrayList<>(); } tryCatchInfos.add(new ExceptionTableEntry(start, end, handler, type.getType())); }
private void cast(MethodExecuteContext context, IClass from, IClass to){ Instructions instructions = context.getInstructions(); if(from.isPrimitive() && to.isPrimitive()){ instructions.cast(from.getType(), to.getType()); }else if(from.isPrimitive()){ instructions.box(from.getType()); }else if(IClassUtils.isPrimitiveWrapAClass(from) && to.isPrimitive()){ Type primType = Instructions.getUnBoxedType(from.getType()); instructions.unbox(from.getType()); instructions.cast(primType, to.getType()); } }
@Override protected final void factorToStack(MethodExecuteContext context) { factor.push(context); context.getInstructions().unbox(targetClass.getType()); }
@Override protected void doExecute(MethodExecuteContext context) { obj.push(context); context.getInstructions().instanceOf(type.getType()); }
public String getDescription() { if (ArrayUtils.isEmpty(argClasses)) { return Type.getMethodDescriptor(returnType); } else { Type[] argTypes = new Type[argClasses.length]; for (int i = 0; i < argTypes.length; i++) { argTypes[i] = argClasses[i].getType(); } return Type.getMethodDescriptor(returnType, argTypes); } }
@Override protected void factorToStack(MethodExecuteContext context) { factor.push(context); context.getInstructions().unbox(factor.getResultType().getType()); }
@Override protected void doExecute(MethodExecuteContext context) { if(LOG.isPrintEnabled()){ LOG.print("duplicate the top of stack and push it to stack"); } context.getInstructions().dup(type.getType()); }
@Override public void doExecute(MethodExecuteContext context) { LOG.print("run the negative operator"); factorToStack(context); context.getInstructions().neg(factor.getResultType().getType()); }
@Override protected void factorToStack(MethodExecuteContext context) { LOG.print("factors to stack"); factor.push(context); context.getInstructions().unbox(factor.getResultType().getType()); }
@Override protected void factorToStack(MethodExecuteContext context) { if(LOG.isPrintEnabled()) { LOG.print("Factors to stack"); } leftFactor.push(context); context.getInstructions().unbox(leftFactor.getResultType().getType()); rightFactor.push(context); context.getInstructions().unbox(rightFactor.getResultType().getType()); }
@Override protected void doExecute(MethodExecuteContext context) { // the exception variable already exists at the top of the statck. context.getInstructions().getOperandStack().push(getExceptionType().getType()); for (InstructionNode node : getChildren()) { node.execute(context); } }
@Override public void doExecute(MethodExecuteContext context) { LOG.print("new a instance of class :" + this.methodOwner.getName()); LOG.print("put class reference to stack"); context.getInstructions().newInstance(methodOwner.getType()); if (isSaveReference()) { context.getInstructions().dup(); } argumentsToStack(context); LOG.print("call the constrcutor"); context.getInstructions().invokeConstructor(methodOwner.getType(), methodMeta.getParameterAsmTypes()); }
@Override public void doExecute(MethodExecuteContext context) { if(LOG.isPrintEnabled()){ LOG.print("assign value to global variable '" + var.getMeta().getName() + "' from " + value ); } value.push(context); autoCast(context); context.getInstructions().putStatic(var.getOwner().getType(), var.getMeta().getName(), var.getMeta().getType().getType()); }
@Override public void doExecute(MethodExecuteContext context) { if(LOG.isPrintEnabled()) { LOG.print("Start execute sub arithmetic operator"); } factorToStack(context); if(LOG.isPrintEnabled()) { LOG.print("Execute the sub instruction"); } context.getInstructions().rem(targetClass.getType()); }
@Override public void doExecute(MethodExecuteContext context) { LOG.print("call method '"+ name +"' by 'this' key word"); LOG.print("put 'this' to stack"); context.getInstructions().loadThis(getParent().getMethod().getMeta().getOwner().getType()); argumentsToStack(context); IClass[] argTypes = new IClass[arguments.length]; for(int i=0; i<argTypes.length; i++){ argTypes[i] = arguments[i].getResultType(); } context.getInstructions().invokeConstructor(getActuallyOwner().getType(), methodMeta.getParameterAsmTypes()); }
@Override public void doExecute(MethodExecuteContext context) { if(LOG.isPrintEnabled()) { LOG.print("start execute sub arithmetic operator"); } factorToStack(context); if(LOG.isPrintEnabled()) { LOG.print("execute the sub instruction"); } context.getInstructions().div(targetClass.getType()); }
@Override protected void init() { if (lock.getResultType() == null || lock.getResultType().isPrimitive() || lock.getResultType().getType().equals(Type.VOID_TYPE)) { throw new IllegalArgumentException(lock + " is not a valid type's argument for the synchronized statement"); } lock.asArgument(); AbstractMethodBody methodBody = getMethod().getBody(); methodBody.addExceptionTableEntry(monitorenter, monitorexit, excetpionStart, null); methodBody.addExceptionTableEntry(excetpionStart, excetpionEnd, excetpionStart, null); }
/** * Generates the instruction to store the top stack value in a local * variable. * * @param var */ public void storeInsn(final LocalVariable var) { locals.setCursor(var.getScopeLogicVar()); locals.printState(); mv.visitVarInsn(var.getMeta().getType().getType().getOpcode(Opcodes.ISTORE), var.getScopeLogicVar().getInitStartPos()); }
@Override public void doExecute(MethodExecuteContext context) { if(LOG.isPrintEnabled()) { LOG.print("Start inverts operator : " + getOperatorSymbol()); LOG.print("Factor to stack"); } factorToStack(context); if(LOG.isPrintEnabled()) { LOG.print("Start invert"); } context.getInstructions().inverts(targetClass.getType()); }
@Override public void doExecute(MethodExecuteContext context) { argumentsToStack(context); LOG.print("invoke static method : " + name); context.getInstructions().invokeStatic(methodOwner.getType(), name, getReturnType(), methodMeta.getParameterAsmTypes()); if(!isSaveReference()){ if(!getReturnType().equals(Type.VOID_TYPE)){ context.getInstructions().pop(); } } }