public static void Init() { DynamicMethodWrapper.Init(); DynamicILGenerator.Init(); DynamicILInfoWrapper.Init(); DynamicScope.Init(); DynamicResolver.Init(); }
public void WriteToDynamicMethod(DynamicMethod dynamicMethod, int?maxStack) { Seal(); MaxStack = maxStack ?? new MaxStackSizeCalculator(this, ResolveToken).ComputeMaxStack(); var dynamicILInfo = new DynamicMethodWrapper(dynamicMethod).GetDynamicILInfoWithOldScope(); var wrapper = new DynamicILInfoWrapper(dynamicILInfo); var code = new ILCodeBaker(Instructions, wrapper.GetTokenFor).BakeILCode(); dynamicILInfo.SetCode(code, MaxStack); dynamicILInfo.SetLocalSignature(GetLocalSignature()); if (HasExceptionHandlers) { dynamicILInfo.SetExceptions(new ExceptionsBaker(ExceptionHandlers, Instructions, wrapper.GetTokenFor).BakeExceptions()); } }
public MethodBodyOnDynamicILInfo(DynamicMethod dynamicMethod, GrEmit.Utils.DynamicILInfo dynamicILInfo, bool resolveTokens) : base(GetMethodSignature(dynamicILInfo), resolveTokens) { scope = new DynamicILInfoWrapper(dynamicILInfo).m_scope; using (var dynamicResolver = new DynamicResolver(dynamicMethod, dynamicILInfo)) { int stackSize; int initLocals; int EHCount; var code = dynamicResolver.GetCodeInfo(out stackSize, out initLocals, out EHCount); MaxStack = stackSize; InitLocals = initLocals != 0; SetLocalSignature(dynamicResolver.m_localSignature); ILCodeReader.Read(code, ResolveToken, resolveTokens, this); ExceptionsInfoReader.Read(dynamicResolver.GetRawEHInfo(), ResolveToken, resolveTokens, this); } }
private static byte[] GetMethodSignature(GrEmit.Utils.DynamicILInfo dynamicILInfo) { var wrapper = new DynamicILInfoWrapper(dynamicILInfo); return((byte[])wrapper.m_scope[wrapper.m_methodSignature]); }