24 lines
817 B
C#
24 lines
817 B
C#
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;
|
|
}
|
|
}
|
|
}
|