public BasicType check(BasicType p1, BasicType p2) { if (p1 == BasicType.Bool && p2 == BasicType.Bool) { return(BasicType.Bool); } else { return(null); } }
public static bool numeric(BasicType p) { if (p == BasicType.Char || p == BasicType.Int || p == BasicType.Float) { return(true); } else { return(false); } }
public BasicType dims(BasicType p) { match('['); Token tok = look; match(Tag.NUM); match(']'); if (look.tag == '[') { p = dims(p); } return(new BasicArray(((Num)tok).value, p)); }
public void decls() { while (look.tag == Tag.BASIC) { BasicType p = type(); Token tok = look; match(Tag.ID); match(';'); Id id = new Id((Word)tok, p, used); top.put(tok, id); used += p.width; } }
public BasicType type() { BasicType p = (BasicType)look; match(Tag.BASIC); if (look.tag != '[') { return(p); } else { return(dims(p)); } }
public BasicType check(BasicType p1, BasicType p2) { if (p1 is BasicArray || p2 is BasicArray) { return(null); } else if (p1 == p2) { return(BasicType.Bool); } else { return(null); } }
public BasicType check(BasicType p1, BasicType p2) { if (BasicType.numeric(p1) && BasicType.numeric(p2)) { return(p2); } else if (p1 == BasicType.Bool && p2 == BasicType.Bool) { return(p2); } else { return(null); } }
public BasicType check(BasicType p1, BasicType p2) { if (p1 is BasicArray || p2 is BasicArray) { return(null); } else if (p1 == p2) { return(p2); } else if (BasicType.numeric(p1) && BasicType.numeric(p2)) { return(p2); } else { return(null); } }
public static BasicType max(BasicType p1, BasicType p2) { if (!numeric(p1) || !numeric(p2)) { return(null); } else if (p1 == BasicType.Float || p2 == BasicType.Float) { return(BasicType.Float); } else if (p1 == BasicType.Int || p2 == BasicType.Int) { return(BasicType.Int); } else { return(BasicType.Char); } }
public Access(Id a, Expr i, BasicType p) : base(new Word(Tag.INDEX, "[]"), p) { array = a; index = i; }
public Expr(Token tok, BasicType p) { op = tok; type = p; }
public Temp(BasicType p) : base(Word.temp, p) { number = ++count; }
public BasicArray(int sz, BasicType p) : base(Tag.INDEX, "[]", sz * p.width) { size = sz; of = p; }
public Id(Word id, BasicType p, int b) : base(id, p) { offset = b; }
public Op(Token tok, BasicType p) : base(tok, p) { }
public Constant(Token tok, BasicType p) : base(tok, p) { }