解离出Runner
This commit is contained in:
32
DoRunner/BreakpointRunner.cs
Normal file
32
DoRunner/BreakpointRunner.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Convention.RScript.Parser;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Convention.RScript
|
||||
{
|
||||
public class BreakpointRunner : IRSentenceRunner
|
||||
{
|
||||
[return: MaybeNull]
|
||||
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
// 检查并跳转到当前命名空间的结束位置
|
||||
if (parser.Evaluate<bool>(sentence.content))
|
||||
{
|
||||
if (context.RuntimePointerStack.Count == 0)
|
||||
{
|
||||
context.CurrentRuntimePointer = context.Sentences.Length;
|
||||
}
|
||||
else if (context.NamespaceLayer.TryGetValue(context.RuntimePointerStack.Peek(), out var exitPointer))
|
||||
{
|
||||
context.CurrentRuntimePointer = exitPointer;
|
||||
//DoExitNamespace(parser);
|
||||
context.SentenceRunners[RScriptSentence.Mode.ExitNamespace].Run(parser, context.CurrentSentence, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RScriptRuntimeException($"No namespace to break.", context.CurrentRuntimePointer);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user