b.loadLocal(b.getParameter(i)); b.invoke(ctor); b.returnValue(TypeDesc.OBJECT);
case READ_METHOD: case TRY_READ_METHOD: default: { b.loadLocal(beanVar); b.invoke(bp.getReadMethod()); TypeDesc type = TypeDesc.forClass(bp.getType()); b.convert(type, type.toObjectType()); b.checkCast(type.toObjectType()); b.convert(type.toObjectType(), type); b.invoke(bp.getWriteMethod()); if (methodType == WRITE_METHOD) { b.returnVoid();
builder.loadLocal(obj1); builder.loadLocal(obj2); builder.invoke(compareMethod); builder.storeLocal(result); builder.loadLocal(result); builder.invoke(prop.getReadMethod()); builder.storeLocal(p1); builder.loadLocal(obj2); builder.invoke(prop.getReadMethod()); builder.storeLocal(p2); builder.loadLocal(p2); builder.convert(propertyType, propertyType.toObjectType()); builder.invoke(compareMethod); } else { builder.loadLocal(p1); builder.loadLocal(p2); builder.invoke(compareMethod);
/** * Generate code to test equality of two properties. * @param b * @param property * @param otherInstance * @param propsAreEqual */ private static void addPropertyTest(CodeBuilder b, StorableProperty<?> property, LocalVariable otherInstance, Label propsAreEqual) { TypeDesc propertyType = TypeDesc.forClass(property.getType()); b.loadThis(); b.invokeVirtual(property.getReadMethodName(), propertyType, null); b.loadLocal(otherInstance); b.invoke(property.getReadMethod()); CodeBuilderUtil.addValuesEqualCall(b, propertyType, true, // test for null propsAreEqual, true); // branch to propsAreEqual when equal // Property values differ, so return false. b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); }
builder.invoke(floatToIntBits); builder.convert(TypeDesc.INT, TypeDesc.LONG); builder.loadLocal(b); builder.invoke(floatToIntBits); builder.convert(TypeDesc.INT, TypeDesc.LONG); builder.math(Opcode.LCMP); builder.invoke(doubleToLongBits); builder.loadLocal(b); builder.invoke(doubleToLongBits); builder.math(Opcode.LCMP);
/** * Generate code to test equality of two properties. * @param b * @param property * @param otherInstance * @param propsAreEqual */ private static void addPropertyTest(CodeBuilder b, StorableProperty<?> property, LocalVariable otherInstance, Label propsAreEqual) { TypeDesc propertyType = TypeDesc.forClass(property.getType()); b.loadThis(); b.invokeVirtual(property.getReadMethodName(), propertyType, null); b.loadLocal(otherInstance); b.invoke(property.getReadMethod()); CodeBuilderUtil.addValuesEqualCall(b, propertyType, true, // test for null propsAreEqual, true); // branch to propsAreEqual when equal // Property values differ, so return false. b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); }
private void loadProperty(CodeBuilder b, StorableProperty<?> property) { Method readMethod = property.getReadMethod(); if (readMethod == null) { // Invoke synthetic package accessible method. String readName = property.getReadMethodName(); try { readMethod = property.getEnclosingType().getDeclaredMethod(readName); } catch (NoSuchMethodException e) { // This shouldn't happen since it was checked for earlier. throw new IllegalArgumentException ("Property \"" + property.getName() + "\" cannot be read"); } } b.invoke(readMethod); }
b.loadThis(); b.invokeVirtual(prop.getReadMethodName(), propType, null); b.invoke(prop.getWriteMethod()); } else if (methodName.equals(mCopyFromMasterMethodName)) { if (prop.getReadMethod() == null) { b.invoke(prop.getReadMethod()); b.invokeVirtual(prop.getWriteMethodName(), null, new TypeDesc[] {propType});
private void loadProperty(CodeBuilder b, StorableProperty<?> property) { Method readMethod = property.getReadMethod(); if (readMethod == null) { // Invoke synthetic package accessible method. String readName = property.getReadMethodName(); try { readMethod = property.getEnclosingType().getDeclaredMethod(readName); } catch (NoSuchMethodException e) { // This shouldn't happen since it was checked for earlier. throw new IllegalArgumentException ("Property \"" + property.getName() + "\" cannot be read"); } } b.invoke(readMethod); }
/** * Loads the property value of the current storable onto the stack. If the * property is derived the read method is used, otherwise it just loads the * value from the appropriate field. * * entry stack: [ * exit stack: [value * * @param b - {@link CodeBuilder} to which to add the load code * @param property - property to load * @param type - type of the property */ private void loadThisProperty(CodeBuilder b, StorableProperty property, TypeDesc type) { b.loadThis(); if (property.isDerived()) { b.invoke(property.getReadMethod()); } else { b.loadField(property.getName(), type); } }
/** * Loads the property value of the current storable onto the stack. If the * property is derived the read method is used, otherwise it just loads the * value from the appropriate field. * * entry stack: [ * exit stack: [value * * @param b - {@link CodeBuilder} to which to add the load code * @param property - property to load * @param type - type of the property */ private void loadThisProperty(CodeBuilder b, StorableProperty property, TypeDesc type) { b.loadThis(); if (property.isDerived()) { b.invoke(property.getReadMethod()); } else { b.loadField(property.getName(), type); } }
private void addAdjustVersionProperty(CodeBuilder b, LocalVariable storableVar, int value) throws SupportException { // Push storable to stack in preparation for calling set method below. if (storableVar == null) { b.loadThis(); } else { b.loadLocal(storableVar); } StorableProperty<?> versionProperty = mInfo.getVersionProperty(); TypeDesc versionType = TypeDesc.forClass(versionProperty.getType()); if (value >= 0) { CodeBuilderUtil.initialVersion(b, versionType, value); } else { // Load current property value. b.dup(); b.invoke(versionProperty.getReadMethod()); CodeBuilderUtil.incrementVersion(b, versionType); } b.invoke(versionProperty.getWriteMethod()); }
private void addAdjustVersionProperty(CodeBuilder b, LocalVariable storableVar, int value) throws SupportException { // Push storable to stack in preparation for calling set method below. if (storableVar == null) { b.loadThis(); } else { b.loadLocal(storableVar); } StorableProperty<?> versionProperty = mInfo.getVersionProperty(); TypeDesc versionType = TypeDesc.forClass(versionProperty.getType()); if (value >= 0) { CodeBuilderUtil.initialVersion(b, versionType, value); } else { // Load current property value. b.dup(); b.invoke(versionProperty.getReadMethod()); CodeBuilderUtil.incrementVersion(b, versionType); } b.invoke(versionProperty.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()); } }
/** * 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()); } }