insn = insn.append(Insn.create(opc_iadd));
// test result of isLoaded and return field if nonzero
final InsnTarget mediate = new InsnTarget();
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_isLoaded_Name,
JDO_SM_isLoaded_Sig),
countMethodArgWords(JDO_SM_isLoaded_Sig)));
insn = insn.append(Insn.create(opc_ifeq, mediate));
insn = appendDirectReadReturn(insn, fieldRef);
// call sm for mediation
insn = insn.append(mediate);
insn = insn.append(InsnUtils.aLoad(varStart, pool));
// push instance
insn = insn.append(Insn.create(opc_aload_0));
// push absolute field index
insn = insn.append(
Insn.create(opc_getstatic,
pool.addFieldRef(
className,
JDO_PC_jdoInheritedFieldCount_Name,
JDO_PC_jdoInheritedFieldCount_Sig)));
insn = insn.append(InsnUtils.integerConstant(fieldIndex, pool));
insn = insn.append(Insn.create(opc_iadd));
// push field
insn = insn.append(Insn.create(opc_aload_0));
insn = insn.append(Insn.create(opc_getfield, fieldRef));
// call the sm's get field method
switch (sig.charAt(0)) {
case 'Z':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getBooleanField_Name,
JDO_SM_getBooleanField_Sig),
countMethodArgWords(JDO_SM_getBooleanField_Sig)));
insn = insn.append(Insn.create(opc_ireturn));
break;
case 'C':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getCharField_Name,
JDO_SM_getCharField_Sig),
countMethodArgWords(JDO_SM_getCharField_Sig)));
insn = insn.append(Insn.create(opc_ireturn));
break;
case 'B':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getByteField_Name,
JDO_SM_getByteField_Sig),
countMethodArgWords(JDO_SM_getByteField_Sig)));
insn = insn.append(Insn.create(opc_ireturn));
break;
case 'S':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getShortField_Name,
JDO_SM_getShortField_Sig),
countMethodArgWords(JDO_SM_getShortField_Sig)));
insn = insn.append(Insn.create(opc_ireturn));
break;
case 'I':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getIntField_Name,
JDO_SM_getIntField_Sig),
countMethodArgWords(JDO_SM_getIntField_Sig)));
insn = insn.append(Insn.create(opc_ireturn));
break;
case 'J':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getLongField_Name,
JDO_SM_getLongField_Sig),
countMethodArgWords(JDO_SM_getLongField_Sig)));
insn = insn.append(Insn.create(opc_lreturn));
break;
case 'F':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getFloatField_Name,
JDO_SM_getFloatField_Sig),
countMethodArgWords(JDO_SM_getFloatField_Sig)));
insn = insn.append(Insn.create(opc_freturn));
break;
case 'D':
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getDoubleField_Name,
JDO_SM_getDoubleField_Sig),
countMethodArgWords(JDO_SM_getDoubleField_Sig)));
insn = insn.append(Insn.create(opc_dreturn));
break;
case 'L':
case '[':
if (sig.equals(JAVA_String_Sig)) {
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getStringField_Name,
JDO_SM_getStringField_Sig),
countMethodArgWords(JDO_SM_getStringField_Sig)));
insn = insn.append(Insn.create(opc_areturn));
} else {
insn = insn.append(
new InsnInterfaceInvoke(
pool.addInterfaceMethodRef(
JDO_StateManager_Path,
JDO_SM_getObjectField_Name,
JDO_SM_getObjectField_Sig),
countMethodArgWords(JDO_SM_getObjectField_Sig)));