2023-03-09 19:40:14 +00:00
|
|
|
namespace tlang
|
|
|
|
{
|
|
|
|
internal class SetVariableNode : Node
|
|
|
|
{
|
|
|
|
public Node Value {get;set;}
|
2023-03-09 23:57:16 +00:00
|
|
|
public GetVariableValue Name {get;set;}
|
|
|
|
public SetVariableNode(GetVariableValue gvn,Node v)
|
2023-03-09 19:40:14 +00:00
|
|
|
{
|
2023-03-09 23:57:16 +00:00
|
|
|
Name=gvn;
|
2023-03-09 19:40:14 +00:00
|
|
|
Value=v;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override TObject Execute(IScopeEnvironment nodeEnv)
|
|
|
|
{
|
|
|
|
var res=Value.Execute(nodeEnv);
|
2023-03-09 23:57:16 +00:00
|
|
|
Name.SetValue(nodeEnv,res);
|
2023-03-09 19:40:14 +00:00
|
|
|
return res;
|
|
|
|
}
|
2023-06-08 18:14:35 +00:00
|
|
|
|
2023-03-09 23:57:16 +00:00
|
|
|
|
2023-03-09 19:40:14 +00:00
|
|
|
}
|
|
|
|
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];
|
|
|
|
}
|
2023-03-09 23:57:16 +00:00
|
|
|
public virtual void SetValue(IScopeEnvironment nodeEnv,TObject value)
|
|
|
|
{
|
|
|
|
nodeEnv[Name] = value;
|
|
|
|
}
|
2023-06-08 18:14:35 +00:00
|
|
|
|
|
|
|
|
2023-03-09 19:40:14 +00:00
|
|
|
}
|
|
|
|
}
|