#ifndef ICI_EXEC_H
#define ICI_EXEC_H

#ifndef ICI_ARRAY_H
#include "array.h"
#endif

#ifndef ICI_INT_H
#include "int.h"
#endif

#ifndef ICI_FLOAT_H
#include "float.h"
#endif

/*
 * The following portion of this file exports to ici.h. --ici.h-start--
 */
union ostemp
{
    int_t       i;
    float_t     f;
};

struct exec
{
    array_t     x_xs;
    array_t     x_os;
    array_t     x_vs;
    int         x_count;
    array_t     *x_xs_pc_cache;         /* See below. */
    array_t     *x_os_temp_cache;       /* See below. */
};
/*
 * x_xs_pc_cache        An array that shadows the execution stack. pc objects
 *                      exist only in a one-to-one relationship with a fixed
 *                      (for their life) position on the execution stack. This
 *                      cache holds pc objects that, if present at a
 *                      particular index equal to the corresponding execution
 *                      stack index, can be used to avoid a new allocation.
 *                      See new_pc() in pc.c.
 *
 * x_os_temp_cache      An array of pseudo int/float objects that shadows the
 *                      operand stack. The objects in this array (apart
 *                      from the NULLs) are unions of int and float objects
 *                      that can be used as intermediate results in specific
 *                      circumstances as flaged by the compiler. Specifically,
 *                      they are known to be immediately consumed by some operator
 *                      that is only sensitive to the value, not the address,
 *                      of the object. See binop.h.
 */

#ifdef MULTI

#include    "multi.h"

#define ici_ex  (PROC_VARS->v_ex)

#else

extern DLI exec_t ici_ex;

#endif

#define os      (&ici_ex.x_os)
#define xs      (&ici_ex.x_xs)
#define vs      (&ici_ex.x_vs)
#define o_top   ici_ex.x_os.a_top
#define x_top   ici_ex.x_xs.a_top
#define v_top   ici_ex.x_vs.a_top

#ifndef NODEBUGGING

/*
 * ICI debug interface.  exec() calls the functions in this interface
 * if debugging is enabled.  A default interface, with stubbed
 * implementations of these functions, is provided in the ICI core
 * (in idb2.c).  Debuggers will normally override the default with
 * a more useful set of functions.
 */
struct debug
{
    void    (*idbg_error)(char *, src_t *);
    void    (*idbg_fncall)(object_t *, object_t **, int);
    void    (*idbg_fnresult)(object_t *);
    void    (*idbg_src)(src_t *);
    void    (*idbg_watch)(object_t *, object_t *, object_t *);
};

#endif
/*
 * End of ici.h export. --ici.h-end--
 */

#endif /* ICI_EXEC_H */
