/// <summary> /// Checks whether <paramref name="localSig"/> contains a <see cref="GenericVar"/> or a /// <see cref="GenericMVar"/>. /// </summary> /// <param name="localSig">Local signature</param> /// <returns><c>true</c> if <paramref name="localSig"/> contains a <see cref="GenericVar"/> /// or a <see cref="GenericMVar"/>.</returns> public static bool ContainsGenericParameter(LocalSig localSig) => new TypeHelper().ContainsGenericParameterInternal(localSig);
public void Write() { uint codeSize = InitializeInstructionOffsets(); jitBody.MaxStack = keepMaxStack ? body.MaxStack : GetMaxStack(); jitBody.Options = 0; if (body.InitLocals) { jitBody.Options |= 0x10; } if (body.Variables.Count > 0) { var local = new LocalSig(body.Variables.Select(var => var.Type).ToList()); jitBody.LocalVars = SignatureWriter.Write(metadata, local); } else { jitBody.LocalVars = new byte[0]; } using (var ms = new MemoryStream()) { uint _codeSize = WriteInstructions(new BinaryWriter(ms)); Debug.Assert(codeSize == _codeSize); jitBody.ILCode = ms.ToArray(); } jitBody.EHs = new JITEHClause[exceptionHandlers.Count]; if (exceptionHandlers.Count > 0) { jitBody.Options |= 8; for (int i = 0; i < exceptionHandlers.Count; i++) { ExceptionHandler eh = exceptionHandlers[i]; jitBody.EHs[i].Flags = (uint)eh.HandlerType; uint tryStart = GetOffset(eh.TryStart); uint tryEnd = GetOffset(eh.TryEnd); jitBody.EHs[i].TryOffset = tryStart; jitBody.EHs[i].TryLength = tryEnd - tryStart; uint handlerStart = GetOffset(eh.HandlerStart); uint handlerEnd = GetOffset(eh.HandlerEnd); jitBody.EHs[i].HandlerOffset = handlerStart; jitBody.EHs[i].HandlerLength = handlerEnd - handlerStart; if (eh.HandlerType == ExceptionHandlerType.Catch) { uint token = metadata.GetToken(eh.CatchType).Raw; if ((token & 0xff000000) == 0x1b000000) { jitBody.Options |= 0x80; } jitBody.EHs[i].ClassTokenOrFilterOffset = token; } else if (eh.HandlerType == ExceptionHandlerType.Filter) { jitBody.EHs[i].ClassTokenOrFilterOffset = GetOffset(eh.FilterStart); } } } }
void Write(LocalSig sig) { if (sig == null) { helper.Error("sig is null"); return; } if (!recursionCounter.Increment()) { helper.Error("Infinite recursion"); return; } writer.Write((byte)sig.GetCallingConvention()); uint count = WriteCompressedUInt32((uint)sig.Locals.Count); for (uint i = 0; i < count; i++) Write(sig.Locals[(int)i]); recursionCounter.Decrement(); }