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