Exemplo n.º 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.IsNumberType(ltype) && Calculater.IsNumberType(rtype))
     {
         return("Float");
     }
     return("Ref");
 }
Exemplo n.º 2
0
 public static CalculaterMethodTypeEnum GetCalculaterMethodType(TokenKindSymbol opKind, Type ltype, Type rtype)
 {
     if (ltype == typeof(string) || rtype == typeof(string))
     {
         if (opKind == TokenKindSymbol.ADD)
         {
             return(CalculaterMethodTypeEnum.ContactString);
         }
     }
     if (opKind == TokenKindSymbol.ADD || opKind == TokenKindSymbol.SUB || opKind == TokenKindSymbol.MUL)
     {
         return(CalculaterMethodTypeEnum.MathOp);
     }
     if (opKind == TokenKindSymbol.DIV)
     {
         return(CalculaterMethodTypeEnum.MathDiv);
     }
     if (opKind == TokenKindSymbol.GT || opKind == TokenKindSymbol.GE || opKind == TokenKindSymbol.LT || opKind == TokenKindSymbol.LE)
     {
         return(CalculaterMethodTypeEnum.MathCompare);
     }
     if (opKind == TokenKindSymbol.AND || opKind == TokenKindSymbol.OR)
     {
         return(CalculaterMethodTypeEnum.Logic);
     }
     if (opKind == TokenKindSymbol.EQ || opKind == TokenKindSymbol.NE)
     {
         if (Calculater.IsNumberType(ltype) && Calculater.IsNumberType(rtype))
         {
             return(CalculaterMethodTypeEnum.MathCompare);
         }
         else
         {
             return(CalculaterMethodTypeEnum.RefCompare);
         }
     }
     return(CalculaterMethodTypeEnum.None);
 }