tlang-interperter-cs/GetVariableValue.cs

34 lines
759 B
C#
Raw Normal View History

2023-03-09 19:40:14 +00:00
namespace tlang
{
internal class SetVariableNode : Node
{
public Node Value {get;set;}
public string Name {get;set;}
public SetVariableNode(string text,Node v)
{
Name=text;
Value=v;
}
public override TObject Execute(IScopeEnvironment nodeEnv)
{
var res=Value.Execute(nodeEnv);
nodeEnv[Name]=res;
return res;
}
}
public class GetVariableValue : Node
{
public string Name {get;set;}
public GetVariableValue(string text)
{
this.Name = text;
}
public override TObject Execute(IScopeEnvironment nodeEnv)
{
return nodeEnv[Name];
}
}
}