40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
namespace tlang
|
|
{
|
|
internal class BitwiseOrNode : Node
|
|
{
|
|
public Node Left {get;set;}
|
|
public Node Right {get;set;}
|
|
|
|
public BitwiseOrNode(Node left, Node right)
|
|
{
|
|
this.Left = left;
|
|
this.Right = right;
|
|
}
|
|
|
|
public override TObject Execute(IScopeEnvironment nodeEnv)
|
|
{
|
|
var l = Left.Execute(nodeEnv);
|
|
var r = Right.Execute(nodeEnv);
|
|
var lnum = l as TNumber;
|
|
var rnum = r as TNumber;
|
|
var dleft = l as TDictionary;
|
|
|
|
if(dleft != null)
|
|
{
|
|
if(dleft.MemberExists("bor"))
|
|
{
|
|
var mbm = dleft["bor"] as ICallable;
|
|
if(mbm != null)
|
|
{
|
|
return mbm.Call(r);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(lnum != null && rnum != null)
|
|
return TObject.Number((long)lnum.Value | (long)rnum.Value);
|
|
|
|
return TObject.Null;
|
|
}
|
|
}
|
|
} |