// Path: src/stone/StoneException.java
// public class StoneException extends RuntimeException {
//     public StoneException(String m) { super(m); }
//     public StoneException(String m, ASTree t) {
//         super(m + " " + t.location());
//     }
// }
// 
// Path: src/chap11/EnvOptimizer.java
// @Reviser public static interface EnvEx2 extends Environment {
//     Symbols symbols();
//     void put(int nest, int index, Object value);
//     Object get(int nest, int index);
//     void putNew(String name, Object value);
//     Environment where(String name);
// }
// 
// Path: src/chap6/Environment.java
// public interface Environment {
//     void put(String name, Object value);
//     Object get(String name);
// }


import stone.StoneException;
import chap11.EnvOptimizer.EnvEx2;
import chap6.Environment;
package chap11;

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
// Path: src/stone/StoneException.java
// public class StoneException extends RuntimeException {
//     public StoneException(String m) { super(m); }
//     public StoneException(String m, ASTree t) {
//         super(m + " " + t.location());
//     }
// }
// 
// Path: src/chap11/EnvOptimizer.java
// @Reviser public static interface EnvEx2 extends Environment {
//     Symbols symbols();
//     void put(int nest, int index, Object value);
//     Object get(int nest, int index);
//     void putNew(String name, Object value);
//     Environment where(String name);
// }
// 
// Path: src/chap6/Environment.java
// public interface Environment {
//     void put(String name, Object value);
//     Object get(String name);
// }


// Path: src/chap11/ArrayEnv.java
import stone.StoneException;
import chap11.EnvOptimizer.EnvEx2;
import chap6.Environment;

package chap11;

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);