1 package scm; 2 3 import jas.*; 4 5 class InsnProcedure extends Procedure implements Obj, jas.RuntimeConstants 6 { 7 int opc; 8 9 Obj apply(Cell args, Env f) 10 throws Exception 11 { 12 if (args == null) 13 { return new primnode(new Insn(opc)); } 14 Obj t = (args.car).eval(f); 15 if (t instanceof Selfrep) 16 { 17 int val = (int) (((Selfrep)t).num); 19 return new primnode(new Insn(opc, val)); 20 } 21 if (t instanceof primnode) 22 { 23 Object tprime = ((primnode)t).val; 24 if (tprime instanceof CP) 25 { 26 return new primnode(new Insn(opc, (CP)tprime)); 28 } 29 if (tprime instanceof Label) 31 { 32 return new primnode(new Insn(opc, (Label)tprime)); 33 } 34 } 35 throw new SchemeError("Sorry, not yet implemented " + this.toString()); 36 } 37 38 InsnProcedure(int opc) { this.opc = opc; } 39 public String toString() 40 { return ("<#insn "+opcNames[opc]+"#>"); } 41 } 42 | Popular Tags |