解离出Runner
This commit is contained in:
23
DoRunner/EnterNamespaceRunner.cs
Normal file
23
DoRunner/EnterNamespaceRunner.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user