KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scm > InsnProcedure


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 JavaDoc
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                                 // Single integer arg
18
int val = (int) (((Selfrep)t).num);
19         return new primnode(new Insn(opc, val));
20       }
21     if (t instanceof primnode)
22       {
23         Object JavaDoc tprime = ((primnode)t).val;
24         if (tprime instanceof CP)
25           {
26                                 // Single CP argument
27
return new primnode(new Insn(opc, (CP)tprime));
28           }
29                                 // Labels
30
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 JavaDoc toString()
40   { return ("<#insn "+opcNames[opc]+"#>"); }
41 }
42
Popular Tags