b.loadField(REF_FIELD_NAME, atomicRefType); b.invokeVirtual(atomicRefType, "get", TypeDesc.OBJECT, null); b.checkCast(TypeDesc.forClass(mType)); b.checkCast(cf.getType()); b.loadField(REF_FIELD_NAME, atomicRefType); b.invokeVirtual(atomicRefType, "get", TypeDesc.OBJECT, null); b.checkCast(TypeDesc.forClass(mType));
b.checkCast(TypeDesc.forClass(beanType)); b.storeLocal(beanVar);
/** * Generates code to push the JDBCSupport instance on the stack. */ private void pushJDBCSupport(CodeBuilder b) { b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, TypeDesc.forClass(TriggerSupport.class)); b.checkCast(TypeDesc.forClass(JDBCSupport.class)); }
/** * Generates code to push the JDBCSupport instance on the stack. */ private void pushJDBCSupport(CodeBuilder b) { b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, TypeDesc.forClass(TriggerSupport.class)); b.checkCast(TypeDesc.forClass(JDBCSupport.class)); }
/** * 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; }
b.checkCast(type);
private String addFilterField(PropertyFilter filter, TypeDesc type) { final int propertyOrdinal = mPropertyOrdinalMap.get(filter); final String fieldName = FIELD_PREFIX + propertyOrdinal; if (mGeneratedPropertyFilters.containsKey(filter)) { return fieldName; } final TypeDesc fieldType = actualFieldType(type); mClassFile.addField(Modifiers.PRIVATE.toFinal(true), fieldName, fieldType); // Add code to constructor to store value into field. { CodeBuilder b = mCtorBuilder; b.loadThis(); b.loadLocal(b.getParameter(1)); b.loadConstant(propertyOrdinal); b.loadFromArray(OBJECT); if (type != OBJECT) { b.checkCast(type.toObjectType()); convertProperty(b, type.toObjectType(), fieldType); } b.storeField(fieldName, fieldType); } mGeneratedPropertyFilters.put(filter, filter); return fieldName; }
private String addFilterField(PropertyFilter filter, TypeDesc type) { final int propertyOrdinal = mPropertyOrdinalMap.get(filter); final String fieldName = FIELD_PREFIX + propertyOrdinal; if (mGeneratedPropertyFilters.containsKey(filter)) { return fieldName; } final TypeDesc fieldType = actualFieldType(type); mClassFile.addField(Modifiers.PRIVATE.toFinal(true), fieldName, fieldType); // Add code to constructor to store value into field. { CodeBuilder b = mCtorBuilder; b.loadThis(); b.loadLocal(b.getParameter(1)); b.loadConstant(propertyOrdinal); b.loadFromArray(OBJECT); if (type != OBJECT) { b.checkCast(type.toObjectType()); convertProperty(b, type.toObjectType(), fieldType); } b.storeField(fieldName, fieldType); } mGeneratedPropertyFilters.put(filter, filter); return fieldName; }
/** * Creates code to call set method. Assumes Storable and property value * are already on the stack. */ private static void callSetPropertyValue(CodeBuilder b, OrderedProperty<?> op) { StorableProperty<?> property = op.getChainedProperty().getLastProperty(); TypeDesc propType = TypeDesc.forClass(property.getType()); if (propType != TypeDesc.OBJECT) { TypeDesc objectType = propType.toObjectType(); b.checkCast(objectType); // Potentially unbox primitive. b.convert(objectType, propType); } b.invoke(property.getWriteMethod()); } }
/** * Creates code to call set method. Assumes Storable and property value * are already on the stack. */ private static void callSetPropertyValue(CodeBuilder b, OrderedProperty<?> op) { StorableProperty<?> property = op.getChainedProperty().getLastProperty(); TypeDesc propType = TypeDesc.forClass(property.getType()); if (propType != TypeDesc.OBJECT) { TypeDesc objectType = propType.toObjectType(); b.checkCast(objectType); // Potentially unbox primitive. b.convert(objectType, propType); } b.invoke(property.getWriteMethod()); } }
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); } }
TypeDesc.forClass(Class.class) }); b.checkCast(TypeDesc.forClass(annotation.getAnnotationType()));
b.loadThis(); b.loadLocal(b.getParameter(0)); b.checkCast(TypeDesc.forClass(property.getType())); b.invoke(property.getWriteMethod()); b.returnVoid();
b.loadField(supportFieldName, supportFieldType); if (supportFieldType != supportCtorType) { b.checkCast(supportCtorType);
b.loadField(supportFieldName, supportFieldType); if (supportFieldType != supportCtorType) { b.checkCast(supportCtorType);