解离出Runner
This commit is contained in:
26
DoRunner/BackpointRunner.cs
Normal file
26
DoRunner/BackpointRunner.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user