// Path: src/chap8/NativeEvaluator.java
// @Require(FuncEvaluator.class)
// @Reviser public class NativeEvaluator {
//     @Reviser public static class NativeArgEx extends FuncEvaluator.ArgumentsEx {
//         public NativeArgEx(List<ASTree> c) { super(c); }
//         @Override public Object eval(Environment callerEnv, Object value) {
//             if (!(value instanceof NativeFunction))
//                 return super.eval(callerEnv, value);
// 
//             NativeFunction func = (NativeFunction)value;
//             int nparams = func.numOfParameters();
//             if (size() != nparams)
//                 throw new StoneException("bad number of arguments", this);
//             Object[] args = new Object[nparams];
//             int num = 0;
//             for (ASTree a: this) {
//                 ASTreeEx ae = (ASTreeEx)a;
//                 args[num++] = ae.eval(callerEnv);
//             }
//             return func.invoke(args, this);
//         }
//     }
// }


import javassist.gluonj.util.Loader;
import chap8.NativeEvaluator;
package chap13;

public class VmRunner {
    public static void main(String[] args) throws Throwable {
        Loader.run(VmInterpreter.class, args, VmEvaluator.class,
// Path: src/chap8/NativeEvaluator.java
// @Require(FuncEvaluator.class)
// @Reviser public class NativeEvaluator {
//     @Reviser public static class NativeArgEx extends FuncEvaluator.ArgumentsEx {
//         public NativeArgEx(List<ASTree> c) { super(c); }
//         @Override public Object eval(Environment callerEnv, Object value) {
//             if (!(value instanceof NativeFunction))
//                 return super.eval(callerEnv, value);
// 
//             NativeFunction func = (NativeFunction)value;
//             int nparams = func.numOfParameters();
//             if (size() != nparams)
//                 throw new StoneException("bad number of arguments", this);
//             Object[] args = new Object[nparams];
//             int num = 0;
//             for (ASTree a: this) {
//                 ASTreeEx ae = (ASTreeEx)a;
//                 args[num++] = ae.eval(callerEnv);
//             }
//             return func.invoke(args, this);
//         }
//     }
// }


// Path: src/chap13/VmRunner.java
import javassist.gluonj.util.Loader;
import chap8.NativeEvaluator;

package chap13;

public class VmRunner {
    public static void main(String[] args) throws Throwable {
        Loader.run(VmInterpreter.class, args, VmEvaluator.class,
                                              NativeEvaluator.class);