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); }
b.ifNullBranch(searchNotNull, false); b.ifNullBranch(noMatch, false); b.loadConstant(true); b.returnValue(TypeDesc.BOOLEAN);
Label label = builder.createLabel(); builder.loadLocal(obj1); builder.ifNullBranch(label, false); builder.loadConstant(nullHigh ? 1 : -1); builder.returnValue(TypeDesc.INT); label = builder.createLabel(); builder.loadLocal(obj2); builder.ifNullBranch(label, false); builder.loadConstant(nullHigh ? -1 : 1); builder.returnValue(TypeDesc.INT); label = builder.createLabel(); builder.loadLocal(p1); builder.ifNullBranch(label, false); builder.loadConstant(nullHigh ? 1 : -1); builder.returnValue(TypeDesc.INT); label = builder.createLabel(); builder.loadLocal(p2); builder.ifNullBranch(label, false); builder.loadConstant(nullHigh ? -1 : 1); builder.returnValue(TypeDesc.INT);
/** * Branch to the fail location if the value on the stack is * null. When choice is false, fail on non-null. * * @param choice if true, fail when null, else fail when not null */ void failIfNull(CodeBuilder b, boolean choice) { if (mFailLocation != null) { b.ifNullBranch(mFailLocation, choice); } else { Label pass = b.createLabel(); b.ifNullBranch(pass, !choice); b.loadConstant(false); b.returnValue(BOOLEAN); pass.setLocation(); } }
/** * Branch to the success location if the value on the stack is * null. When choice is false, success on non-null. * * @param choice if true, success when null, else success when not null */ void successIfNull(CodeBuilder b, boolean choice) { if (mSuccessLocation != null) { b.ifNullBranch(mSuccessLocation, choice); } else { Label pass = b.createLabel(); b.ifNullBranch(pass, !choice); b.loadConstant(true); b.returnValue(BOOLEAN); pass.setLocation(); } }
/** * Branch to the fail location if the value on the stack is * null. When choice is false, fail on non-null. * * @param choice if true, fail when null, else fail when not null */ void failIfNull(CodeBuilder b, boolean choice) { if (mFailLocation != null) { b.ifNullBranch(mFailLocation, choice); } else { Label pass = b.createLabel(); b.ifNullBranch(pass, !choice); b.loadConstant(false); b.returnValue(BOOLEAN); pass.setLocation(); } }
/** * Branch to the success location if the value on the stack is * null. When choice is false, success on non-null. * * @param choice if true, success when null, else success when not null */ void successIfNull(CodeBuilder b, boolean choice) { if (mSuccessLocation != null) { b.ifNullBranch(mSuccessLocation, choice); } else { Label pass = b.createLabel(); b.ifNullBranch(pass, !choice); b.loadConstant(true); b.returnValue(BOOLEAN); pass.setLocation(); } }
private void branchIfNull(CodeBuilder b, LocalVariable value, Label isNull) { if (!value.getType().isPrimitive()) { b.loadLocal(value); b.ifNullBranch(isNull, true); } }
private void branchIfNull(CodeBuilder b, LocalVariable value, Label isNull) { if (!value.getType().isPrimitive()) { b.loadLocal(value); b.ifNullBranch(isNull, true); } }
/** * Branch to the success location if the value on the stack is * null. When choice is false, success on non-null. If the success * condition is not met, the fail location is branched to. * * @param choice if true, success when null, else success when not null */ void successIfNullElseFail(CodeBuilder b, boolean choice) { if (mSuccessLocation != null) { b.ifNullBranch(mSuccessLocation, choice); fail(b); } else if (mFailLocation != null) { b.ifNullBranch(mFailLocation, !choice); success(b); } else { Label success = b.createLabel(); b.ifNullBranch(success, choice); b.loadConstant(false); b.returnValue(BOOLEAN); success.setLocation(); b.loadConstant(true); b.returnValue(BOOLEAN); } }
/** * Branch to the success location if the value on the stack is * null. When choice is false, success on non-null. If the success * condition is not met, the fail location is branched to. * * @param choice if true, success when null, else success when not null */ void successIfNullElseFail(CodeBuilder b, boolean choice) { if (mSuccessLocation != null) { b.ifNullBranch(mSuccessLocation, choice); fail(b); } else if (mFailLocation != null) { b.ifNullBranch(mFailLocation, !choice); success(b); } else { Label success = b.createLabel(); b.ifNullBranch(success, choice); b.loadConstant(false); b.returnValue(BOOLEAN); success.setLocation(); b.loadConstant(true); b.returnValue(BOOLEAN); } }
/** * Generate code to throw an exception if a parameter is null * @param b CodeBuilder into which to append the code * @param paramIndex index of the parameter to check */ public static void assertParameterNotNull(CodeBuilder b, int paramIndex) { b.loadLocal(b.getParameter(paramIndex)); Label notNull = b.createLabel(); b.ifNullBranch(notNull, false); throwException(b, IllegalArgumentException.class, null); notNull.setLocation(); }
/** * Generate code to throw an exception if a parameter is null * @param b CodeBuilder into which to append the code * @param paramIndex index of the parameter to check */ public static void assertParameterNotNull(CodeBuilder b, int paramIndex) { b.loadLocal(b.getParameter(paramIndex)); Label notNull = b.createLabel(); b.ifNullBranch(notNull, false); throwException(b, IllegalArgumentException.class, null); notNull.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); }
/** * * @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(); }
/** * * @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 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(); }
/** * Generated code checks if chained properties resolve to null, and if * so, branches to the current scope's fail or success location. */ private void loadChainedProperty(CodeBuilder b, ChainedProperty<?> chained) { b.loadLocal(mStorableVar); loadProperty(b, chained.getPrimeProperty()); for (int i=0; i<chained.getChainCount(); i++) { // Check if last loaded property was null. Fail for inner join, // success for outer join. b.dup(); Label notNull = b.createLabel(); b.ifNullBranch(notNull, false); b.pop(); if (chained.isOuterJoin(i)) { getScope().success(b); } else { getScope().fail(b); } notNull.setLocation(); // Now load next property in chain. loadProperty(b, chained.getChainedProperty(i)); } }
/** * Generated code checks if chained properties resolve to null, and if * so, branches to the current scope's fail or success location. */ private void loadChainedProperty(CodeBuilder b, ChainedProperty<?> chained) { b.loadLocal(mStorableVar); loadProperty(b, chained.getPrimeProperty()); for (int i=0; i<chained.getChainCount(); i++) { // Check if last loaded property was null. Fail for inner join, // success for outer join. b.dup(); Label notNull = b.createLabel(); b.ifNullBranch(notNull, false); b.pop(); if (chained.isOuterJoin(i)) { getScope().success(b); } else { getScope().fail(b); } notNull.setLocation(); // Now load next property in chain. loadProperty(b, chained.getChainedProperty(i)); } }