private void LoadMethod(MosaType declType, MosaMethod.Mutator method, MethodDef methodDef) { MethodSig methodSig = methodDef.MethodSig; method.Module = declType.Module; method.UnderlyingObject = new UnitDesc <MethodDef, MethodSig>(methodDef.Module, methodDef, methodSig); method.DeclaringType = declType; method.Name = methodDef.Name; method.MethodAttributes = (MosaMethodAttributes)methodDef.Attributes; method.IsAbstract = methodDef.IsAbstract; method.IsStatic = methodDef.IsStatic; method.HasThis = methodDef.HasThis; method.HasExplicitThis = methodDef.ExplicitThis; method.IsInternalCall = methodDef.IsInternalCall; method.IsNoInlining = methodDef.IsNoInlining; method.IsSpecialName = methodDef.IsSpecialName; method.IsRTSpecialName = methodDef.IsRuntimeSpecialName; method.IsVirtual = methodDef.IsVirtual; method.IsNewSlot = methodDef.IsNewSlot; method.IsFinal = methodDef.IsFinal; method.IsSpecialName = methodDef.IsSpecialName; if (methodDef.HasImplMap) { method.ExternMethod = methodDef.ImplMap.Module.Name; } }
private void LoadMethod(MosaType declType, MosaMethod.Mutator method, MethodDef methodDef) { var methodSig = methodDef.MethodSig; method.Module = declType.Module; method.UnderlyingObject = new UnitDesc <MethodDef, MethodSig>(methodDef.Module, methodDef, methodSig); method.DeclaringType = declType; method.Name = methodDef.Name; method.MethodAttributes = (MosaMethodAttributes)methodDef.Attributes; method.IsAbstract = methodDef.IsAbstract; method.IsStatic = methodDef.IsStatic; method.HasThis = methodDef.HasThis; method.HasExplicitThis = methodDef.ExplicitThis; method.IsInternalCall = methodDef.IsInternalCall; method.IsNoInlining = methodDef.IsNoInlining; method.IsAggressiveInlining = methodDef.IsAggressiveInlining; method.IsSpecialName = methodDef.IsSpecialName; method.IsRTSpecialName = methodDef.IsRuntimeSpecialName; method.IsVirtual = methodDef.IsVirtual; method.IsNewSlot = methodDef.IsNewSlot; method.IsFinal = methodDef.IsFinal; method.IsSpecialName = methodDef.IsSpecialName; if (methodDef.HasImplMap) { method.IsExternal = true; method.ExternMethodModule = methodDef.ImplMap.Module.Name; method.ExternMethodName = methodDef.ImplMap.Name; } if (methodDef.HasGenericParameters) { foreach (var genericParam in methodDef.GenericParameters) { var genericArg = LoadGenericParam(new GenericMVar(genericParam.Number)); method.GenericArguments.Add(genericArg); } } // Special treatment for SZArrayHelper constructor if (methodDef.DeclaringType.Name == "SZArrayHelper" && methodDef.Name == ".ctor") { var genericArg = LoadGenericParam(new GenericMVar(0)); method.GenericArguments.Add(genericArg); } }
private void ResolveBody(MethodDef methodDef, MosaMethod.Mutator method, CilBody body, GenericArgumentResolver resolver) { method.LocalVariables.Clear(); int index = 0; foreach (var variable in body.Variables) { method.LocalVariables.Add(new MosaLocal( variable.Name ?? "V_" + index, metadata.Loader.GetType(resolver.Resolve(variable.Type)), variable.Type.IsPinned)); index++; } method.ExceptionBlocks.Clear(); foreach (var eh in body.ExceptionHandlers) { method.ExceptionBlocks.Add(new MosaExceptionHandler( (ExceptionHandlerType)eh.HandlerType, ResolveOffset(body, eh.TryStart), ResolveOffset(body, eh.TryEnd), ResolveOffset(body, eh.HandlerStart), ResolveOffset(body, eh.HandlerEnd), eh.CatchType == null ? null : metadata.Loader.GetType(resolver.Resolve(eh.CatchType.ToTypeSig())), eh.FilterStart == null ? null : (int?)eh.FilterStart.Offset )); } method.MaxStack = methodDef.Body.MaxStack; method.Code.Clear(); for (int i = 0; i < body.Instructions.Count; i++) { method.Code.Add(ResolveInstruction(methodDef, body, i, resolver)); } }