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


C# Interpreter.PushState方法代码示例

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


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

示例1: TagBlueprint

        public TagBlueprint(Interpreter interpreter, Source source, Stringe name, IEnumerable<Token<TokenType>>[] args = null)
            : base(interpreter)
        {
            Source = source;
            Name = name;

            if (!Interpreter.TagFuncs.TryGetValue(Name.Value.ToLower().Trim(), out _tagDef))
            {
                throw new ManhoodException(Source, Name, "The tag '" + Name.Value + "' does not exist.");
            }

            _tagDef.ValidateArgCount(source, name, args != null ? args.Length : 0);

            if (args == null)
            {
                _args = Enumerable.Empty<TagArg>().ToArray();
            }
            else
            {
                // Insert token arguments into the array, set string args to null.
                _args = args.Select((a, i) => _tagDef.ArgTypes[i] == TagArgType.Tokens ? TagArg.FromTokens(a) : null).ToArray();

                // Queue string arguments on the stack.
                for (int i = 0; i < _tagDef.ArgTypes.Length; i++)
                {
                    if (_tagDef.ArgTypes[i] == TagArgType.Result)
                    {
                        interpreter.PushState(Interpreter.State.CreateDerivedDistinct(source, args[i], interpreter));
                    }
                }
            }
        }
开发者ID:dandrews,项目名称:Manhood,代码行数:32,代码来源:TagBlueprint.cs

示例2: SubCallBlueprint

        public SubCallBlueprint(Interpreter interpreter, Source source, Subroutine subroutine, IEnumerable<Token<TokenType>>[] args) : base(interpreter)
        {
            _subroutine = subroutine;
            if (args == null)
            {
                _args = Enumerable.Empty<TagArg>().ToArray();
            }
            else
            {
                // Insert token arguments into the array, set string args to null.
                _args = args.Select((a, i) => _subroutine.Parameters[i].Item2 == TagArgType.Tokens ? TagArg.FromTokens(a) : null).ToArray();

                // Queue string arguments on the stack.
                for (int i = 0; i < _subroutine.ParamCount; i++)
                {
                    if (_subroutine.Parameters[i].Item2 == TagArgType.Result)
                    {
                        interpreter.PushState(Interpreter.State.CreateDerivedDistinct(source, args[i], interpreter));
                    }
                }
            }
        }
开发者ID:dandrews,项目名称:Manhood,代码行数:22,代码来源:SubCallBlueprint.cs

示例3: First

 private static bool First(Interpreter interpreter, Source source, Stringe tagname, TagArg[] args)
 {
     if (interpreter.CurrentRepeater == null || !interpreter.CurrentRepeater.IsFirst) return false;
     interpreter.PushState(State.CreateDerivedDistinct(source, args[0].GetTokens(), interpreter, interpreter.CurrentState.Output));
     return true;
 }
开发者ID:dandrews,项目名称:Manhood,代码行数:6,代码来源:Interpreter.TagFuncs.cs

示例4: Nth

        private static bool Nth(Interpreter interpreter, Source source, Stringe tagname, TagArg[] args)
        {
            int offset, interval;
            if (!Int32.TryParse(args[0].GetString(), out interval))
            {
                throw new ManhoodException(source, tagname, "Invalid interval value.");
            }

            if (interval <= 0)
            {
                throw new ManhoodException(source, tagname, "Interval must be greater than zero.");
            }

            if (!Int32.TryParse(args[1].GetString(), out offset))
            {
                throw new ManhoodException(source, tagname, "Invalid offset value.");
            }

            if (interpreter.CurrentRepeater == null || !interpreter.CurrentRepeater.Nth(offset, interval)) return false;
            interpreter.PushState(State.CreateDerivedDistinct(source, args[2].GetTokens(), interpreter, interpreter.CurrentState.Output));
            return true;
        }
开发者ID:dandrews,项目名称:Manhood,代码行数:22,代码来源:Interpreter.TagFuncs.cs

示例5: Alt

 private static bool Alt(Interpreter interpreter, Source source, Stringe tagname, TagArg[] args)
 {
     var testState = State.CreateDerivedDistinct(source, args[0].GetTokens(), interpreter,
         interpreter.CurrentState.Output);
     testState.AddPostBlueprint(new AltBlueprint(interpreter, testState, args[1].GetTokens()));
     interpreter.PushState(testState);
     return true;
 }
开发者ID:dandrews,项目名称:Manhood,代码行数:8,代码来源:Interpreter.TagFuncs.cs

示例6: Arg

        private static bool Arg(Interpreter interpreter, Source source, Stringe tagname, TagArg[] args)
        {
            if (!interpreter.SubArgStack.Any())
                throw new ManhoodException(source, tagname, "Tried to access arguments outside of a subroutine body.");

            TagArg arg;
            var argName = args[0].GetString().Trim();
            if (!interpreter.SubArgStack.Peek().TryGetValue(argName, out arg))
                throw new ManhoodException(source, tagname, "Could not find argument '" + argName + "'.");

            // Argument is string
            if (arg.Type == TagArgType.Result)
            {
                interpreter.Print(arg.GetString());
                return false;
            }
            
            // Argument is tokens
            interpreter.PushState(State.CreateDerivedShared(source, arg.GetTokens(), interpreter));
            return true;
        }
开发者ID:dandrews,项目名称:Manhood,代码行数:21,代码来源:Interpreter.TagFuncs.cs


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