diff options
author | jfrijters <jfrijters> | 2011-12-12 15:21:29 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-12-12 15:21:29 +0400 |
commit | d6dc2d72562b5ce10e958c568e7b33bdefd9d005 (patch) | |
tree | cd3ffb46f634c23c84435f4e5d37c1b5a35c6f71 | |
parent | 063a9f470f72ace4d5d82c0bcb8cb5034b76316d (diff) |
Removed TypeAsBuilder usage from method handle code.
-rw-r--r-- | runtime/DynamicTypeWrapper.cs | 17 | ||||
-rw-r--r-- | runtime/compiler.cs | 7 |
2 files changed, 20 insertions, 4 deletions
diff --git a/runtime/DynamicTypeWrapper.cs b/runtime/DynamicTypeWrapper.cs index 5e1f517c..a6d72511 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -5326,6 +5326,23 @@ namespace IKVM.Internal RegisterNestedTypeBuilder(tb); return tb; } + + internal TypeBuilder DefineMethodHandleConstantType(int index) + { + TypeBuilder tb = typeBuilder.DefineNestedType("__<>MHC" + index, TypeAttributes.NestedPrivate | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit); ; + RegisterNestedTypeBuilder(tb); + return tb; + } + + internal MethodBuilder DefineMethodHandleDispatchStub(Type returnType, Type[] parameterTypes) + { + return typeBuilder.DefineMethod("__<>MHC", MethodAttributes.Static | MethodAttributes.PrivateScope, returnType, parameterTypes); + } + + internal FieldBuilder DefineMethodHandleInvokeCacheField(Type fieldType) + { + return typeBuilder.DefineField("__<>invokeCache", fieldType, FieldAttributes.Static | FieldAttributes.PrivateScope); + } } private static bool CheckRequireOverrideStub(MethodWrapper mw1, MethodWrapper mw2) diff --git a/runtime/compiler.cs b/runtime/compiler.cs index d39f7554..39bb3e92 100644 --- a/runtime/compiler.cs +++ b/runtime/compiler.cs @@ -3261,7 +3261,7 @@ sealed class Compiler private static FieldBuilder CreateField(Compiler compiler, int index) { - TypeBuilder tb = compiler.clazz.TypeAsBuilder.DefineNestedType("__<>MHC" + index, TypeAttributes.NestedPrivate | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit); + TypeBuilder tb = compiler.context.DefineMethodHandleConstantType(index); FieldBuilder field = tb.DefineField("value", CoreClasses.java.lang.invoke.MethodHandle.Wrapper.TypeAsSignatureType, FieldAttributes.Assembly | FieldAttributes.Static | FieldAttributes.InitOnly); ConstructorBuilder cb = tb.DefineConstructor(MethodAttributes.Static, CallingConventions.Standard, Type.EmptyTypes); ILGenerator ilgen = cb.GetILGenerator(); @@ -3326,7 +3326,6 @@ sealed class Compiler ilgen.Emit(OpCodes.Call, ByteCodeHelperMethods.MethodHandleFromDelegate); ilgen.Emit(OpCodes.Stsfld, field); ilgen.Emit(OpCodes.Ret); - tb.CreateType(); return field; } @@ -3342,7 +3341,7 @@ sealed class Compiler ret = args[args.Length - 1]; Array.Resize(ref args, args.Length - 1); } - MethodBuilder mb = compiler.clazz.TypeAsBuilder.DefineMethod("__<>MHC", MethodAttributes.Static | MethodAttributes.PrivateScope, ret, args); + MethodBuilder mb = compiler.context.DefineMethodHandleDispatchStub(ret, args); CodeEmitter ilgen = CodeEmitter.Create(mb); if (args.Length > 0 && MethodHandleUtil.IsPackedArgsContainer(args[args.Length - 1])) { @@ -3761,7 +3760,7 @@ sealed class Compiler #else typeofInvokeCache = typeof(IKVM.Runtime.InvokeCache<>); #endif - FieldBuilder fb = wrapper.TypeAsBuilder.DefineField("__<>invokeCache", typeofInvokeCache.MakeGenericType(delegateType), FieldAttributes.Static | FieldAttributes.PrivateScope); + FieldBuilder fb = context.DefineMethodHandleInvokeCacheField(typeofInvokeCache.MakeGenericType(delegateType)); ilgen.Emit(OpCodes.Ldloc, temps[0]); ilgen.Emit(OpCodes.Ldsflda, fb); ilgen.Emit(OpCodes.Call, mi); |