32 lines
997 B
C#
32 lines
997 B
C#
using Convention.RScript.Parser;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Convention.RScript.Runner
|
|
{
|
|
public class BackpointRunner : JumpRuntimePointerRunner
|
|
{
|
|
public override void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
|
{
|
|
|
|
}
|
|
|
|
[return: MaybeNull]
|
|
public override object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
|
{
|
|
// 检查并跳转到上次跳转的位置
|
|
if (parser.Evaluate<bool>(sentence.content))
|
|
{
|
|
if (context.GotoPointerStack.Count == 0)
|
|
{
|
|
throw new RScriptRuntimeException($"No position to back.", context.CurrentRuntimePointer);
|
|
}
|
|
else
|
|
{
|
|
DoJumpRuntimePointer(parser, context.GotoPointerStack.Pop(), context);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|