// Copyright (c) 1996-2002 Brian D. Carlstrom

package bdc.scheme.expression;

import bdc.scheme.Environment;
import bdc.scheme.Stack;
import bdc.scheme.Variable;
import bdc.scheme.compiler.CompileTimeEnvironment;

public class LocalAddress extends Expression
{
    public Variable variable;
    public int      index;

    public LocalAddress (Variable variable,
                         int      index)
    {
        this.variable = variable;
        this.index    = index;
    }

    public Object eval (Environment environment, Stack stack)
    {
        return stack.array[stack.frame+index];
    }

    /**
        Fixup
    */
    public Expression fixupVariables (CompileTimeEnvironment environment)
    {
        return environment.fixupVariable(variable, this);
    }

    public String toString ()
    {
        return variable.name.toString();
    }
}
