internal VerifiableTracker Concat(VerifiableTracker other) { var branchTo = BranchesAtTransitions.ContainsKey(other.BeganAt) ? BranchesAtTransitions[other.BeganAt] : Transitions.Count; var shouldTake = branchTo != Transitions.Count; var trans = new LinqList <InstructionAndTransitions>(branchTo + other.Transitions.Count); if (shouldTake) { for (var i = 0; i < branchTo; i++) { trans.Add(Transitions[i]); } } else { trans.AddRange(Transitions); } trans.AddRange(other.Transitions); var canReuseCache = branchTo == Transitions.Count && IsBaseless && CachedVerifyStack != null; var ret = new VerifiableTracker(BeganAt, IsBaseless) { StartingStack = new LinqStack <LinqList <TypeOnStack> >(StartingStack.Reverse().AsEnumerable()), Transitions = trans, CachedVerifyStack = canReuseCache ? new LinqStack <LinqList <TypeOnStack> >(CachedVerifyStack.Reverse().AsEnumerable()) : null, CachedVerifyIndex = canReuseCache ? CachedVerifyIndex : null }; return(ret); }
public void EmitCall(OpCode op, MethodInfo method, IEnumerable <Type> parameterTypes, Type[] arglist) { InstructionSizes.Add(() => InstructionSize.Get(op)); LengthCache.Clear(); Buffer.Add( (il, logOnly, log) => { if (!logOnly) { il.EmitCall(op, method, arglist); } var mtdString = method is MethodBuilder ? method.Name : method.ToString(); log.AppendLine(op + " " + mtdString + " __arglist(" + Join(", ", arglist) + ")"); } ); var parameters = new LinqList <Type>(parameterTypes); if (!method.IsStatic) { var declaring = method.DeclaringType; if (TypeHelpers.IsValueType(declaring)) { declaring = declaring.MakePointerType(); } parameters.Insert(0, declaring); } parameters.AddRange(arglist); var paras = new List <object> { method }; paras.AddRange(arglist); TraversableBuffer.Add(new BufferedILInstruction { IsInstruction = op, MethodReturnType = method.ReturnType, MethodParameterTypes = parameters }); Operations.Add(new Operation <DelegateType> { OpCode = op, Parameters = paras.ToArray() }); }
public void EmitCalli(CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] arglist) { InstructionSizes.Add(() => InstructionSize.Get(OpCodes.Calli)); LengthCache.Clear(); Buffer.Add( (il, logOnly, log) => { if (!logOnly) { il.EmitCalli(OpCodes.Calli, callingConvention, returnType, parameterTypes, arglist); } log.AppendLine(OpCodes.Calli + " " + callingConvention + " " + returnType + " " + Join(" ", (IEnumerable <Type>)parameterTypes) + " __arglist(" + Join(", ", arglist) + ")"); } ); var ps = new LinqList <Type>(parameterTypes); ps.AddRange(arglist); TraversableBuffer.Add(new BufferedILInstruction { IsInstruction = OpCodes.Calli, MethodReturnType = returnType, MethodParameterTypes = ps }); var paras = new List <object>() { callingConvention, returnType }; paras.AddRange(parameterTypes); paras.AddRange(arglist); Operations.Add(new Operation <DelegateType> { OpCode = OpCodes.Calli, Parameters = paras.ToArray() }); }