/// <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) { return(new TypeHelper().ContainsGenericParameterInternal(localSig)); }
/// <summary> /// Constructor /// </summary> /// <param name="localSig">A locals sig</param> public StandAloneSigUser(LocalSig localSig) { this.signature = localSig; }
bool ContainsGenericParameterInternal(LocalSig ls) { if (ls == null) return false; if (!recursionCounter.Increment()) return false; bool res = ContainsGenericParameter(ls.Locals); recursionCounter.Decrement(); return res; }
void Add(LocalSig sig) { if (sig == null) return; Add(sig.Locals); }
/// <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) { return 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); } } } }
/// <summary> /// Gets the locals /// </summary> /// <param name="sig">this</param> /// <returns>All locals</returns> public static IList <TypeSig> GetLocals(this LocalSig sig) { return(sig == null?ThreadSafeListCreator.Create <TypeSig>() : sig.Locals); }
/// <summary> /// Gets the locals /// </summary> /// <param name="sig">this</param> /// <returns>All locals</returns> public static IList <TypeSig> GetLocals(this LocalSig sig) { return(sig == null ? new List <TypeSig>() : sig.Locals); }