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); }
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; }
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); }
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; }
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); }
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; }
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; }
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; }
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); }
public override BoolType Or(TypeBase right) { if (right.GetTypeStr() != "bool") return new BoolType(false); return new BoolType( val || (right as BoolType).val); }