Last set of changes preparing for new stub generator. A massive amount of conditional compilation changes, to skip irrelevant code when building ikvmstub.

This commit is contained in:
jfrijters 2010-01-28 07:14:37 +00:00
Родитель f01904d51a
Коммит 1d05c1ed7b
7 изменённых файлов: 186 добавлений и 116 удалений

Просмотреть файл

@ -45,7 +45,7 @@ namespace IKVM.Internal
private string[] references;
private AssemblyClassLoader[] delegates;
private bool isReflectionOnly;
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
private Thread initializerThread;
private int initializerRecursion;
private volatile object protectionDomain;
@ -342,7 +342,7 @@ namespace IKVM.Internal
internal AssemblyClassLoader(Assembly assembly)
: this(assembly, null)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
initializerThread = Thread.CurrentThread;
#endif
}
@ -470,7 +470,7 @@ namespace IKVM.Internal
}
try
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
if (exported)
{
return StaticCompiler.LoadFile(this.MainAssembly.Location + "/../" + new AssemblyName(name).Name + ".dll");
@ -601,7 +601,7 @@ namespace IKVM.Internal
{
return tw;
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if (hasCustomClassLoader)
{
return base.LoadClassImpl(name, throwClassNotFoundException);
@ -760,7 +760,7 @@ namespace IKVM.Internal
private void WaitInitDone()
{
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
if (initializerThread != null)
{
if (initializerThread == Thread.CurrentThread)
@ -801,7 +801,7 @@ namespace IKVM.Internal
internal virtual object GetProtectionDomain()
{
#if STATIC_COMPILER || FIRST_PASS
#if STATIC_COMPILER || FIRST_PASS || STUB_GENERATOR
return null;
#else
if (protectionDomain == null)
@ -928,7 +928,7 @@ namespace IKVM.Internal
return new AssemblyClassLoader(assembly);
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
private void InitializeJavaClassLoader()
{
Assembly assembly = assemblyLoader.Assembly;

Просмотреть файл

@ -50,6 +50,7 @@ namespace IKVM.Internal
RemoveAsserts = 16,
}
#if !STUB_GENERATOR
abstract class TypeWrapperFactory
{
internal abstract ModuleBuilder ModuleBuilder { get; }
@ -57,6 +58,7 @@ namespace IKVM.Internal
internal abstract bool ReserveName(string name);
internal abstract Type DefineUnloadable(string name);
}
#endif // !STUB_GENERATOR
class ClassLoaderWrapper
{
@ -69,10 +71,12 @@ namespace IKVM.Internal
private static AssemblyClassLoader bootstrapClassLoader;
#endif
private static List<GenericClassLoader> genericClassLoaders;
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
protected java.lang.ClassLoader javaClassLoader;
#endif
#if !STUB_GENERATOR
private TypeWrapperFactory factory;
#endif // !STUB_GENERATOR
private Dictionary<string, TypeWrapper> types = new Dictionary<string, TypeWrapper>();
private readonly Dictionary<string, Thread> defineClassInProgress = new Dictionary<string, Thread>();
private List<IntPtr> nativeLibraries;
@ -140,7 +144,7 @@ namespace IKVM.Internal
internal ClassLoaderWrapper(CodeGenOptions codegenoptions, object javaClassLoader)
{
this.codegenoptions = codegenoptions;
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
this.javaClassLoader = (java.lang.ClassLoader)javaClassLoader;
#endif
}
@ -284,6 +288,7 @@ namespace IKVM.Internal
// this hook exists so that AssemblyClassLoader can prevent DefineClass when the name is already present in the assembly
}
#if !STUB_GENERATOR
internal TypeWrapper DefineClass(ClassFile f, object protectionDomain)
{
string dotnetAssembly = f.IKVMAssemblyAttribute;
@ -364,6 +369,7 @@ namespace IKVM.Internal
}
return factory;
}
#endif // !STUB_GENERATOR
internal TypeWrapper LoadClassByDottedName(string name)
{
@ -641,7 +647,7 @@ namespace IKVM.Internal
{
return tw;
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
Profiler.Enter("ClassLoader.loadClass");
try
{
@ -712,7 +718,7 @@ namespace IKVM.Internal
internal object GetJavaClassLoader()
{
#if FIRST_PASS || STATIC_COMPILER
#if FIRST_PASS || STATIC_COMPILER || STUB_GENERATOR
return null;
#else
return javaClassLoader;
@ -881,7 +887,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal static ClassLoaderWrapper GetClassLoaderWrapper(object javaClassLoader)
{
if(javaClassLoader == null)
@ -1024,7 +1030,7 @@ namespace IKVM.Internal
return matchingLoader;
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal static object DoPrivileged(java.security.PrivilegedAction action)
{
return java.security.AccessController.doPrivileged(action, ikvm.@internal.CallerID.create(typeof(java.lang.ClassLoader).TypeHandle));
@ -1047,7 +1053,7 @@ namespace IKVM.Internal
}
}
object javaClassLoader = null;
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
javaClassLoader = DoPrivileged(new AssemblyClassLoader.CreateAssemblyClassLoader(null));
#endif
GenericClassLoader newLoader = new GenericClassLoader(key, javaClassLoader);
@ -1057,7 +1063,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER && __MonoCS__
#if !STATIC_COMPILER && !STUB_GENERATOR && __MonoCS__
// MONOBUG this weird hack is to work around an mcs bug
private static void SetClassLoadWrapperHack<T>(ref T field, ClassLoaderWrapper wrapper)
{
@ -1067,7 +1073,7 @@ namespace IKVM.Internal
protected static void SetWrapperForClassLoader(object javaClassLoader, ClassLoaderWrapper wrapper)
{
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
#if __MonoCS__
SetClassLoadWrapperHack(ref ((java.lang.ClassLoader)javaClassLoader).wrapper, wrapper);
#else
@ -1125,7 +1131,7 @@ namespace IKVM.Internal
{
return GetGenericClassLoaderByName(name);
}
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
return AssemblyClassLoader.FromAssembly(StaticCompiler.Load(name));
#else
return AssemblyClassLoader.FromAssembly(Assembly.Load(name));
@ -1208,7 +1214,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
public override string ToString()
{
if(javaClassLoader == null)
@ -1225,7 +1231,7 @@ namespace IKVM.Internal
return this == friend.GetClassLoader();
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal static ClassLoaderWrapper FromCallerID(object callerID)
{
#if FIRST_PASS

Просмотреть файл

@ -269,7 +269,7 @@ namespace IKVM.Internal
// SECURITY we never expose types from IKVM.Runtime, because doing so would lead to a security hole,
// since the reflection implementation lives inside this assembly, all internal members would
// be accessible through Java reflection.
#if !FIRST_PASS && !STATIC_COMPILER
#if !FIRST_PASS && !STATIC_COMPILER && !STUB_GENERATOR
if (type.Assembly == typeof(DotNetTypeWrapper).Assembly)
{
return false;
@ -353,7 +353,7 @@ namespace IKVM.Internal
internal DelegateInnerClassTypeWrapper(string name, Type delegateType, ClassLoaderWrapper classLoader)
: base(Modifiers.Public | Modifiers.Interface | Modifiers.Abstract, name, null)
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
this.fakeType = FakeTypes.GetDelegateType(delegateType);
#elif !FIRST_PASS
this.fakeType = typeof(ikvm.@internal.DelegateInterface<>).MakeGenericType(delegateType);
@ -436,7 +436,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
object ICustomInvoke.Invoke(object obj, object[] args, ikvm.@internal.CallerID callerID)
{
// a DynamicOnlyMethodWrapper is an interface method, but now that we've been called on an actual object instance,
@ -451,7 +451,7 @@ namespace IKVM.Internal
m.@override = true;
return m.invoke(obj, args, callerID);
}
#endif // !STATIC_COMPILER && !FIRST_PASS
#endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
}
private sealed class EnumEnumTypeWrapper : TypeWrapper
@ -461,7 +461,7 @@ namespace IKVM.Internal
internal EnumEnumTypeWrapper(string name, Type enumType)
: base(Modifiers.Public | Modifiers.Enum | Modifiers.Final, name, ClassLoaderWrapper.LoadClassCritical("java.lang.Enum"))
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
this.fakeType = FakeTypes.GetEnumType(enumType);
#elif !FIRST_PASS
if (enumType.Assembly.ReflectionOnly)
@ -482,7 +482,7 @@ namespace IKVM.Internal
#endif
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal object GetUnspecifiedValue()
{
return ((EnumFieldWrapper)GetFieldWrapper("__unspecified", this.SigName)).GetValue();
@ -491,7 +491,7 @@ namespace IKVM.Internal
private class EnumFieldWrapper : FieldWrapper
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
private readonly int ordinal;
private object val;
#endif
@ -499,12 +499,12 @@ namespace IKVM.Internal
internal EnumFieldWrapper(TypeWrapper tw, string name, int ordinal)
: base(tw, tw, name, tw.SigName, Modifiers.Public | Modifiers.Static | Modifiers.Final | Modifiers.Enum, null, MemberFlags.None)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
this.ordinal = ordinal;
#endif
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal object GetValue()
{
if (val == null)
@ -515,6 +515,7 @@ namespace IKVM.Internal
}
#endif
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
#if STATIC_COMPILER
@ -529,6 +530,7 @@ namespace IKVM.Internal
protected override void EmitSetImpl(CodeEmitter ilgen)
{
}
#endif // !STUB_GENERATOR
}
private class EnumValuesMethodWrapper : MethodWrapper, ICustomInvoke
@ -546,7 +548,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
object ICustomInvoke.Invoke(object obj, object[] args, ikvm.@internal.CallerID callerID)
{
FieldWrapper[] values = this.DeclaringType.GetFields();
@ -557,7 +559,7 @@ namespace IKVM.Internal
}
return array;
}
#endif // !STATIC_COMPILER && !FIRST_PASS
#endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
}
private class EnumValueOfMethodWrapper : MethodWrapper, ICustomInvoke
@ -575,7 +577,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
object ICustomInvoke.Invoke(object obj, object[] args, ikvm.@internal.CallerID callerID)
{
FieldWrapper[] values = this.DeclaringType.GetFields();
@ -588,7 +590,7 @@ namespace IKVM.Internal
}
throw new java.lang.IllegalArgumentException("" + args[0]);
}
#endif // !STATIC_COMPILER && !FIRST_PASS
#endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
}
protected override void LazyPublishMembers()
@ -697,7 +699,7 @@ namespace IKVM.Internal
internal AttributeAnnotationTypeWrapper(string name, Type attributeType)
: base(name)
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
this.fakeType = FakeTypes.GetAttributeType(attributeType);
#elif !FIRST_PASS
this.fakeType = typeof(ikvm.@internal.AttributeAnnotation<>).MakeGenericType(attributeType);
@ -905,7 +907,7 @@ namespace IKVM.Internal
base.LazyPublishMembers();
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override object GetAnnotationDefault(MethodWrapper mw)
{
if (mw.IsOptionalAttributeAnnotationValue)
@ -962,7 +964,7 @@ namespace IKVM.Internal
}
return null;
}
#endif // !STATIC_COMPILER && !FIRST_PASS
#endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override TypeWrapper DeclaringTypeWrapper
{
@ -988,7 +990,7 @@ namespace IKVM.Internal
internal ReturnValueAnnotationTypeWrapper(AttributeAnnotationTypeWrapper declaringType)
: base(declaringType.Name + AttributeAnnotationReturnValueSuffix)
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
this.fakeType = FakeTypes.GetAttributeReturnValueType(declaringType.attributeType);
#elif !FIRST_PASS
this.fakeType = typeof(ikvm.@internal.AttributeAnnotationReturnValue<>).MakeGenericType(declaringType.attributeType);
@ -1031,7 +1033,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override object[] GetDeclaredAnnotations()
{
java.util.HashMap targetMap = new java.util.HashMap();
@ -1135,7 +1137,7 @@ namespace IKVM.Internal
internal MultipleAnnotationTypeWrapper(AttributeAnnotationTypeWrapper declaringType)
: base(declaringType.Name + AttributeAnnotationMultipleSuffix)
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
this.fakeType = FakeTypes.GetAttributeMultipleType(declaringType.attributeType);
#elif !FIRST_PASS
this.fakeType = typeof(ikvm.@internal.AttributeAnnotationMultiple<>).MakeGenericType(declaringType.attributeType);
@ -1174,7 +1176,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal override object[] GetDeclaredAnnotations()
{
return declaringType.GetDeclaredAnnotations();
@ -1350,7 +1352,7 @@ namespace IKVM.Internal
return attr;
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override object[] GetDeclaredAnnotations()
{
// note that AttributeUsageAttribute.Inherited does not map to java.lang.annotation.Inherited
@ -1687,6 +1689,7 @@ namespace IKVM.Internal
this.iface = iface;
}
#if !STUB_GENERATOR
internal override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
{
TypeWrapper targetType = ma == null ? null : ma.GetStackTypeWrapper(opcodeIndex, 0);
@ -1714,6 +1717,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Newobj, delegateConstructor);
}
}
#endif // !STUB_GENERATOR
}
private class ByRefMethodWrapper : SmartMethodWrapper
@ -1732,6 +1736,7 @@ namespace IKVM.Internal
#endif
}
#if !STUB_GENERATOR
protected override void CallImpl(CodeEmitter ilgen)
{
MethodBase mb = GetMethod();
@ -1780,6 +1785,7 @@ namespace IKVM.Internal
}
base.PreEmit(ilgen);
}
#endif // !STUB_GENERATOR
}
private class EnumWrapMethodWrapper : MethodWrapper
@ -1789,12 +1795,14 @@ namespace IKVM.Internal
{
}
#if !STUB_GENERATOR
internal override void EmitCall(CodeEmitter ilgen)
{
// We don't actually need to do anything here!
// The compiler will insert a boxing operation after calling us and that will
// result in our argument being boxed (since that's still sitting on the stack).
}
#endif // !STUB_GENERATOR
}
internal class EnumValueFieldWrapper : FieldWrapper
@ -1807,6 +1815,7 @@ namespace IKVM.Internal
underlyingType = EnumHelper.GetUnderlyingType(tw.type);
}
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
// NOTE if the reference on the stack is null, we *want* the NullReferenceException, so we don't use TypeWrapper.EmitUnbox
@ -1824,6 +1833,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Stobj, underlyingType);
ilgen.ReleaseTempLocal(temp);
}
#endif // !STUB_GENERATOR
}
private class ValueTypeDefaultCtor : MethodWrapper
@ -1833,12 +1843,14 @@ namespace IKVM.Internal
{
}
#if !STUB_GENERATOR
internal override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
{
LocalBuilder local = ilgen.DeclareLocal(DeclaringType.TypeAsTBD);
ilgen.Emit(OpCodes.Ldloc, local);
ilgen.Emit(OpCodes.Box, DeclaringType.TypeAsTBD);
}
#endif // !STUB_GENERATOR
}
private class FinalizeMethodWrapper : MethodWrapper
@ -1848,6 +1860,7 @@ namespace IKVM.Internal
{
}
#if !STUB_GENERATOR
internal override void EmitCall(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Pop);
@ -1857,6 +1870,7 @@ namespace IKVM.Internal
{
ilgen.Emit(OpCodes.Pop);
}
#endif // !STUB_GENERATOR
}
private class CloneMethodWrapper : MethodWrapper
@ -1866,6 +1880,7 @@ namespace IKVM.Internal
{
}
#if !STUB_GENERATOR
internal override void EmitCall(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Dup);
@ -1885,6 +1900,7 @@ namespace IKVM.Internal
{
EmitCall(ilgen);
}
#endif // !STUB_GENERATOR
}
protected override void LazyPublishMembers()
@ -2143,6 +2159,7 @@ namespace IKVM.Internal
this.m = m;
}
#if !STUB_GENERATOR
internal override void EmitCall(CodeEmitter ilgen)
{
// we direct EmitCall to EmitCallvirt, because we always want to end up at the instancehelper method
@ -2154,6 +2171,7 @@ namespace IKVM.Internal
{
m.EmitCallvirt(ilgen);
}
#endif // !STUB_GENERATOR
}
internal static bool IsUnsupportedAbstractMethod(MethodBase mb)
@ -2485,6 +2503,7 @@ namespace IKVM.Internal
}
}
#if !STUB_GENERATOR
internal override void EmitInstanceOf(TypeWrapper context, CodeEmitter ilgen)
{
if (IsRemapped)
@ -2514,6 +2533,7 @@ namespace IKVM.Internal
}
ilgen.EmitCastclass(type);
}
#endif // !STUB_GENERATOR
internal override void Finish()
{
@ -2527,7 +2547,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal override object[] GetDeclaredAnnotations()
{
if (type.Assembly.ReflectionOnly)

Просмотреть файл

@ -44,7 +44,7 @@ abstract class RetargetableJavaException : ApplicationException
return String.Format(s, args);
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal abstract Exception ToJava();
#elif FIRST_PASS
internal virtual Exception ToJava()
@ -65,7 +65,7 @@ class ClassLoadingException : RetargetableJavaException
{
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal override Exception ToJava()
{
return InnerException;
@ -83,7 +83,7 @@ class LinkageError : RetargetableJavaException
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.LinkageError(Message);
@ -105,7 +105,7 @@ class VerifyError : LinkageError
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.VerifyError(Message);
@ -119,7 +119,7 @@ class ClassNotFoundException : RetargetableJavaException
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.ClassNotFoundException(Message);
@ -133,7 +133,7 @@ class ClassCircularityError : LinkageError
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.ClassCircularityError(Message);
@ -147,7 +147,7 @@ class NoClassDefFoundError : LinkageError
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.NoClassDefFoundError(Message);
@ -161,7 +161,7 @@ class IncompatibleClassChangeError : LinkageError
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.IncompatibleClassChangeError(Message);
@ -175,7 +175,7 @@ class IllegalAccessError : IncompatibleClassChangeError
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.IllegalAccessError(Message);
@ -190,7 +190,7 @@ class ClassFormatError : LinkageError
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.ClassFormatError(Message);
@ -205,7 +205,7 @@ class UnsupportedClassVersionError : ClassFormatError
{
}
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal override Exception ToJava()
{
return new java.lang.UnsupportedClassVersionError(Message);

Просмотреть файл

@ -312,14 +312,14 @@ namespace IKVM.Internal
interface ICustomInvoke
{
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
object Invoke(object obj, object[] args, ikvm.@internal.CallerID callerID);
#endif
}
abstract class MethodWrapper : MemberWrapper
{
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
private static Dictionary<MethodWrapper, sun.reflect.MethodAccessor> invokenonvirtualCache;
private volatile object reflectionMethod;
#endif
@ -329,6 +329,7 @@ namespace IKVM.Internal
private TypeWrapper returnTypeWrapper;
private TypeWrapper[] parameterTypeWrappers;
#if !STUB_GENERATOR
internal virtual void EmitCall(CodeEmitter ilgen)
{
throw new InvalidOperationException();
@ -353,6 +354,7 @@ namespace IKVM.Internal
{
throw new InvalidOperationException();
}
#endif // STUB_GENERATOR
internal virtual bool IsDynamicOnly
{
@ -385,11 +387,13 @@ namespace IKVM.Internal
}
}
#if !STUB_GENERATOR
protected override void CallvirtImpl(CodeEmitter ilgen)
{
ResolveGhostMethod();
ilgen.Emit(OpCodes.Call, ghostMethod);
}
#endif
}
internal static MethodWrapper Create(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
@ -466,7 +470,7 @@ namespace IKVM.Internal
this.declaredExceptions = (string[])exceptions.Clone();
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal object ToMethodOrConstructor(bool copy)
{
#if FIRST_PASS
@ -591,7 +595,7 @@ namespace IKVM.Internal
return TypeWrapper.FromClass(constructor.getDeclaringClass()).GetMethods()[constructor._slot()];
#endif
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
internal static MethodWrapper FromCookie(IntPtr cookie)
{
@ -770,7 +774,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
[HideFromJava]
internal object InvokeJNI(object obj, object[] args, bool nonVirtual, object callerID)
{
@ -894,9 +898,9 @@ namespace IKVM.Internal
}
return args;
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal void ResolveMethod()
{
// if we've still got the builder object, we need to replace it with the real thing before we can call it
@ -981,7 +985,7 @@ namespace IKVM.Internal
return args;
}
}
#endif // !STATIC_COMPILER && !FIRST_PASS
#endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
internal static OpCode SimpleOpCodeToOpCode(SimpleOpCode opc)
{
@ -1027,6 +1031,7 @@ namespace IKVM.Internal
{
}
#if !STUB_GENERATOR
protected virtual void PreEmit(CodeEmitter ilgen)
{
}
@ -1079,6 +1084,7 @@ namespace IKVM.Internal
{
throw new InvalidOperationException();
}
#endif // STUB_GENERATOR
}
enum SimpleOpCode : byte
@ -1100,6 +1106,7 @@ namespace IKVM.Internal
this.callvirt = callvirt;
}
#if !STUB_GENERATOR
internal override void EmitCall(CodeEmitter ilgen)
{
ilgen.Emit(SimpleOpCodeToOpCode(call), (MethodInfo)GetMethod());
@ -1109,6 +1116,7 @@ namespace IKVM.Internal
{
ilgen.Emit(SimpleOpCodeToOpCode(callvirt), (MethodInfo)GetMethod());
}
#endif // !STUB_GENERATOR
}
sealed class SmartCallMethodWrapper : SmartMethodWrapper
@ -1123,6 +1131,7 @@ namespace IKVM.Internal
this.callvirt = callvirt;
}
#if !STUB_GENERATOR
protected override void CallImpl(CodeEmitter ilgen)
{
ilgen.Emit(SimpleOpCodeToOpCode(call), (MethodInfo)GetMethod());
@ -1132,6 +1141,7 @@ namespace IKVM.Internal
{
ilgen.Emit(SimpleOpCodeToOpCode(callvirt), (MethodInfo)GetMethod());
}
#endif // !STUB_GENERATOR
}
sealed class SmartConstructorMethodWrapper : SmartMethodWrapper
@ -1141,6 +1151,7 @@ namespace IKVM.Internal
{
}
#if !STUB_GENERATOR
protected override void CallImpl(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Call, (ConstructorInfo)GetMethod());
@ -1150,11 +1161,12 @@ namespace IKVM.Internal
{
ilgen.Emit(OpCodes.Newobj, (ConstructorInfo)GetMethod());
}
#endif // !STUB_GENERATOR
}
abstract class FieldWrapper : MemberWrapper
{
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
private static readonly FieldInfo slotField = typeof(java.lang.reflect.Field).GetField("slot", BindingFlags.Instance | BindingFlags.NonPublic);
private volatile java.lang.reflect.Field reflectionField;
private sun.reflect.FieldAccessor jniAccessor;
@ -1206,7 +1218,7 @@ namespace IKVM.Internal
Debug.Assert(fieldType != null, this.DeclaringType.Name + "::" + this.Name + " (" + this.Signature+ ")");
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
// NOTE used (thru IKVM.Runtime.Util.GetFieldConstantValue) by ikvmstub to find out if the
// field is a constant (and if it is, to get its value)
internal object GetConstant()
@ -1288,7 +1300,7 @@ namespace IKVM.Internal
return field;
#endif // FIRST_PASS
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
internal static FieldWrapper FromCookie(IntPtr cookie)
{
@ -1304,6 +1316,7 @@ namespace IKVM.Internal
}
}
#if !STUB_GENERATOR
internal void EmitGet(CodeEmitter ilgen)
{
AssertLinked();
@ -1319,6 +1332,7 @@ namespace IKVM.Internal
}
protected abstract void EmitSetImpl(CodeEmitter ilgen);
#endif // !STUB_GENERATOR
internal void Link()
{
@ -1369,7 +1383,7 @@ namespace IKVM.Internal
return new SimpleFieldWrapper(declaringType, fieldType, fi, name, sig, modifiers);
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal virtual void ResolveField()
{
FieldBuilder fb = field as FieldBuilder;
@ -1391,7 +1405,7 @@ namespace IKVM.Internal
return jniAccessor;
#endif
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
}
sealed class SimpleFieldWrapper : FieldWrapper
@ -1402,6 +1416,7 @@ namespace IKVM.Internal
Debug.Assert(!(fieldType == PrimitiveTypeWrapper.DOUBLE || fieldType == PrimitiveTypeWrapper.LONG) || !IsVolatile);
}
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
if(!IsStatic && DeclaringType.IsNonPrimitiveValueType)
@ -1431,6 +1446,7 @@ namespace IKVM.Internal
}
ilgen.Emit(IsStatic ? OpCodes.Stsfld : OpCodes.Stfld, fi);
}
#endif // !STUB_GENERATOR
}
sealed class VolatileLongDoubleFieldWrapper : FieldWrapper
@ -1442,6 +1458,7 @@ namespace IKVM.Internal
Debug.Assert(sig == "J" || sig == "D");
}
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
FieldInfo fi = GetField();
@ -1496,6 +1513,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Call, ByteCodeHelperMethods.volatileWriteLong);
}
}
#endif // !STUB_GENERATOR
}
sealed class GetterFieldWrapper : FieldWrapper
@ -1528,6 +1546,7 @@ namespace IKVM.Internal
return prop;
}
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
if(!IsStatic && DeclaringType.IsNonPrimitiveValueType)
@ -1566,8 +1585,10 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Call, prop.GetSetMethod(true));
}
}
#endif // !STUB_GENERATOR
}
#if !STUB_GENERATOR
// this class represents a .NET property defined in Java with the ikvm.lang.Property annotation
sealed class DynamicPropertyFieldWrapper : FieldWrapper
{
@ -1714,6 +1735,7 @@ namespace IKVM.Internal
}
}
}
#endif // !STUB_GENERATOR
// this class represents a .NET property defined in Java with the ikvm.lang.Property annotation
sealed class CompiledPropertyFieldWrapper : FieldWrapper
@ -1726,6 +1748,7 @@ namespace IKVM.Internal
this.property = property;
}
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
MethodInfo getter = property.GetGetMethod(true);
@ -1770,6 +1793,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Callvirt, setter);
}
}
#endif // !STUB_GENERATOR
internal PropertyInfo GetProperty()
{
@ -1790,6 +1814,7 @@ namespace IKVM.Internal
this.constant = constant;
}
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
// Reading a field should trigger the cctor, but since we're inlining the value
@ -1850,6 +1875,7 @@ namespace IKVM.Internal
// constant value is inlined), so we emulate that behavior by emitting a Pop
ilgen.LazyEmitPop();
}
#endif // !STUB_GENERATOR
internal object GetConstantValue()
{
@ -1890,6 +1916,7 @@ namespace IKVM.Internal
this.setter = property.GetSetMethod(true);
}
#if !STUB_GENERATOR
protected override void EmitGetImpl(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Call, getter);
@ -1899,6 +1926,7 @@ namespace IKVM.Internal
{
ilgen.Emit(OpCodes.Call, setter);
}
#endif // !STUB_GENERATOR
internal static bool TryGet(TypeWrapper wrapper, PropertyInfo property, out FieldWrapper accessStub)
{

Просмотреть файл

@ -722,7 +722,7 @@ namespace IKVM.Internal
internal static object GetConstantValue(FieldInfo field)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!field.DeclaringType.Assembly.ReflectionOnly)
{
// In Java, instance fields can also have a ConstantValue attribute so we emulate that
@ -750,7 +750,7 @@ namespace IKVM.Internal
internal static ModifiersAttribute GetModifiersAttribute(Type type)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
object[] attr = type.GetCustomAttributes(typeof(ModifiersAttribute), false);
@ -777,7 +777,7 @@ namespace IKVM.Internal
internal static ModifiersAttribute GetModifiersAttribute(PropertyInfo property)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if (!property.DeclaringType.Assembly.ReflectionOnly)
{
object[] attr = property.GetCustomAttributes(typeof(ModifiersAttribute), false);
@ -804,7 +804,7 @@ namespace IKVM.Internal
internal static ExModifiers GetModifiers(MethodBase mb, bool assemblyIsPrivate)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!mb.DeclaringType.Assembly.ReflectionOnly)
{
object[] customAttribute = mb.GetCustomAttributes(typeof(ModifiersAttribute), false);
@ -885,7 +885,7 @@ namespace IKVM.Internal
internal static ExModifiers GetModifiers(FieldInfo fi, bool assemblyIsPrivate)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!fi.DeclaringType.Assembly.ReflectionOnly)
{
object[] customAttribute = fi.GetCustomAttributes(typeof(ModifiersAttribute), false);
@ -1168,7 +1168,7 @@ namespace IKVM.Internal
internal static NameSigAttribute GetNameSig(FieldInfo field)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!field.DeclaringType.Assembly.ReflectionOnly)
{
object[] attr = field.GetCustomAttributes(typeof(NameSigAttribute), false);
@ -1191,7 +1191,7 @@ namespace IKVM.Internal
internal static NameSigAttribute GetNameSig(PropertyInfo property)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!property.DeclaringType.Assembly.ReflectionOnly)
{
object[] attr = property.GetCustomAttributes(typeof(NameSigAttribute), false);
@ -1214,7 +1214,7 @@ namespace IKVM.Internal
internal static NameSigAttribute GetNameSig(MethodBase method)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!method.DeclaringType.Assembly.ReflectionOnly)
{
object[] attr = method.GetCustomAttributes(typeof(NameSigAttribute), false);
@ -1248,7 +1248,7 @@ namespace IKVM.Internal
internal static ImplementsAttribute GetImplements(Type type)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
object[] attribs = type.GetCustomAttributes(typeof(ImplementsAttribute), false);
@ -1272,12 +1272,14 @@ namespace IKVM.Internal
#if !STATIC_COMPILER
internal static ThrowsAttribute GetThrows(MethodBase mb)
{
#if !STUB_GENERATOR
if(!mb.DeclaringType.Assembly.ReflectionOnly)
{
object[] attribs = mb.GetCustomAttributes(typeof(ThrowsAttribute), false);
return attribs.Length == 1 ? (ThrowsAttribute)attribs[0] : null;
}
else
#endif
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(mb))
{
@ -1305,7 +1307,7 @@ namespace IKVM.Internal
internal static string[] GetNonNestedInnerClasses(Type t)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!t.Assembly.ReflectionOnly)
{
object[] attribs = t.GetCustomAttributes(typeof(NonNestedInnerClassAttribute), false);
@ -1334,7 +1336,7 @@ namespace IKVM.Internal
internal static string GetNonNestedOuterClasses(Type t)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!t.Assembly.ReflectionOnly)
{
object[] attribs = t.GetCustomAttributes(typeof(NonNestedOuterClassAttribute), false);
@ -1357,7 +1359,7 @@ namespace IKVM.Internal
internal static SignatureAttribute GetSignature(MethodBase mb)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!mb.DeclaringType.Assembly.ReflectionOnly)
{
object[] attribs = mb.GetCustomAttributes(typeof(SignatureAttribute), false);
@ -1380,7 +1382,7 @@ namespace IKVM.Internal
internal static SignatureAttribute GetSignature(Type type)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
object[] attribs = type.GetCustomAttributes(typeof(SignatureAttribute), false);
@ -1403,7 +1405,7 @@ namespace IKVM.Internal
internal static SignatureAttribute GetSignature(FieldInfo fi)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!fi.DeclaringType.Assembly.ReflectionOnly)
{
object[] attribs = fi.GetCustomAttributes(typeof(SignatureAttribute), false);
@ -1426,7 +1428,7 @@ namespace IKVM.Internal
internal static InnerClassAttribute GetInnerClass(Type type)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
object[] attribs = type.GetCustomAttributes(typeof(InnerClassAttribute), false);
@ -1449,7 +1451,7 @@ namespace IKVM.Internal
internal static RemappedInterfaceMethodAttribute[] GetRemappedInterfaceMethods(Type type)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
object[] attr = type.GetCustomAttributes(typeof(RemappedInterfaceMethodAttribute), false);
@ -1475,7 +1477,7 @@ namespace IKVM.Internal
internal static RemappedTypeAttribute GetRemappedType(Type type)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
object[] attribs = type.GetCustomAttributes(typeof(RemappedTypeAttribute), false);
@ -1498,7 +1500,7 @@ namespace IKVM.Internal
internal static RemappedClassAttribute[] GetRemappedClasses(Assembly coreAssembly)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!coreAssembly.ReflectionOnly)
{
object[] attr = coreAssembly.GetCustomAttributes(typeof(RemappedClassAttribute), false);
@ -1524,7 +1526,7 @@ namespace IKVM.Internal
internal static string GetAnnotationAttributeType(Type type)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
object[] attr = type.GetCustomAttributes(typeof(AnnotationAttributeAttribute), false);
@ -1570,7 +1572,7 @@ namespace IKVM.Internal
internal static bool IsDefined(Module mod, Type attribute)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!mod.Assembly.ReflectionOnly)
{
return mod.IsDefined(attribute, false);
@ -1592,7 +1594,7 @@ namespace IKVM.Internal
internal static bool IsDefined(Assembly asm, Type attribute)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!asm.ReflectionOnly)
{
return asm.IsDefined(attribute, false);
@ -1613,7 +1615,7 @@ namespace IKVM.Internal
internal static bool IsDefined(Type type, Type attribute)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!type.Assembly.ReflectionOnly)
{
return type.IsDefined(attribute, false);
@ -1635,7 +1637,7 @@ namespace IKVM.Internal
internal static bool IsDefined(ParameterInfo pi, Type attribute)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!pi.Member.DeclaringType.Assembly.ReflectionOnly)
{
return pi.IsDefined(attribute, false);
@ -1657,7 +1659,7 @@ namespace IKVM.Internal
internal static bool IsDefined(MemberInfo member, Type attribute)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!member.DeclaringType.Assembly.ReflectionOnly)
{
return member.IsDefined(attribute, false);
@ -1684,7 +1686,7 @@ namespace IKVM.Internal
internal static object[] GetJavaModuleAttributes(Module mod)
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(!mod.Assembly.ReflectionOnly)
{
return mod.GetCustomAttributes(typeofJavaModuleAttribute, false);
@ -1731,7 +1733,7 @@ namespace IKVM.Internal
}
else
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
object[] attr = type.GetCustomAttributes(typeof(EnclosingMethodAttribute), false);
if (attr.Length == 1)
{
@ -2203,7 +2205,7 @@ namespace IKVM.Internal
private MethodWrapper[] methods;
private FieldWrapper[] fields;
private readonly TypeWrapper baseWrapper;
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
private object classObject;
#endif
internal static readonly TypeWrapper[] EmptyArray = new TypeWrapper[0];
@ -2221,6 +2223,7 @@ namespace IKVM.Internal
this.baseWrapper = baseWrapper;
}
#if !STUB_GENERATOR
internal void EmitClassLiteral(CodeEmitter ilgen)
{
Debug.Assert(!this.IsPrimitive);
@ -2238,6 +2241,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Ldsfld, RuntimeHelperTypes.GetClassLiteralField(type));
}
}
#endif // !STUB_GENERATOR
private Type GetClassLiteralType()
{
@ -2275,7 +2279,7 @@ namespace IKVM.Internal
get { return false; }
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal void SetClassObject(object classObject)
{
this.classObject = classObject;
@ -2469,7 +2473,7 @@ namespace IKVM.Internal
return tw;
#endif
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
public override string ToString()
{
@ -3295,7 +3299,7 @@ namespace IKVM.Internal
return this.IsSubTypeOf(wrapper);
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal bool IsInstance(object obj)
{
if(obj != null)
@ -3340,7 +3344,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal void RunClassInit()
{
Type t = IsRemapped ? TypeAsBaseType : TypeAsTBD;
@ -3351,6 +3355,7 @@ namespace IKVM.Internal
}
#endif
#if !STUB_GENERATOR
internal void EmitUnbox(CodeEmitter ilgen)
{
Debug.Assert(this.IsNonPrimitiveValueType);
@ -3485,6 +3490,7 @@ namespace IKVM.Internal
ilgen.LazyEmit_instanceof(TypeAsTBD);
}
}
#endif // !STUB_GENERATOR
// NOTE don't call this method, call MethodWrapper.Link instead
internal virtual MethodBase LinkMethod(MethodWrapper mw)
@ -3498,9 +3504,11 @@ namespace IKVM.Internal
return fw.GetField();
}
#if !STUB_GENERATOR
internal virtual void EmitRunClassConstructor(CodeEmitter ilgen)
{
}
#endif // !STUB_GENERATOR
internal virtual string GetGenericSignature()
{
@ -3517,7 +3525,7 @@ namespace IKVM.Internal
return null;
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal virtual string[] GetEnclosingMethod()
{
return null;
@ -3571,7 +3579,7 @@ namespace IKVM.Internal
}
return null;
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
internal virtual Annotation Annotation
{
@ -3714,6 +3722,7 @@ namespace IKVM.Internal
throw new InvalidOperationException("Finish called on UnloadableTypeWrapper: " + Name);
}
#if !STUB_GENERATOR
internal override void EmitCheckcast(TypeWrapper context, CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Ldtoken, context.TypeAsTBD);
@ -3727,6 +3736,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Ldstr, Name);
ilgen.Emit(OpCodes.Call, ByteCodeHelperMethods.DynamicInstanceOf);
}
#endif // !STUB_GENERATOR
}
sealed class PrimitiveTypeWrapper : TypeWrapper
@ -4467,12 +4477,14 @@ namespace IKVM.Internal
invoke = (MethodInfo)mw.GetMethod();
}
#if !STUB_GENERATOR
internal override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
{
ilgen.Emit(OpCodes.Dup);
ilgen.Emit(OpCodes.Ldvirtftn, invoke);
ilgen.Emit(OpCodes.Newobj, constructor);
}
#endif // !STUB_GENERATOR
}
protected override void LazyPublishMethods()
@ -4593,6 +4605,7 @@ namespace IKVM.Internal
#endif
}
#if !STUB_GENERATOR
protected override void CallImpl(CodeEmitter ilgen)
{
MethodBase mb = GetMethod();
@ -4635,8 +4648,9 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Newobj, (ConstructorInfo)mb);
}
}
#endif // !STUB_GENERATOR
#if !STATIC_COMPILER && !FIRST_PASS
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
[HideFromJava]
protected override object InvokeNonvirtualRemapped(object obj, object[] args)
{
@ -4749,6 +4763,7 @@ namespace IKVM.Internal
}
}
#if !STUB_GENERATOR
internal override void EmitRunClassConstructor(CodeEmitter ilgen)
{
if(HasStaticInitializer)
@ -4756,6 +4771,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Call, clinitMethod);
}
}
#endif // !STUB_GENERATOR
internal override string GetGenericSignature()
{
@ -4811,7 +4827,7 @@ namespace IKVM.Internal
return null;
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal override string[] GetEnclosingMethod()
{
EnclosingMethodAttribute enc = AttributeHelper.GetEnclosingMethodAttribute(type);
@ -4998,7 +5014,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal override string GetSourceFileName()
{
object[] attr = type.GetCustomAttributes(typeof(SourceFileAttribute), false);

Просмотреть файл

@ -36,7 +36,7 @@ using System.Security;
using System.Security.Permissions;
using IKVM.Internal;
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
namespace IKVM.Internal
{
public static class Starter
@ -79,7 +79,7 @@ namespace IKVM.Internal
}
}
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
namespace IKVM.Internal
{
@ -89,7 +89,7 @@ namespace IKVM.Internal
internal const bool IsStaticCompiler = true;
internal const bool FinishingForDebugSave = false;
internal const bool IsSaveDebugImage = false;
#else
#elif !STUB_GENERATOR
internal const bool IsStaticCompiler = false;
private static bool finishingForDebugSave;
private static int emitSymbols;
@ -134,7 +134,7 @@ namespace IKVM.Internal
{
get
{
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
if(coreAssembly == null)
{
#if FIRST_PASS
@ -152,7 +152,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal static bool FinishingForDebugSave
{
get
@ -189,7 +189,7 @@ namespace IKVM.Internal
return emitSymbols == 1;
}
}
#endif // !STATIC_COMPILER
#endif // !STATIC_COMPILER && !STUB_GENERATOR
internal static bool IsUnix
{
@ -251,7 +251,7 @@ namespace IKVM.Internal
{
Tracer.Error(Tracer.Runtime, "CRITICAL FAILURE: {0}", message);
System.Type messageBox = null;
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
// NOTE we use reflection to invoke MessageBox.Show, to make sure we run in environments where WinForms isn't available
Assembly winForms = IsUnix ? null : Assembly.Load("System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
if(winForms != null)
@ -309,7 +309,7 @@ namespace IKVM.Internal
// with can be different from the one we're compiling against.)
internal static Type LoadType(Type type)
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
return StaticCompiler.GetRuntimeType(type.FullName);
#else
return type;
@ -318,7 +318,7 @@ namespace IKVM.Internal
internal static object Box(object val)
{
#if STATIC_COMPILER || FIRST_PASS
#if STATIC_COMPILER || FIRST_PASS || STUB_GENERATOR
return null;
#else
if(val is byte)
@ -362,7 +362,7 @@ namespace IKVM.Internal
internal static object Unbox(object val)
{
#if STATIC_COMPILER || FIRST_PASS
#if STATIC_COMPILER || FIRST_PASS || STUB_GENERATOR
return null;
#else
java.lang.Byte b = val as java.lang.Byte;
@ -412,7 +412,7 @@ namespace IKVM.Internal
#endif
}
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal static object NewAnnotation(object classLoader, object definition)
{
#if FIRST_PASS
@ -423,7 +423,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
internal static object NewAnnotationElementValue(object classLoader, object expectedClass, object definition)
{
#if FIRST_PASS
@ -442,7 +442,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
#if !STATIC_COMPILER && !STUB_GENERATOR
// helper for JNI (which doesn't have access to core library internals)
internal static object NewDirectByteBuffer(long address, int capacity)
{
@ -456,7 +456,7 @@ namespace IKVM.Internal
internal static Type Import(System.Type type)
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
return StaticCompiler.Universe.Import(type);
#else
return type;
@ -465,7 +465,7 @@ namespace IKVM.Internal
internal static Type GetType(string typeName, bool throwOnError)
{
#if STATIC_COMPILER
#if STATIC_COMPILER || STUB_GENERATOR
return StaticCompiler.Universe.GetType(typeName, throwOnError);
#else
return Type.GetType(typeName, throwOnError);