public void invokeConstructor(TypeDesc classDesc, TypeDesc[] params) { invokeConstructor(getClassName(classDesc), classDesc, params); }
public void invokeConstructor(String className, TypeDesc[] params) { invokeConstructor(className, TypeDesc.forClass(className), params); }
public void invokeSuperConstructor(TypeDesc[] params) { invokeConstructor(mClassFile.getSuperClassName(), params); }
public void invokeConstructor(TypeDesc[] params) { invokeConstructor(mClassFile.getClassName(), mClassFile.getType(), params); }
/** * @param from must be a primitive type * @param to must be an object type */ private void box(TypeDesc from, TypeDesc to) { if (mTarget >= 0x00010005) { // Call the new valueOf method. invokeStatic(to.getRootName(), "valueOf", to, new TypeDesc[] {from}); return; } switch (from.getTypeCode()) { case TypeDesc.BOOLEAN_CODE: toBoolean(true); break; case TypeDesc.CHAR_CODE: case TypeDesc.FLOAT_CODE: case TypeDesc.BYTE_CODE: case TypeDesc.SHORT_CODE: case TypeDesc.INT_CODE: case TypeDesc.DOUBLE_CODE: case TypeDesc.LONG_CODE: invokeConstructor(to.getRootName(), new TypeDesc[]{from}); break; } }
dup(); loadConstant(strlen); invokeConstructor(stringBufferDesc, new TypeDesc[] {intDesc});
public void invokeConstructor(String className, TypeDesc[] params) { invokeConstructor(className, TypeDesc.forClass(className), params); }
public void invokeSuperConstructor(TypeDesc[] params) { invokeConstructor(mClassFile.getSuperClassName(), params); }
public void invokeConstructor(TypeDesc classDesc, TypeDesc[] params) { invokeConstructor(getClassName(classDesc), classDesc, params); }
public void invokeConstructor(TypeDesc[] params) { invokeConstructor(mClassFile.getClassName(), mClassFile.getType(), params); }
b.invokeConstructor(NoSuchPropertyException.class.getName(), params); b.throwObject();
/** * Generate code to throw an exception with an optional message. * @param b {@link CodeBuilder} to which to add code * @param type type of the object to throw * @param message optional message to provide to the constructor */ public static void throwException(CodeBuilder b, Class type, String message) { TypeDesc desc = TypeDesc.forClass(type); b.newObject(desc); b.dup(); if (message == null) { b.invokeConstructor(desc, null); } else { b.loadConstant(message); b.invokeConstructor(desc, new TypeDesc[] {TypeDesc.STRING}); } b.throwObject(); }
/** * Generate code to throw an exception with an optional message. * @param b {@link CodeBuilder} to which to add code * @param type type of the object to throw * @param message optional message to provide to the constructor */ public static void throwException(CodeBuilder b, Class type, String message) { TypeDesc desc = TypeDesc.forClass(type); b.newObject(desc); b.dup(); if (message == null) { b.invokeConstructor(desc, null); } else { b.loadConstant(message); b.invokeConstructor(desc, new TypeDesc[] {TypeDesc.STRING}); } b.throwObject(); }
private static void throwIllegalArgException(CodeBuilder b, String message, LocalVariable concatStr) { TypeDesc exceptionType = TypeDesc.forClass(IllegalArgumentException.class); TypeDesc[] params = {TypeDesc.STRING}; b.newObject(exceptionType); b.dup(); b.loadConstant(message); b.loadLocal(concatStr); b.invokeVirtual(TypeDesc.STRING, "concat", TypeDesc.STRING, params); b.invokeConstructor(exceptionType, params); b.throwObject(); }
/** * @param from must be a primitive type * @param to must be an object type */ private void box(TypeDesc from, TypeDesc to) { if (mTarget >= 0x00010005) { // Call the new valueOf method. invokeStatic(to.getRootName(), "valueOf", to, new TypeDesc[] {from}); return; } switch (from.getTypeCode()) { case TypeDesc.BOOLEAN_CODE: toBoolean(true); break; case TypeDesc.CHAR_CODE: case TypeDesc.FLOAT_CODE: case TypeDesc.BYTE_CODE: case TypeDesc.SHORT_CODE: case TypeDesc.INT_CODE: case TypeDesc.DOUBLE_CODE: case TypeDesc.LONG_CODE: invokeConstructor(to.getRootName(), new TypeDesc[]{from}); break; } }
private static void throwIllegalArgException(CodeBuilder b, String message, LocalVariable concatStr) { TypeDesc exceptionType = TypeDesc.forClass(IllegalArgumentException.class); TypeDesc[] params = {TypeDesc.STRING}; b.newObject(exceptionType); b.dup(); b.loadConstant(message); b.loadLocal(concatStr); b.invokeVirtual(TypeDesc.STRING, "concat", TypeDesc.STRING, params); b.invokeConstructor(exceptionType, params); b.throwObject(); }
/** * Generate code to throw an exception with a message concatenated at runtime. * * @param b {@link CodeBuilder} to which to add code * @param type type of the object to throw * @param messages messages to concat at runtime */ public static void throwConcatException(CodeBuilder b, Class type, String... messages) { if (messages == null || messages.length == 0) { throwException(b, type, null); return; } if (messages.length == 1) { throwException(b, type, messages[0]); return; } TypeDesc desc = TypeDesc.forClass(type); b.newObject(desc); b.dup(); TypeDesc[] params = new TypeDesc[] {TypeDesc.STRING}; for (int i=0; i<messages.length; i++) { b.loadConstant(String.valueOf(messages[i])); if (i > 0) { b.invokeVirtual(TypeDesc.STRING, "concat", TypeDesc.STRING, params); } } b.invokeConstructor(desc, params); b.throwObject(); }
private void checkIfPartitionKeyPresent(CodeBuilder b) { b.loadThis(); b.invokeVirtual(StorableGenerator.IS_PARTITION_KEY_INITIALIZED_METHOD_NAME, TypeDesc.BOOLEAN, null); Label ptnkInitialized = b.createLabel(); b.ifZeroComparisonBranch(ptnkInitialized, "!="); TypeDesc exType = TypeDesc.forClass(IllegalStateException.class); b.newObject(exType); b.dup(); b.loadConstant("Partition key not fully specified"); b.invokeConstructor(exType, new TypeDesc[] {TypeDesc.STRING}); b.throwObject(); ptnkInitialized.setLocation(); }
private void checkIfPartitionKeyPresent(CodeBuilder b) { b.loadThis(); b.invokeVirtual(StorableGenerator.IS_PARTITION_KEY_INITIALIZED_METHOD_NAME, TypeDesc.BOOLEAN, null); Label ptnkInitialized = b.createLabel(); b.ifZeroComparisonBranch(ptnkInitialized, "!="); TypeDesc exType = TypeDesc.forClass(IllegalStateException.class); b.newObject(exType); b.dup(); b.loadConstant("Partition key not fully specified"); b.invokeConstructor(exType, new TypeDesc[] {TypeDesc.STRING}); b.throwObject(); ptnkInitialized.setLocation(); }
b.checkCast(supportCtorType); b.invokeConstructor(new TypeDesc[] {supportCtorType}); b.returnValue(cf.getType());