当前位置: 首页>>代码示例>>C#>>正文


C# ICpu.PopValueEncapsulated方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:CalebJ2,项目名称:KOS,代码行数:45,代码来源:Opcode.cs


注:本文中的ICpu.PopValueEncapsulated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。