Access offset(Id a) { Expr i; Expr w; Expr t1, t2; Expr loc; symbols.Type type = a.type; match('['); i = bool_expr(); match(']'); type = ((symbols.Array)type).of; w = new Constant(type.width, compileRows); t1 = new Arith(new Token('*'), i, w, compileRows); loc = t1; while (look.tag == '[') { match('['); i = bool_expr(); match(']'); type = ((symbols.Array)type).of; w = new Constant(type.width, compileRows); t1 = new Arith(new Token('*'), i, w, compileRows); t2 = new Arith(new Token('+'), loc, t1, compileRows); loc = t2; } return(new Access(a, loc, type, compileRows)); }
public virtual symbols.Type check(symbols.Type p1, symbols.Type p2) { if (p1 == symbols.Type.Bool && p2 == symbols.Type.Bool) { return(symbols.Type.Bool); } else { return(null); } }
symbols.Type dims(symbols.Type p) { match('['); Token tok = look; match(Tag.NUM); match(']'); if (look.tag == '[') { p = dims(p); } return(new symbols.Array(((Num)tok).value, p)); }
symbols.Type type() { symbols.Type p = (symbols.Type)look; match(Tag.BASIC); if (look.tag != '[') { return(p); } else { return(dims(p)); } }
void decls() { while (look.tag == Tag.BASIC) { symbols.Type p = type(); Token tok = look; match(Tag.ID); match(';'); Id id = new Id((Word)tok, p, used, compileRows); top.put(tok, id); used = used + p.width; } }
public symbols.Type check(symbols.Type p1, symbols.Type p2) { if (symbols.Type.numeric(p1) && symbols.Type.numeric(p2)) { return(p2); } else if (p1 == symbols.Type.Bool && p2 == symbols.Type.Bool) { return(p2); } else { return(null); } }
public override symbols.Type check(symbols.Type p1, symbols.Type p2) { if (p1 is symbols.Array || p1 is symbols.Array) { return(null); } else if (p1 == p2) { return(symbols.Type.Bool); } else { return(null); } }
public symbols.Type check(symbols.Type p1, symbols.Type p2) { if ((p1 is symbols.Array) || (p2 is symbols.Array)) { return(null); } else if (p1 == p2) { return(p2); } else if (symbols.Type.numeric(p1) && symbols.Type.numeric(p2)) { return(p2); } else { return(null); } }
public Expr(Token tok, symbols.Type p, List <CodeRow> outputList) { op = tok; type = p; rows = outputList; }
public Access(Id a, Expr i, symbols.Type p, List <CodeRow> outputList) : base(new Word("[]", Tag.INDEX), p, outputList) { array = a; index = i; }
public Constant(Token tok, symbols.Type p, List <CodeRow> outputList) : base(tok, p, outputList) { }
public Temp(symbols.Type p, List <CodeRow> outputList) : base(Word.temp, p, outputList) { number = ++count; }
public Id(Word id, symbols.Type p, int b, List <CodeRow> outputList) : base(id, p, outputList) { offset = b; }