예제 #1
0
 private static TypeWrapper[] LoadTypes(ClassLoaderWrapper loader, string[] classes)
 {
     if (classes == null || classes.Length == 0)
     {
         return(TypeWrapper.EmptyArray);
     }
     TypeWrapper[] tw = new TypeWrapper[classes.Length];
     for (int i = 0; i < tw.Length; i++)
     {
         tw[i] = loader.LoadClassByDottedName(classes[i]);
     }
     return(tw);
 }
예제 #2
0
        internal static void Create(ModuleBuilder modb, ClassLoaderWrapper loader)
        {
            TypeBuilder tb = modb.DefineType(DotNetTypeWrapper.GenericDelegateInterfaceTypeName, TypeAttributes.Interface | TypeAttributes.Abstract | TypeAttributes.Public);

            tb.DefineGenericParameters("T")[0].SetBaseTypeConstraint(Types.MulticastDelegate);
            genericDelegateInterfaceType = tb.CreateType();

            TypeWrapper annotationTypeWrapper = loader.LoadClassByDottedName("java.lang.annotation.Annotation");

            annotationTypeWrapper.Finish();
            genericAttributeAnnotationType            = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationTypeName, annotationTypeWrapper);
            genericAttributeAnnotationMultipleType    = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationMultipleTypeName, annotationTypeWrapper);
            genericAttributeAnnotationReturnValueType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationReturnValueTypeName, annotationTypeWrapper);
            CreateEnumEnum(modb, loader);
        }
예제 #3
0
파일: FakeTypes.cs 프로젝트: moayyaed/ikvm
        internal static void Finish(ClassLoaderWrapper loader)
        {
            TypeBuilder tb = (TypeBuilder)genericEnumEnumType;
            TypeWrapper enumTypeWrapper = loader.LoadClassByDottedName("java.lang.Enum");

            enumTypeWrapper.Finish();
            tb.SetParent(enumTypeWrapper.TypeAsBaseType);
            CodeEmitter ilgen = CodeEmitter.Create(ReflectUtil.DefineConstructor(tb, MethodAttributes.Private, new Type[] { Types.String, Types.Int32 }));

            ilgen.Emit(OpCodes.Ldarg_0);
            ilgen.Emit(OpCodes.Ldarg_1);
            ilgen.Emit(OpCodes.Ldarg_2);
            enumTypeWrapper.GetMethodWrapper("<init>", "(Ljava.lang.String;I)V", false).EmitCall(ilgen);
            ilgen.Emit(OpCodes.Ret);
            ilgen.DoEmit();
            genericEnumEnumType = tb.CreateType();
        }
예제 #4
0
        private static void CreateEnumEnum(ModuleBuilder modb, ClassLoaderWrapper loader)
        {
            TypeWrapper enumTypeWrapper = loader.LoadClassByDottedName("java.lang.Enum");

            enumTypeWrapper.Finish();
            TypeBuilder tb = modb.DefineType(DotNetTypeWrapper.GenericEnumEnumTypeName, TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public, enumTypeWrapper.TypeAsBaseType);
            GenericTypeParameterBuilder gtpb = tb.DefineGenericParameters("T")[0];

            gtpb.SetBaseTypeConstraint(Types.Enum);
            CodeEmitter ilgen = CodeEmitter.Create(tb.DefineConstructor(MethodAttributes.Private, CallingConventions.Standard, new Type[] { Types.String, Types.Int32 }));

            ilgen.Emit(OpCodes.Ldarg_0);
            ilgen.Emit(OpCodes.Ldarg_1);
            ilgen.Emit(OpCodes.Ldarg_2);
            enumTypeWrapper.GetMethodWrapper("<init>", "(Ljava.lang.String;I)V", false).EmitCall(ilgen);
            ilgen.Emit(OpCodes.Ret);
            genericEnumEnumType = tb.CreateType();
        }