tlang-interperter-cs/tlanglib/Not.cs

37 lines
777 B
C#
Raw Permalink Normal View History

2023-06-08 18:14:35 +00:00
namespace tlang
{
public class NotNode : Node
{
public Node Node {get;set;}
public NotNode(Node node)
{
this.Node = node;
}
public override TObject Execute(IScopeEnvironment nodeEnv)
{
var l = Node.Execute(nodeEnv);
var dleft = l as TDictionary;
if(dleft != null)
{
if(dleft.MemberExists("not"))
{
var mbm = dleft["not"] as ICallable;
if(mbm != null)
{
return mbm.Call();
}
}
}
return TObject.Boolean(!l.AsBoolean);
}
}
}