tlang-interperter-cs/tlanglib/FunctionCallNode.cs

28 lines
667 B
C#
Raw Normal View History

2023-03-10 10:12:36 +00:00
using System.Collections.Generic;
using System.Linq;
2023-03-09 19:40:14 +00:00
namespace tlang
{
internal class FunctionCallNode : Node
{
public string Text {get;set;}
public List<Node> Args {get;set;}
public FunctionCallNode(string text, List<Node> args)
{
this.Text = text;
this.Args = args;
}
public override TObject Execute(IScopeEnvironment nodeEnv)
{
var n = nodeEnv[Text] as ICallable;
if(n != null)
{
return n.Call(Args.Select<Node,TObject>(e=>e.Execute(nodeEnv)).ToArray());
}
return new TUninit();
}
}
}