1 20 21 22 25 class Tident extends Texp implements AST { 26 String name; 27 28 public Tident(String s) { 29 name = s; 30 } 31 32 public String toString() { 33 return name; 34 } 35 36 public void checkcontext(SymTab st) { SymtabEntry ste = st.lookup(name); 38 39 if (ste==null) 40 Main.error("variable not defined: "+name); 41 else if (ste.kind() != SymtabEntry.VAR) 42 Main.error("function used as variable: "+name); 43 } 44 45 int index; boolean is_input; 48 public void prepInterp(SymTab st) { STEvar ste = (STEvar)st.lookup(name); 50 index = ste.getIndex(); 51 is_input = ste.isInput(); 52 } 53 54 public int interpret(int[] in, int[] par) { 55 if (is_input) 56 return(in[index]); 57 else 58 return(par[index]); 59 } 60 } 61 62 63 | Popular Tags |