01: package jsint;
02:
03: /**
04: * A aupport class for the Scheme->Java compiler
05: * used to implement the last call optimization
06: * @author Timothy J. Hickey, Copyright (c) 2000, tim@cs.brandeis.edu <a href="license.txt">license</a>
07: * subsequently modified by Jscheme project members
08: * licensed under zlib licence (see license.txt)
09: */
10:
11: public class LCO {
12: public Object func;
13: public Pair params;
14:
15: public LCO(Object func, Pair params) {
16: this .func = func;
17: this .params = params;
18: }
19:
20: public static Object eval(Object X) {
21: while (X instanceof LCO) {
22: Object f = ((LCO) X).func;
23: if (f instanceof Function)
24: X = ((Function) f).invoke1(((LCO) X).params);
25: else if (f instanceof Procedure)
26: X = ((Procedure) f).apply(((LCO) X).params);
27: }
28: return X;
29: }
30: }
|