本文整理汇总了C#中ExecutionContext.EnsureStack方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext.EnsureStack方法的具体用法?C# ExecutionContext.EnsureStack怎么用?C# ExecutionContext.EnsureStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.EnsureStack方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleGreaterThan
private static void HandleGreaterThan(ExecutionContext context)
{
context.EnsureStack(2);
var a = context.Values.Pop();
var b = context.Values.Pop();
context.Values.Push(b > a ? 1 : 0);
}
示例2: HandleSwap
private static void HandleSwap(ExecutionContext context)
{
context.EnsureStack(2);
var a = context.Values.Pop();
var b = context.Values.Pop();
context.Values.Push(a);
context.Values.Push(b);
}
示例3: OnHandle
internal override void OnHandle(ExecutionContext context)
{
context.EnsureStack(1);
switch (context.Current.Value)
{
case TurnInstructionHandler.LeftRightInstruction:
context.Direction = context.Values.Pop() == 0 ? Direction.Right : Direction.Left;
break;
case TurnInstructionHandler.UpDownInstruction:
context.Direction = context.Values.Pop() == 0 ? Direction.Down : Direction.Up;
break;
}
}
示例4: HandleGet
private static void HandleGet(ExecutionContext context)
{
context.EnsureStack(2);
var y = context.Values.Pop();
var x = context.Values.Pop();
var target = context.Find(new Point(x, y));
if (target != null)
{
context.Values.Push(target.Value);
}
else
{
context.Values.Push(' ');
}
}
示例5: OnHandle
internal override void OnHandle(ExecutionContext context)
{
context.EnsureStack(1);
switch (context.Current.Value)
{
case OutputInstructionHandler.AsciiInstruction:
context.Writer.Write(Convert.ToChar(
context.Values.Pop()));
break;
case OutputInstructionHandler.NumericInstruction:
context.Writer.Write(
context.Values.Pop().ToString(CultureInfo.CurrentCulture));
break;
}
}
示例6: HandlePut
private static void HandlePut(ExecutionContext context)
{
context.EnsureStack(3);
var y = context.Values.Pop();
var x = context.Values.Pop();
var value = Convert.ToChar(context.Values.Pop());
var location = new Point(x, y);
var target = context.Find(location);
if (target != null)
{
context.Cells[context.Cells.IndexOf(target)] = new Cell(location, value);
}
else if (value != ' ')
{
context.Cells.Add(new Cell(location, value));
}
}
示例7: OnHandle
internal override void OnHandle(ExecutionContext context)
{
context.EnsureStack(2);
switch (context.Current.Value)
{
case MathInstructionHandler.AddInstruction:
MathInstructionHandler.HandleAddition(context);
break;
case MathInstructionHandler.SubtractInstruction:
MathInstructionHandler.HandleSubtraction(context);
break;
case MathInstructionHandler.MultiplyInstruction:
MathInstructionHandler.HandleMultiplication(context);
break;
case MathInstructionHandler.DivideInstruction:
MathInstructionHandler.HandleDivision(context);
break;
case MathInstructionHandler.ModInstruction:
MathInstructionHandler.HandleModulo(context);
break;
}
}
示例8: HandleDuplicate
private static void HandleDuplicate(ExecutionContext context)
{
context.EnsureStack(1);
context.Values.Push(context.Values.Peek());
}
示例9: HandleNot
private static void HandleNot(ExecutionContext context)
{
context.EnsureStack(1);
context.Values.Push(context.Values.Pop() == 0 ? 1 : 0);
}