/// <summary> /// Pops the operands of an instruction From the evaluation stack. /// </summary> /// <param name="ctx">The context.</param> /// <returns>The number of operands popped.</returns> private int PopOperands(Context ctx) { for (int i = ctx.OperandCount - 1; i > -1; i--) { Operand op = ctx.GetOperand (i); Operand evalOp = evaluationStack.Pop (); Debug.Assert (ReferenceEquals (evalOp, op), "Operand's are not equal?"); } return ctx.OperandCount; }
/// <summary> /// Assigns the operands from CIL stack. /// </summary> /// <param name="ctx">The context.</param> /// <param name="currentStack">The current stack.</param> private void AssignOperandsFromCILStack(Context ctx, Stack<Operand> currentStack) { for (int index = ctx.OperandCount - 1; index >= 0; --index) { if (ctx.GetOperand(index) != null) continue; ctx.SetOperand(index, currentStack.Pop()); } }
/// <summary> /// Assigns the operands from CIL stack. /// </summary> /// <param name="ctx">The context.</param> /// <param name="currentStack">The current stack.</param> private static void AssignOperandsFromCILStack(Context ctx, IList<Operand> currentStack) { for (int index = ctx.OperandCount - 1; index >= 0; --index) { if (ctx.GetOperand (index) == null) { Operand operand = currentStack[currentStack.Count - 1]; currentStack.RemoveAt (currentStack.Count - 1); ctx.SetOperand (index, operand); } } }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <param name="context">The context.</param> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public virtual string ToString(Context context) { string s = ToString(); if (context.Other is IR.ConditionCode) s = s + " [" + GetConditionString(context.ConditionCode) + "]"; string mod = GetModifier(context); if (mod != null) s = s + " [" + mod + "]"; if (context.ResultCount == 1) s = s + " " + context.Result; else if (context.ResultCount == 2) s = s + " " + context.Result + ", " + context.Result2; if (context.ResultCount > 0 && context.OperandCount > 0) s = s + " <-"; for (int i = 0; (i < 3) && (i < context.OperandCount); i++) s = s + " " + context.GetOperand(i) + ","; if (context.OperandCount > 3) s = s + " [more]"; else s = s.TrimEnd(','); if (context.Branch != null) { for (int i = 0; (i < 2) && (i < context.Branch.Targets.Length); i++) s = s + String.Format(@" L_{0:X4},", context.Branch.Targets[i]); if (context.Branch.Targets.Length > 2) s = s + " [more]"; else s = s.TrimEnd(','); } if (context.InvokeTarget != null) s = s + " " + context.InvokeTarget.ToString(); if (context.RuntimeField != null) s = s + " " + context.RuntimeField.ToString(); return s; }
/// <summary> /// Visitation function for <see cref="ICILVisitor.Calli"/>. /// </summary> /// <param name="ctx">The context.</param> void ICILVisitor.Calli(Context ctx) { Operand destinationOperand = ctx.GetOperand(ctx.OperandCount - 1); ctx.OperandCount -= 1; this.ProcessInvokeInstruction(ctx, destinationOperand, ctx.Result, new List<Operand>(ctx.Operands)); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <param name="context">The context.</param> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public virtual string ToString(Context context) { string s = ToString(); if (context.Other is IR.ConditionCode) { s = s + " [" + GetConditionString(context.ConditionCode) + "]"; } string mod = GetModifier(context); if (mod != null) { s = s + " [" + mod + "]"; } if (context.ResultCount == 1) { s = s + " " + context.Result; } else if (context.ResultCount == 2) { s = s + " " + context.Result + ", " + context.Result2; } if (context.ResultCount > 0 && context.OperandCount > 0) { s = s + " <-"; } for (int i = 0; (i < 3) && (i < context.OperandCount); i++) { s = s + " " + context.GetOperand(i) + ","; } if (context.OperandCount > 3) { s = s + " [more]"; } else { s = s.TrimEnd(','); } if (context.Branch != null) { for (int i = 0; (i < 2) && (i < context.Branch.Targets.Length); i++) { s = s + String.Format(@" L_{0:X4},", context.Branch.Targets[i]); } if (context.Branch.Targets.Length > 2) { s = s + " [more]"; } else { s = s.TrimEnd(','); } } if (context.InvokeTarget != null) { s = s + " {" + context.InvokeTarget.ToString() + "}"; } if (context.RuntimeField != null) { s = s + " {" + context.RuntimeField.ToString() + "}"; } return(s); }
/// <summary> /// Visitation function for Calli instruction. /// </summary> /// <param name="context">The context.</param> void CIL.ICILVisitor.Calli(Context context) { Operand destinationOperand = context.GetOperand(context.OperandCount - 1); context.OperandCount -= 1; ProcessInvokeInstruction(context, destinationOperand, context.Result, new List<Operand>(context.Operands)); }