解离出Runner

This commit is contained in:
2025-10-16 15:20:53 +08:00
parent e2ab2a1077
commit 15bdb6f8db
9 changed files with 301 additions and 237 deletions

View File

@@ -0,0 +1,23 @@
using Convention.RScript.Parser;
using System.Diagnostics.CodeAnalysis;
namespace Convention.RScript.Runner
{
public class EnterNamespaceRunner : IRSentenceRunner
{
[return: MaybeNull]
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
{
// 准备记录当前命名空间中定义的变量, 清空上层命名空间的变量
context.CurrentLocalSpaceVariableNames.Push(new());
// 更新变量值
foreach (var (varName, varValue) in parser.context.Variables)
{
context.Variables.SetValue(varName, varValue);
}
// 压栈
context.RuntimePointerStack.Push(context.CurrentRuntimePointer);
return null;
}
}
}