private void emit_if() { LocalVariable var1 = b.createLocalVariable("var1", TypeDesc.DOUBLE); LocalVariable var2 = b.createLocalVariable("var2", TypeDesc.DOUBLE); b.storeLocal(var2); b.storeLocal(var1); Label lbl1 = b.createLabel(); Label lbl2 = b.createLabel(); b.ifZeroComparisonBranch(lbl1, "!="); b.loadLocal(var1); b.branch(lbl2); lbl1.setLocation(); b.loadLocal(var2); lbl2.setLocation(); }
private void nullConvert(Label end) { LocalVariable temp = createLocalVariable("temp", TypeDesc.OBJECT); storeLocal(temp); loadLocal(temp); Label notNull = createLabel(); ifNullBranch(notNull, false); loadNull(); branch(end); notNull.setLocation(); loadLocal(temp); }
public LocalVariable createLocalVariable(TypeDesc type) { return createLocalVariable(null, type); }
mBuilder.createLocalVariable("temp", mIntType); } else { savedIndex = (LocalVariable)mTempLocals.pop();
mLimitLocal = mBuilder.getParameter(1); mResultsLocal = mBuilder.getParameter(2); mPositionsLocal = mBuilder.createLocalVariable("positions", mIntArrayType); mIndexLocal = mBuilder.createLocalVariable("index", mIntType);
if (mTempLocals.isEmpty()) { tempChar = mBuilder.createLocalVariable("temp", mIntType); } else { tempChar = (LocalVariable)mTempLocals.pop();
PropertyCopy(CodeBuilder b, StorableProperty<S> property) { this.property = property; copyVar = b.createLocalVariable(null, TypeDesc.forClass(property.getType())); }
PropertyCopy(CodeBuilder b, StorableProperty<S> property) { this.property = property; copyVar = b.createLocalVariable(null, TypeDesc.forClass(property.getType())); }
builder.createLocalVariable("result", TypeDesc.INT); if (bc.mUsingComparator != null) { builder.loadThis(); LocalVariable p1 = builder.createLocalVariable("p1", propertyType); LocalVariable p2 = builder.createLocalVariable("p2", propertyType);
/** * Generates code to get the JDBCSupport instance and store it in a local * variable. */ private LocalVariable getJDBCSupport(CodeBuilder b) { pushJDBCSupport(b); LocalVariable supportVar = b.createLocalVariable("support", TypeDesc.forClass(JDBCSupport.class)); b.storeLocal(supportVar); return supportVar; }
/** * Generates code to get the JDBCSupport instance and store it in a local * variable. */ private LocalVariable getJDBCSupport(CodeBuilder b) { pushJDBCSupport(b); LocalVariable supportVar = b.createLocalVariable("support", TypeDesc.forClass(JDBCSupport.class)); b.storeLocal(supportVar); return supportVar; }
/** * Creates local variable to hold invocation input stream, unless already * created. Assumes that */ private static LocalVariable invInVar(CodeBuilder b, LocalVariable channelVar, LocalVariable invInVar) { if (invInVar == null) { b.loadLocal(channelVar); b.invokeInterface(INV_CHANNEL_TYPE, "getInputStream", INV_IN_TYPE, null); invInVar = b.createLocalVariable(null, INV_IN_TYPE); b.storeLocal(invInVar); } return invInVar; }
/** * Generate code to create a local variable containing the specified parameter coerced * to the specified type. This is useful for re-interpreting erased generics into * the more specific genericized type. * * @param b CodeBuilder into which to append the code * @param paramType the more specific type which was erased during compilation * @param paramIndex index of the parameter to unerase * @return a local variable referencing the type-cast parameter */ public static LocalVariable uneraseGenericParameter( CodeBuilder b, TypeDesc paramType, final int paramIndex) { b.loadLocal(b.getParameter(paramIndex)); b.checkCast(paramType); LocalVariable result = b.createLocalVariable(null, paramType); b.storeLocal(result); return result; }
/** * Generate code to create a local variable containing the specified parameter coerced * to the specified type. This is useful for re-interpreting erased generics into * the more specific genericized type. * * @param b CodeBuilder into which to append the code * @param paramType the more specific type which was erased during compilation * @param paramIndex index of the parameter to unerase * @return a local variable referencing the type-cast parameter */ public static LocalVariable uneraseGenericParameter( CodeBuilder b, TypeDesc paramType, final int paramIndex) { b.loadLocal(b.getParameter(paramIndex)); b.checkCast(paramType); LocalVariable result = b.createLocalVariable(null, paramType); b.storeLocal(result); return result; }
/** * Generates code to get connection from JDBCConnectionCapability and store * it in a local variable. * * @param capVar reference to JDBCConnectionCapability */ private LocalVariable getConnection(CodeBuilder b, LocalVariable capVar) { b.loadLocal(capVar); b.invokeInterface(TypeDesc.forClass(JDBCConnectionCapability.class), "getConnection", TypeDesc.forClass(Connection.class), null); LocalVariable conVar = b.createLocalVariable("con", TypeDesc.forClass(Connection.class)); b.storeLocal(conVar); return conVar; }
/** * Generates code to get connection from JDBCConnectionCapability and store * it in a local variable. * * @param capVar reference to JDBCConnectionCapability */ private LocalVariable getConnection(CodeBuilder b, LocalVariable capVar) { b.loadLocal(capVar); b.invokeInterface(TypeDesc.forClass(JDBCConnectionCapability.class), "getConnection", TypeDesc.forClass(Connection.class), null); LocalVariable conVar = b.createLocalVariable("con", TypeDesc.forClass(Connection.class)); b.storeLocal(conVar); return conVar; }
private void nullConvert(Label end) { LocalVariable temp = createLocalVariable("temp", TypeDesc.OBJECT); storeLocal(temp); loadLocal(temp); Label notNull = createLabel(); ifNullBranch(notNull, false); loadNull(); branch(end); notNull.setLocation(); loadLocal(temp); }
private void genCompletionResponse(CodeBuilder b, TypeDesc type, LocalVariable completionVar, Label tryStart, Label tryEnd, LocalVariable sequenceVar) { TypeDesc remoteCompletionType = TypeDesc.forClass(RemoteCompletion.class); LocalVariable valueVar = b.createLocalVariable(null, type); b.storeLocal(valueVar); b.loadThis(); b.loadField(SUPPORT_FIELD_NAME, SKEL_SUPPORT_TYPE); b.loadLocal(valueVar); b.loadLocal(completionVar); b.invokeInterface(SKEL_SUPPORT_TYPE, "completion", null, new TypeDesc[] {TypeDesc.forClass(Future.class), remoteCompletionType}); Label skip = b.createLabel(); b.branch(skip); genExceptionHandler(b, tryStart, tryEnd, sequenceVar); LocalVariable throwableVar = b.createLocalVariable(null, THROWABLE_TYPE); b.storeLocal(throwableVar); b.loadLocal(completionVar); b.loadLocal(throwableVar); b.invokeInterface(remoteCompletionType, "exception", null, new TypeDesc[] {THROWABLE_TYPE}); skip.setLocation(); }
/** * Generates method which passes exception to uncaught exception handler. */ private void defineUncaughtExceptionHandler() { MethodInfo mi = mClassFile.addMethod (Modifiers.PRIVATE.toStatic(true), UNCAUGHT_METHOD_NAME, null, new TypeDesc[] {TypeDesc.forClass(Throwable.class)}); CodeBuilder b = new CodeBuilder(mi); // Thread t = Thread.currentThread(); // t.getUncaughtExceptionHandler().uncaughtException(t, e); TypeDesc threadType = TypeDesc.forClass(Thread.class); b.invokeStatic(Thread.class.getName(), "currentThread", threadType, null); LocalVariable threadVar = b.createLocalVariable(null, threadType); b.storeLocal(threadVar); b.loadLocal(threadVar); TypeDesc handlerType = TypeDesc.forClass(Thread.UncaughtExceptionHandler.class); b.invokeVirtual(threadType, "getUncaughtExceptionHandler", handlerType, null); b.loadLocal(threadVar); b.loadLocal(b.getParameter(0)); b.invokeInterface(handlerType, "uncaughtException", null, new TypeDesc[] {threadType, TypeDesc.forClass(Throwable.class)}); b.returnVoid(); }
/** * Generates method which passes exception to uncaught exception handler. */ private void defineUncaughtExceptionHandler() { MethodInfo mi = mClassFile.addMethod (Modifiers.PRIVATE.toStatic(true), UNCAUGHT_METHOD_NAME, null, new TypeDesc[] {TypeDesc.forClass(Throwable.class)}); CodeBuilder b = new CodeBuilder(mi); // Thread t = Thread.currentThread(); // t.getUncaughtExceptionHandler().uncaughtException(t, e); TypeDesc threadType = TypeDesc.forClass(Thread.class); b.invokeStatic(Thread.class.getName(), "currentThread", threadType, null); LocalVariable threadVar = b.createLocalVariable(null, threadType); b.storeLocal(threadVar); b.loadLocal(threadVar); TypeDesc handlerType = TypeDesc.forClass(Thread.UncaughtExceptionHandler.class); b.invokeVirtual(threadType, "getUncaughtExceptionHandler", handlerType, null); b.loadLocal(threadVar); b.loadLocal(b.getParameter(0)); b.invokeInterface(handlerType, "uncaughtException", null, new TypeDesc[] {threadType, TypeDesc.forClass(Throwable.class)}); b.returnVoid(); }