public override void AddToClosure(string name, TypeBase val) { if (closure.ContainsKey(name)) closure[name] = val; else closure.Add(name, val); }
public ArrayBoundType Append(TypeBase from, TypeBase to) { if (from is IntType) { int lower = (from as IntType).ival; int upper = (to as IntType).ival; for (int index = lower; index <= upper; index++) items.Add(new IntType(index)); } else { char lower = (from as CharType).cval; char upper = (to as CharType).cval; for (char index = lower; index <= upper; index++) items.Add(new CharType(index)); } return this; }
public override TypeBase Add(TypeBase right) { if (right == null) return this; //string thisV = this.FriendlyVal(); //Console.WriteLine("{0} + {1}", this.FriendlyVal(), right.FriendlyVal()); if (right is ArrayType) { ArrayType arr = right as ArrayType; if (current == null) { current = arr.current; next = arr.next; } else if (next == null || next.current == null) next = arr; else { ArrayType tmp = next; while (tmp.next != null && tmp.current != null) tmp = tmp.next; if (tmp.current == null) { tmp.current = arr.current; tmp.next = arr.next; } else { tmp.next = right as ArrayType; } } } else { this.Append(right); } return this; }
public override TypeBase Multi(TypeBase right) { return null; }
public override TypeBase Power(TypeBase right) { return null; }
public virtual TypeBase Devide(TypeBase right) { return null; }
public override BoolType Equal(TypeBase right) { if (!(right is ArrayType)) return new BoolType(false); ArrayType v = right as ArrayType; if ((current == null && v.current != null)|| (current != null && v.current == null) ) return new BoolType(false); if (current == null && v.current == null) return new BoolType(true); if (!current.Equal(v.current).IsTrue()) return new BoolType(false); if ((next == null && v.next != null) || (next != null && v.next == null)) return new BoolType(false); if (next == null && v.next == null) return new BoolType(true); return next.Equal(v.next); }
public virtual BoolType Smaller(TypeBase right) { return new BoolType(false); }
public virtual void AddToClosure(string name, TypeBase val) { }
public virtual TypeBase Multi(TypeBase right) { 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 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 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 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 ArrayType() { current = next = 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 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 virtual TypeBase Percent(TypeBase right) { return null; }
public virtual TypeBase Minus(TypeBase right) { return null; }
public override BoolType Or(TypeBase right) { if (right.GetTypeStr() != "bool") return new BoolType(false); return new BoolType( val || (right as BoolType).val); }
public BoolType NotEqual(TypeBase right) { BoolType t = Equal(right); t.BVal = !t.BVal; return t; }
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 virtual TypeBase Power(TypeBase right) { return null; }
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 virtual TypeBase Add(TypeBase right) { return null; }
public override TypeBase Devide(TypeBase right) { return null; }
public virtual BoolType And(TypeBase right) { return new BoolType(false); }
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 virtual BoolType Equal(TypeBase right) { if ( (right is ArrayType) && (right as ArrayType).IsEmpty()) return new BoolType(true); return new BoolType(false); }
public override TypeBase Minus(TypeBase right) { return null; }