final BytecodeFieldDeclaration field = this.fields.get(fieldName);
final boolean isStatic = field.getAccess().isStatic();
BytecodeMethodConcrete getter = this.addMethod(getterName,
new TypeMemberAccess(Scope.Public, false, isStatic, false),
new MethodDescriptor(false, field.getType(), new TypeDescriptor[0])).setMethodBody(new BytecodeBlock() {
@Override protected void writeInstructions(BytecodeContextMethod context) {
context.returnValue(isStatic ? context.getStaticField(fieldName) : context.getThisField(fieldName));
}
});
if (setterName != null) {
this.addMethod(setterName,
new TypeMemberAccess(Scope.Public, false, isStatic, false),
new MethodDescriptor(false, TypeDescriptor.VOID, new TypeDescriptor[0], field.getType())).setMethodBody(new BytecodeBlock() {
@Override protected void writeInstructions(BytecodeContextMethod context) {
context.setArrayIndexValue(isStatic ? context.getStaticField(fieldName) : context.getThisField(fieldName), context.getDeclaredParameter(0));
}