Beispiel #1
0
 public override BoolType Smaller(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType != "string")
         return new BoolType(false);
     return new BoolType(this.strval.CompareTo(right.strval) < 0);
 }
Beispiel #2
0
 public override TypeBase Add(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType == "char")
         return new StringType(this.strval + right.cval.ToString());
     else if (rightType == "string")
         return new StringType(this.strval + right.strval);
     else
         return null;
 }
Beispiel #3
0
 public override BoolType Equal(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType != "string")
         return new BoolType(false);
     return new BoolType(this.strval == right.strval);
 }
Beispiel #4
0
 public override TypeBase Power(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType == "int")
         return new IntType((int)Math.Pow((double)this.ival, (double)right.ival));
     else if (rightType == "double")
         return new DoubleType(Math.Pow((double)this.dval, (double)right.dval));
     else
         return null;
 }
Beispiel #5
0
 public override BoolType Smaller(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType != "int")
         return new BoolType(false);
     return new BoolType(this.ival < right.ival);
 }
Beispiel #6
0
 public override TypeBase Percent(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType == "int")
         return new IntType(this.ival % right.ival);
     else
         return null;
 }
Beispiel #7
0
 public override TypeBase Multi(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType == "int")
         return new IntType(this.ival * right.ival);
     else if (rightType == "double")
         return new DoubleType((double)this.ival * right.dval);
     else
         return null;
 }
Beispiel #8
0
 public override TypeBase Minus(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType == "int")
         return new DoubleType(this.dval - (double)right.ival);
     else if (rightType == "double")
         return new DoubleType(this.dval - right.dval);
     else
         return null;
 }
Beispiel #9
0
 public override BoolType Larger(TypeBase right)
 {
     if (right == null)
         return null;
     var rightType = right.GetTypeStr();
     if (rightType != "double")
         return new BoolType(false);
     return new BoolType(this.dval > right.dval);
 }
Beispiel #10
0
 public override BoolType Or(TypeBase right)
 {
     if (right.GetTypeStr() != "bool")
         return new BoolType(false);
     return new BoolType( val || (right as BoolType).val);
 }