Esempio n. 1
0
 /// <summary>
 /// Virtual
 /// Check if both are Dragon.Type.Bool
 /// </summary>
 /// <param name="lhs"></param>
 /// <param name="rhs"></param>
 /// <returns>Dragon.Type.Bool or null</returns>
 protected virtual Sara.Type Check(Sara.Type lhs, Sara.Type rhs)
 {
     if (lhs == Sara.Type.Bool && rhs == Sara.Type.Bool)
     {
         return(Sara.Type.Bool);
     }
     return(null);
 }
Esempio n. 2
0
 /// <summary>
 /// Overriding
 /// Check the two operands have the same type and neither is Array
 /// </summary>
 /// <param name="lft"></param>
 /// <param name="rht"></param>
 /// <returns></returns>
 protected override Sara.Type Check(Sara.Type lft, Sara.Type rht)
 {
     if (lft is Array || rht is Array)
     {
         return(null);
     }
     else
     {
         return(lft == rht ? Sara.Type.Bool : null);
     }
 }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <returns>Type</returns>
        public Sara.Type Dimension(Sara.Type type)
        {
            this.Match('[');
            var tok = _look;

            this.Match(Tag.NUM);
            this.Match(']');

            if (_look.TagValue == '[')
            {
                type = this.Dimension(type);
            }

            return(new Array((tok as Num).Value, type));
        }
Esempio n. 4
0
 public Sara.Type Check(Sara.Type lhs, Sara.Type rhs)
 {
     if (Sara.Type.Numeric(lhs) && Sara.Type.Numeric(rhs))
     {
         return(rhs);
     }
     else if (lhs == Sara.Type.Bool && rhs == Sara.Type.Bool)
     {
         return(rhs);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 5
0
 private Sara.Type Check(Sara.Type lhs, Sara.Type rhs)
 {
     if (lhs is Array || rhs is Array)
     {
         return(null);
     }
     else if (lhs == rhs)
     {
         return(rhs);
     }
     else if (Sara.Type.Numeric(lhs) && Sara.Type.Numeric(rhs))
     {
         return(rhs);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 6
0
 public Constant(Token tok, Sara.Type type)
     : base(tok, type)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="arr"></param>
 /// <param name="idx"></param>
 /// <param name="type"></param>
 public Access(Id arr, Expr idx, Sara.Type type)
     : base(new Word("[]", Tag.INDEX), type)
 {
     this.Array = arr;
     this.Index = idx;
 }
Esempio n. 8
0
 public Op(Token op, Sara.Type type)
     : base(op, type)
 {
 }
Esempio n. 9
0
 public Temp(Sara.Type type)
     : base(Word.temp, type)
 {
     this.Number = ++Temp.Count;
 }
Esempio n. 10
0
 public Id(Word id, Sara.Type type, int offset)
     : base(id, type)
 {
     this.Offset = offset;
 }