38 lines
861 B
C#
38 lines
861 B
C#
namespace tlang
|
|
{
|
|
public class NegativeNode : Node
|
|
{
|
|
public Node Node {get;set;}
|
|
|
|
public NegativeNode(Node node)
|
|
{
|
|
this.Node = node;
|
|
}
|
|
|
|
public override TObject Execute(IScopeEnvironment nodeEnv)
|
|
{
|
|
var l = Node.Execute(nodeEnv);
|
|
|
|
var lnum = l as TNumber;
|
|
|
|
var dleft = l as TDictionary;
|
|
|
|
if(dleft != null)
|
|
{
|
|
if(dleft.MemberExists("neg"))
|
|
{
|
|
var mbm = dleft["neg"] as ICallable;
|
|
if(mbm != null)
|
|
{
|
|
return mbm.Call();
|
|
}
|
|
}
|
|
}
|
|
|
|
if(lnum != null)
|
|
return TObject.Number(-lnum.Value);
|
|
|
|
return TObject.Null;
|
|
}
|
|
}
|
|
} |