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