/// <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; }
/// <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; }
public Constant(Token tok, Sara.Type type) : base(tok,type) { }
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; }
/// <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; }
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; }
public Op(Token op, Sara.Type type) : base(op, type) { }
public Temp(Sara.Type type) : base(Word.temp, type) { this.Number = ++Temp.Count; }
public Id(Word id, Sara.Type type, int offset) : base(id, type) { this.Offset = offset; }
/// <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); }