public String toString() {
        StringBuffer buffer = new StringBuffer();

        buffer.append("locals = [");
        for (int i = 0; i < locals.length; i++) {
            buffer.append(locals[i] == null ? "empty" : locals[i].toString());
            if (i < locals.length - 1)
                buffer.append(", ");
        }
        buffer.append("] stack = [");
        for (int i = 0; i < top; i++) {
            buffer.append(stack[i]);
            if (i < top - 1)
                buffer.append(", ");
        }
        buffer.append("]");

        return buffer.toString();
    }