37 lines
867 B
C#
37 lines
867 B
C#
namespace tlang
|
|
{
|
|
public class BitwiseNot : Node
|
|
{
|
|
public Node Node {get;set;}
|
|
|
|
public BitwiseNot(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("bnot"))
|
|
{
|
|
var mbm = dleft["bnot"] as ICallable;
|
|
if(mbm != null)
|
|
{
|
|
return mbm.Call();
|
|
}
|
|
}
|
|
}
|
|
|
|
if(lnum != null)
|
|
return TObject.Number(~(long)lnum.Value);
|
|
return TObject.Null;
|
|
}
|
|
}
|
|
} |