// Path: src/chap11/ArrayEnv.java
// public class ArrayEnv implements Environment {
//     protected Object[] values;
//     protected Environment outer;
//     public ArrayEnv(int size, Environment out) {
//         values = new Object[size];
//         outer = out;
//     }
//     public Symbols symbols() { throw new StoneException("no symbols"); }
//     public Object get(int nest, int index) {
//         if (nest == 0)
//             return values[index];
//         else if (outer == null)
//             return null;
//         else
//             return ((EnvEx2)outer).get(nest - 1, index);
//     }
//     public void put(int nest, int index, Object value) {
//         if (nest == 0)
//             values[index] = value;
//         else if (outer == null)
//             throw new StoneException("no outer environment");
//         else
//             ((EnvEx2)outer).put(nest - 1, index, value);
//     }
//     public Object get(String name) { error(name); return null; }
//     public void put(String name, Object value) { error(name); }
//     public void putNew(String name, Object value) { error(name); }
//     public Environment where(String name) { error(name); return null; }
//     public void setOuter(Environment e) { outer = e; }
//     private void error(String name) {
//         throw new StoneException("cannot access by name: " + name);
//     }
// }


import chap11.ArrayEnv;
package chap14;

public class Runtime {
    public static int eq(Object a, Object b) {
        if (a == null)
            return b == null ? 1 : 0;
        else
            return a.equals(b) ? 1 : 0;
    }
    public static Object plus(Object a, Object b) {
        if (a instanceof Integer && b instanceof Integer)
            return ((Integer)a).intValue() + ((Integer)b).intValue();
        else
            return a.toString().concat(b.toString());
    }
    public static int writeInt(ArrayEnv env, int index, int value) {
        env.put(0, index, value);
        return value;
    }
    public static String writeString(ArrayEnv env, int index, String value) {
        env.put(0, index, value);
        return value;
    }
// Path: src/chap11/ArrayEnv.java
// public class ArrayEnv implements Environment {
//     protected Object[] values;
//     protected Environment outer;
//     public ArrayEnv(int size, Environment out) {
//         values = new Object[size];
//         outer = out;
//     }
//     public Symbols symbols() { throw new StoneException("no symbols"); }
//     public Object get(int nest, int index) {
//         if (nest == 0)
//             return values[index];
//         else if (outer == null)
//             return null;
//         else
//             return ((EnvEx2)outer).get(nest - 1, index);
//     }
//     public void put(int nest, int index, Object value) {
//         if (nest == 0)
//             values[index] = value;
//         else if (outer == null)
//             throw new StoneException("no outer environment");
//         else
//             ((EnvEx2)outer).put(nest - 1, index, value);
//     }
//     public Object get(String name) { error(name); return null; }
//     public void put(String name, Object value) { error(name); }
//     public void putNew(String name, Object value) { error(name); }
//     public Environment where(String name) { error(name); return null; }
//     public void setOuter(Environment e) { outer = e; }
//     private void error(String name) {
//         throw new StoneException("cannot access by name: " + name);
//     }
// }


// Path: src/chap14/Runtime.java
import chap11.ArrayEnv;

package chap14;

public class Runtime {
    public static int eq(Object a, Object b) {
        if (a == null)
            return b == null ? 1 : 0;
        else
            return a.equals(b) ? 1 : 0;
    }
    public static Object plus(Object a, Object b) {
        if (a instanceof Integer && b instanceof Integer)
            return ((Integer)a).intValue() + ((Integer)b).intValue();
        else
            return a.toString().concat(b.toString());
    }
    public static int writeInt(ArrayEnv env, int index, int value) {
        env.put(0, index, value);
        return value;
    }
    public static String writeString(ArrayEnv env, int index, String value) {
        env.put(0, index, value);
        return value;
    }
    public static Object writeAny(ArrayEnv env, int index, Object value) {