Exemple #1
0
 public override void AddToClosure(string name, TypeBase val)
 {
     if (closure.ContainsKey(name))
         closure[name] = val;
     else
         closure.Add(name, val);
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 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;
 }
Exemple #4
0
 public override TypeBase Multi(TypeBase right)
 {
     return null;
 }
Exemple #5
0
 public override TypeBase Power(TypeBase right)
 {
     return null;
 }
Exemple #6
0
 public virtual TypeBase Devide(TypeBase right)
 {
     return null;
 }
Exemple #7
0
 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);
 }
Exemple #8
0
 public virtual BoolType Smaller(TypeBase right)
 {
     return new BoolType(false);
 }
Exemple #9
0
 public virtual void AddToClosure(string name, TypeBase val)
 {
 }
Exemple #10
0
 public virtual TypeBase Multi(TypeBase right)
 {
     return null;
 }
Exemple #11
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);
 }
Exemple #12
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;
 }
Exemple #13
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;
 }
Exemple #14
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;
 }
Exemple #15
0
 public ArrayType()
 {
     current = next = null;
 }
Exemple #16
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;
 }
Exemple #17
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);
 }
Exemple #18
0
 public virtual TypeBase Percent(TypeBase right)
 {
     return null;
 }
Exemple #19
0
 public virtual TypeBase Minus(TypeBase right)
 {
     return null;
 }
Exemple #20
0
 public override BoolType Or(TypeBase right)
 {
     if (right.GetTypeStr() != "bool")
         return new BoolType(false);
     return new BoolType( val || (right as BoolType).val);
 }
Exemple #21
0
 public BoolType NotEqual(TypeBase right)
 {
     BoolType t = Equal(right);
     t.BVal = !t.BVal;
     return t;
 }
Exemple #22
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);
 }
Exemple #23
0
 public virtual TypeBase Power(TypeBase right)
 {
     return null;
 }
Exemple #24
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;
 }
Exemple #25
0
 public virtual TypeBase Add(TypeBase right)
 {
     return null;
 }
Exemple #26
0
 public override TypeBase Devide(TypeBase right)
 {
     return null;
 }
Exemple #27
0
 public virtual BoolType And(TypeBase right)
 {
     return new BoolType(false);
 }
Exemple #28
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);
 }
Exemple #29
0
 public virtual BoolType Equal(TypeBase right)
 {
     if ( (right is ArrayType) && (right as ArrayType).IsEmpty())
         return new BoolType(true);
     return new BoolType(false);
 }
Exemple #30
0
 public override TypeBase Minus(TypeBase right)
 {
     return null;
 }