01: package gnu.mapping;
02:
03: /** A procedure activation frame (when compiled with explicit stacks). */
04:
05: public abstract class CallFrame extends CpsProcedure implements
06: Cloneable, CpsMethodContainer {
07: public Object[] args;
08: public Procedure proc;
09: protected Procedure caller;
10: protected int saved_pc;
11:
12: protected int numArgs;
13:
14: public int numArgs() {
15: return numArgs;
16: }
17:
18: public void apply(CpsMethodProc proc, CallContext context) {
19: context.pc = proc.selector;
20: step(context);
21: }
22:
23: public void apply(CallContext stack) {
24: Object[] args = stack.values;
25: Procedure.checkArgCount(this , args.length);
26: try {
27: CallFrame frame = (CallFrame) clone();
28: frame.args = args;
29: frame.caller = stack.proc;
30: frame.saved_pc = stack.pc;
31: frame.proc = this ;
32: stack.proc = frame;
33: stack.pc = saved_pc;
34: } catch (java.lang.CloneNotSupportedException ex) {
35: throw new InternalError(ex.toString());
36: }
37: }
38:
39: public abstract void step(CallContext stack);
40: }
|