本文整理汇总了C#中ICpu.PopValueEncapsulated方法的典型用法代码示例。如果您正苦于以下问题:C# ICpu.PopValueEncapsulated方法的具体用法?C# ICpu.PopValueEncapsulated怎么用?C# ICpu.PopValueEncapsulated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICpu
的用法示例。
在下文中一共展示了ICpu.PopValueEncapsulated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override void Execute(ICpu cpu)
{
string suffixName = cpu.PopStack().ToString().ToUpper();
object popValue = cpu.PopValueEncapsulated();
var specialValue = popValue as ISuffixed;
if (specialValue == null)
{
throw new Exception(string.Format("Values of type {0} cannot have suffixes", popValue.GetType()));
}
ISuffixResult result = specialValue.GetSuffix(suffixName);
// If the result is a suffix that is still in need of being invoked and hasn't resolved to a value yet:
if (result != null && !IsMethodCallAttempt && !result.HasValue)
{
// This is what happens when someone tries to call a suffix method as if
// it wasn't a method (i.e. leaving the parentheses off the call). The
// member returned is a delegate that needs to be called to get its actual
// value. Borrowing the same routine that OpcodeCall uses for its method calls:
cpu.PushStack(result);
cpu.PushStack(new KOSArgMarkerType());
OpcodeCall.StaticExecute(cpu, false, "", false); // this will push the return value on the stack for us.
}
else
{
if (result.HasValue)
{
// Push the already calculated value.
cpu.PushStack(result.Value);
}
else
{
// Push the indirect suffix delegate, but don't execute it yet
// because we need to put the upcoming arg list above it on the stack.
// Eventually an <indirect> OpcodeCall will occur further down the program which
// will actually execute this.
cpu.PushStack(result);
}
}
}