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


C# ICommandContext.PushState方法代码示例

本文整理汇总了C#中ICommandContext.PushState方法的典型用法代码示例。如果您正苦于以下问题:C# ICommandContext.PushState方法的具体用法?C# ICommandContext.PushState怎么用?C# ICommandContext.PushState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICommandContext的用法示例。


在下文中一共展示了ICommandContext.PushState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CallByName

        private void CallByName(ICommandContext context)
        {
            // It has to look up the availabe function names
            Function function = null;
            if (parametersCount >= 0)
            {
                function = context.FunctionLookup.GetFunctionByNameAndParameterCount(functionName, parametersCount);
                if (function == null)
                {
                    throw new PsimulexCoreException(string.Format("Call to an undefined function: {0} with {1} parameters.", functionName, parametersCount));
                }
            }
            else
            {
                function = context.FunctionLookup.GetFunctionByName(functionName);
                if (function == null)
                {
                    throw new PsimulexCoreException("Call to an undefined function: " + functionName);
                }
            }

            if (function.IsUserDefined)
            {
                UserDefinedFunction udf = function as UserDefinedFunction;

                Stack<BaseType> parameters = new Stack<BaseType>();

                foreach (var param in udf.Parameters)
                {
                    var value = context.RunStack.Pop();
                    if (param.IsReference)
                    {
                        value = value.ToReference();
                    }
                    parameters.Push(value.Clone());
                }

                parameters = parameters.Reverse();

                context.PushState();

                foreach (var param in udf.Parameters)
                {
                    context.AddVariable(param.Name, parameters[udf.Parameters.IndexOf(param)]);
                }

                // Just jump to its entry point.
                context.PC = udf.EntryPoint;
            }
            else
            {
                // Pack each parameter, and Invoke.

                Stack<BaseType> poppedValues = new Stack<BaseType>();
                var parameters = new List<BaseType>(function.ParameterCount);
                for (int i = 0; i < function.ParameterCount; ++i)
                {
                    var param = context.RunStack.Pop();
                    if (function.Parameters[i].IsReference)
                    {
                        param = param.ToReference();
                    }
                    poppedValues.Push(param.Clone());
                }

                parameters.AddRange(poppedValues.AsEnumerable());

                // Make the call
                var returnValue = context.System.SystemCall(function, parameters);

                // Push the returned value
                if (function.HasReturnValue)
                {
                    context.RunStack.Push(returnValue);
                }

                foreach (var param in parameters)
                {
                    param.Delete();
                }
            }
        }
开发者ID:hunpody,项目名称:psimulex,代码行数:82,代码来源:Call.cs

示例2: CallByAddress

 private void CallByAddress(ICommandContext context)
 {
     context.PushState();
     context.PC = functionAddress;
 }
开发者ID:hunpody,项目名称:psimulex,代码行数:5,代码来源:Call.cs


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