01: package jsint;
02:
03: import java.lang.reflect.Constructor;
04:
05: /** StaticReflector's like JavaConstructor and Generic can share this behavior.
06: * @author Peter Norvig, Copyright 1998, peter@norvig.com, <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 abstract class StaticReflector extends Reflector {
12:
13: public static final Object[] args0 = new Object[0];
14:
15: /** Code is an Object[] who's first element is a JavaConstructor, and
16: * remaining elements are arguments.
17: **/
18: public Object[] makeArgArray(Object[] code, Evaluator eval,
19: LexicalEnvironment lexenv) {
20: int L = code.length - 1;
21: if (L == 0)
22: return args0;
23:
24: Object[] args = new Object[L];
25: for (int i = 0; i < L; i++)
26: args[i] = eval.execute(code[i + 1], lexenv);
27: return args;
28: }
29:
30: public Object[] makeArgArray(Pair args) {
31: return U.listToVector(args);
32: }
33: }
|