Binary operator: Left op Right
상속: Expr
예제 #1
0
파일: ExpAST.cs 프로젝트: chenzuo/blue
 public BinaryExp(Exp left, Exp right, BinaryOp op)
 {
     Debug.Assert(left != null);
     Debug.Assert(right != null);
     
     //m_filerange = FileRange.Merge(left.Location, right.Location);
     
     m_left = left;
     m_right = right;
     m_op = op;
 }
예제 #2
0
파일: ExpAST.cs 프로젝트: chenzuo/blue
 // Return true if our param types let us match a predefined operator.
 // Else return false (which implies that we must match against an 
 // overloaded operator)
 // @todo - combine w/ CalcCLRTypeHelper()
 static public bool MatchesPredefinedOp(BinaryOp op, Type clrLeft, Type clrRight)
 {
     // For arithmetic ops, only predefined if both args are numbers
     if (op == BinaryOp.cAdd || op == BinaryOp.cMul || op == BinaryOp.cSub || 
         op == BinaryOp.cDiv || op == BinaryOp.cMod ||
         op == BinaryOp.cShiftLeft || op == BinaryOp.cShiftRight)
     {
         return IsNumber(clrLeft) && IsNumber(clrRight);                
     }
     
     if (op == BinaryOp.cEqu || op == BinaryOp.cNeq)
     {
         if (IsNumber(clrLeft) && IsNumber(clrRight)) 
             return true;
         if (IsBool(clrLeft) && IsBool(clrRight))
             return true;
         if (IsEnum(clrLeft) && IsEnum(clrRight))
             return true;                
         return false;                
     }
     
     // Bitwise operators work on either bool or integers
     if (op == BinaryOp.cBitwiseAnd || op == BinaryOp.cBitwiseOr || op == BinaryOp.cBitwiseXor)
     {
         if (IsInteger(clrLeft) && IsInteger(clrRight)) 
             return true;
         if (IsBool(clrLeft) && IsBool(clrRight))
             return true;
         if (IsEnum(clrLeft) && IsEnum(clrRight)) // @todo -only if flags attribute specified
             return true;                
         return false;  
     }
             
     // Relational ops only work on ints
     if (op == BinaryOp.cLT || op == BinaryOp.cGT ||
         op == BinaryOp.cLE || op == BinaryOp.cGE)
     {
         if (IsNumber(clrLeft) && IsNumber(clrRight))
             return true;
         if (IsEnum(clrLeft) && IsEnum(clrRight))
             return true;                
     }
     
     // These ops can't be overloaded, so they had better
     // match a default type
     if (op == BinaryOp.cAnd || op == BinaryOp.cOr)
     {
         return true;        
     }
     
     return false;
 }
예제 #3
0
파일: ExpAST.cs 프로젝트: chenzuo/blue
 public static string OpName(BinaryOp op)
 {
     return m_ops[(int) op];
 }