本文整理汇总了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));
}
}
}
}
示例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));
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}