public void invokeInterface(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params) { invokeInterface(getClassName(classDesc), methodName, ret, params); }
private void emit_queryVar() { b.loadLocal(queryVarParam); // push the queryVar parameter b.swap(); // swap the top two words on the stack, so the var id is on top params = new TypeDesc[] {TypeDesc.INT}; // the type of the id parameter (int) b.invokeInterface(queryVarType, "getValue", TypeDesc.DOUBLE, params); }
private void emit_docVar() { b.loadLocal(docVarParam); // push the docVar parameter b.swap(); // swap the top two words on the stack, so the var id is on top params = new TypeDesc[] {TypeDesc.INT}; // the type of the id parameter (int) b.invokeInterface(docVarType, "getBoost", TypeDesc.FLOAT, params); b.convert(TypeDesc.FLOAT, TypeDesc.DOUBLE); }
public void invokeInterface(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params) { invokeInterface(getClassName(classDesc), methodName, ret, params); }
private void genRebatch(CodeBuilder b, LocalVariable supportVar, LocalVariable batchedChannelVar) { if (batchedChannelVar != null) { b.loadLocal(supportVar); b.loadLocal(batchedChannelVar); b.invokeInterface(STUB_SUPPORT_TYPE, "rebatch", null, new TypeDesc[] {INV_CHANNEL_TYPE}); } }
private void genFinishedAsync(CodeBuilder b, LocalVariable channelVar) { b.loadThis(); b.loadField(SUPPORT_FIELD_NAME, SKEL_SUPPORT_TYPE); b.loadLocal(channelVar); b.invokeInterface(SKEL_SUPPORT_TYPE, "finishedAsync", null, new TypeDesc[] {INV_CHANNEL_TYPE}); }
private void genBatched(CodeBuilder b, LocalVariable supportVar, LocalVariable channelVar, boolean noTimeout) { b.loadLocal(supportVar); b.loadLocal(channelVar); String methodName = noTimeout ? "batched" : "batchedAndCancelTimeout"; b.invokeInterface(STUB_SUPPORT_TYPE, methodName, null, new TypeDesc[] {channelVar.getType()}); }
/** * 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; }
private void genFinished(CodeBuilder b, LocalVariable channelVar, boolean reset) { b.loadThis(); b.loadField(SUPPORT_FIELD_NAME, SKEL_SUPPORT_TYPE); b.loadLocal(channelVar); b.loadConstant(reset); b.invokeInterface(SKEL_SUPPORT_TYPE, "finished", TypeDesc.INT, new TypeDesc[] {INV_CHANNEL_TYPE, TypeDesc.BOOLEAN}); }
/** * Generates code which emulates this: * * // May throw FetchException * JDBCConnectionCapability.yieldConnection(con); * * @param capVar required reference to JDBCConnectionCapability * @param conVar optional connection to yield */ private void yieldConnection(CodeBuilder b, LocalVariable capVar, LocalVariable conVar) { if (conVar != null) { b.loadLocal(capVar); b.loadLocal(conVar); b.invokeInterface(TypeDesc.forClass(JDBCConnectionCapability.class), "yieldConnection", null, new TypeDesc[] {TypeDesc.forClass(Connection.class)}); } }
/** * Generates code which emulates this: * * // May throw FetchException * JDBCConnectionCapability.yieldConnection(con); * * @param capVar required reference to JDBCConnectionCapability * @param conVar optional connection to yield */ private void yieldConnection(CodeBuilder b, LocalVariable capVar, LocalVariable conVar) { if (conVar != null) { b.loadLocal(capVar); b.loadLocal(conVar); b.invokeInterface(TypeDesc.forClass(JDBCConnectionCapability.class), "yieldConnection", null, new TypeDesc[] {TypeDesc.forClass(Connection.class)}); } }
private void genFinished(CodeBuilder b, LocalVariable supportVar, LocalVariable channelVar, LocalVariable batchedChannelVar, boolean noTimeout, boolean reset) { b.loadLocal(supportVar); b.loadLocal(channelVar); b.loadConstant(reset); String methodName = noTimeout ? "finished" : "finishedAndCancelTimeout"; b.invokeInterface(STUB_SUPPORT_TYPE, methodName, null, new TypeDesc[] {channelVar.getType(), TypeDesc.BOOLEAN}); genRebatch(b, supportVar, batchedChannelVar); }
private void addCommitAndExitTransaction(CodeBuilder b, String opType, LocalVariable txnVar) { if (!alwaysHasTxn(opType)) { return; } TypeDesc transactionType = TypeDesc.forClass(Transaction.class); Label noTxn = b.createLabel(); if (!requiresTxnForUpdate(opType)) { // Might be null, if transaction was already in progress. If // requires transaction for update, then a new transaction is // always created. b.loadLocal(txnVar); b.ifNullBranch(noTxn, true); } // txn.commit(); // txn.exit(); b.loadLocal(txnVar); b.invokeInterface(transactionType, COMMIT_METHOD_NAME, null, null); b.loadLocal(txnVar); b.invokeInterface(transactionType, EXIT_METHOD_NAME, null, null); noTxn.setLocation(); }
private void addCommitAndExitTransaction(CodeBuilder b, String opType, LocalVariable txnVar) { if (!alwaysHasTxn(opType)) { return; } TypeDesc transactionType = TypeDesc.forClass(Transaction.class); Label noTxn = b.createLabel(); if (!requiresTxnForUpdate(opType)) { // Might be null, if transaction was already in progress. If // requires transaction for update, then a new transaction is // always created. b.loadLocal(txnVar); b.ifNullBranch(noTxn, true); } // txn.commit(); // txn.exit(); b.loadLocal(txnVar); b.invokeInterface(transactionType, COMMIT_METHOD_NAME, null, null); b.loadLocal(txnVar); b.invokeInterface(transactionType, EXIT_METHOD_NAME, null, null); noTxn.setLocation(); }
/** * 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; }
/** * * @param opType type of operation, Insert, Update, or Delete */ private void addExitTransaction(CodeBuilder b, String opType, LocalVariable txnVar) { if (!alwaysHasTxn(opType)) { return; } TypeDesc transactionType = TypeDesc.forClass(Transaction.class); Label noTxn = b.createLabel(); if (!requiresTxnForUpdate(opType)) { // Might be null, if transaction was already in progress. If // requires transaction for update, then a new transaction is // always created. b.loadLocal(txnVar); b.ifNullBranch(noTxn, true); } // txn.exit(); b.loadLocal(txnVar); b.invokeInterface(transactionType, EXIT_METHOD_NAME, null, null); noTxn.setLocation(); }
private void generateDelegatedMethod(String masterMethodName, String supportMethodName) { TypeDesc triggerSupportType = TypeDesc.forClass(TriggerSupport.class); TypeDesc delegateSupportType = TypeDesc.forClass(DelegateSupport.class); TypeDesc[] storableParam = {TypeDesc.forClass(Storable.class)}; MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED, masterMethodName, TypeDesc.BOOLEAN, null); CodeBuilder b = new CodeBuilder(mi); b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); b.checkCast(delegateSupportType); b.loadThis(); b.invokeInterface(delegateSupportType, supportMethodName, TypeDesc.BOOLEAN, storableParam); b.returnValue(TypeDesc.BOOLEAN); } }
private void generateDelegatedMethod(String masterMethodName, String supportMethodName) { TypeDesc triggerSupportType = TypeDesc.forClass(TriggerSupport.class); TypeDesc delegateSupportType = TypeDesc.forClass(DelegateSupport.class); TypeDesc[] storableParam = {TypeDesc.forClass(Storable.class)}; MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED, masterMethodName, TypeDesc.BOOLEAN, null); CodeBuilder b = new CodeBuilder(mi); b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); b.checkCast(delegateSupportType); b.loadThis(); b.invokeInterface(delegateSupportType, supportMethodName, TypeDesc.BOOLEAN, storableParam); b.returnValue(TypeDesc.BOOLEAN); } }
/** * 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(); }