tlang-interperter-cs/tlanglib/LogicalAndNode.cs

31 lines
772 B
C#
Raw Normal View History

2023-03-10 10:12:51 +00:00
namespace tlang
{
internal class LogicalAndNode : Node
{
public Node Left {get;set;}
public Node Right {get;set;}
public LogicalAndNode(Node left, Node right)
{
Left = left;
Right = right;
}
public override TObject Execute(IScopeEnvironment nodeEnv)
{
var l = Left.Execute(nodeEnv);
var r = Right.Execute(nodeEnv);
var ldict = l as TDictionary;
if(ldict != null)
{
var lor=ldict["land"] as ICallable;
if(lor != null)
{
return lor.Call(r);
}
}
2023-06-08 18:14:35 +00:00
return TObject.Boolean(l.AsBoolean && r.AsBoolean);
2023-03-10 10:12:51 +00:00
}
}
}