private void GenerateLocalByRefType(JavaPrimitiveType type) { GenerateBaseByRefType(type); string valueFieldDesc = "L" + TypeNameToJava(ClassNames.JavaObject) + ";"; if (type != JavaPrimitiveType.Ref) { valueFieldDesc = JavaPrimitive2FieldChar[(int)type].ToString(); } Java.Class javaClass = new Java.Class(); javaClass.AccessFlag = Java.ClassAccessFlag.Final | Java.ClassAccessFlag.Public | Java.ClassAccessFlag.Super; javaClass.ThisClass = TypeNameToJava(new JavaByRefType(ByRefPlace.Local, type).ToString()); javaClass.SuperClass = TypeNameToJava(new JavaByRefType(ByRefPlace.Unknown, type).ToString()); Java.Field valueField = new Java.Field(); valueField.AccessFlags = Java.FieldAccessFlags.Private; valueField.Name = "value"; valueField.Descriptor = valueFieldDesc; javaClass.Fields.Add(valueField); Java.Constants.FieldRef valueRef = new Java.Constants.FieldRef(javaClass.ThisClass, "value", valueFieldDesc); Java.Constants.MethodRef superCtorRef = new Java.Constants.MethodRef(javaClass.SuperClass, ClassNames.JavaConstructorMethodName, "()V"); Java.Method ctor = new Java.Method(); ctor.AccessFlags = Java.MethodAccessFlags.Public; ctor.Name = ClassNames.JavaConstructorMethodName; ctor.Descriptor = "(" + valueFieldDesc + ")V"; ctor.Attributes.Add(new JavaBytecodeWriter() .Add(OpCodes.aload_0) .Add(OpCodes.invokespecial, superCtorRef) .Add(OpCodes.aload_0) .AddLoad(type, 1) .Add(OpCodes.putfield, valueRef) .AddReturn(JavaPrimitiveType.Void) .End(javaClass.ConstantPool) ); javaClass.Methods.Add(ctor); Java.Method get = new Method(); get.AccessFlags = Java.MethodAccessFlags.Public; get.Name = ClassNames.ByRef.GetValueMethodName; get.Descriptor = "()" + valueFieldDesc; get.Attributes.Add(new JavaBytecodeWriter() .Add(OpCodes.aload_0) .Add(OpCodes.getfield, valueRef) .AddReturn(type) .End(javaClass.ConstantPool)); javaClass.Methods.Add(get); Java.Method set = new Method(); set.AccessFlags = MethodAccessFlags.Public; set.Name = ClassNames.ByRef.SetValueMethodName; set.Descriptor = "(" + valueFieldDesc + ")V"; set.Attributes.Add(new JavaBytecodeWriter() .Add(OpCodes.aload_0) .AddLoad(type, 1) .Add(OpCodes.putfield, valueRef) .AddReturn(JavaPrimitiveType.Void) .End(javaClass.ConstantPool)); javaClass.Methods.Add(set); WriteClass(javaClass); }