Files
RScript/DoRunner/BackpointRunner.cs
2025-10-16 15:20:53 +08:00

27 lines
863 B
C#

using Convention.RScript.Parser;
using System.Diagnostics.CodeAnalysis;
namespace Convention.RScript.Runner
{
public class BackpointRunner : JumpRuntimePointerRunner
{
[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;
}
}
}