37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Convention.RScript.Parser;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Convention.RScript
|
|
{
|
|
public class BreakpointRunner : IRSentenceRunner
|
|
{
|
|
public void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
|
{
|
|
parser.Compile<bool>(sentence.content);
|
|
}
|
|
|
|
[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;
|
|
context.SentenceRunners[RScriptSentence.Mode.ExitNamespace].Run(parser, context.CurrentSentence, context);
|
|
}
|
|
else
|
|
{
|
|
throw new RScriptRuntimeException($"No namespace to break.", context.CurrentRuntimePointer);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|