Example #1
0
 public static string GetTypeName(Type ltype, Type rtype)
 {
     if (ltype == typeof(bool) && rtype == typeof(bool))
     {
         return("Bool");
     }
     if (ltype == typeof(int) && rtype == typeof(int))
     {
         return("Int");
     }
     if (Calculater.IsNumber(ltype) && Calculater.IsNumber(rtype))
     {
         return("Float");
     }
     return("Ref");
 }
Example #2
0
 public static CalculaterMethodTypeEnum GetCalculaterMethodType(TokenKind opKind, Type ltype, Type rtype)
 {
     //Type calcType = typeof(Calculater);
     if (ltype == typeof(string) || rtype == typeof(string))
     {
         if (opKind == TokenKind.ADD)
         {
             return(CalculaterMethodTypeEnum.ContactString);
         }
     }
     if (opKind == TokenKind.ADD || opKind == TokenKind.SUB || opKind == TokenKind.MUL)
     {
         return(CalculaterMethodTypeEnum.MathOp);
     }
     if (opKind == TokenKind.DIV)
     {
         return(CalculaterMethodTypeEnum.MathDiv);
     }
     if (opKind == TokenKind.GT || opKind == TokenKind.GE || opKind == TokenKind.LT || opKind == TokenKind.LE)
     {
         return(CalculaterMethodTypeEnum.MathCompare);
     }
     if (opKind == TokenKind.AND || opKind == TokenKind.OR)
     {
         return(CalculaterMethodTypeEnum.Logic);
     }
     if (opKind == TokenKind.EQ || opKind == TokenKind.NE)
     {
         if (Calculater.IsNumber(ltype) && Calculater.IsNumber(rtype))
         {
             return(CalculaterMethodTypeEnum.MathCompare);
         }
         else
         {
             return(CalculaterMethodTypeEnum.RefCompare);
         }
     }
     return(CalculaterMethodTypeEnum.None);
 }