#define push_svalue(val) {sp++; assign_svalue_no_free(sp, val);}
extern struct svalue *sp;
extern struct object *previous_object;


union u {
    char *string;
    int number;
    float real;
    struct object *ob;
    struct vector *vec;
    struct svalue *lvalue;
    struct mapping *map;
};

/*
 * The value stack element.
 * If it is a string, then the way that the string has been allocated differ,
 * wich will affect how it should be freed.
 */
struct svalue {
    short type;
    short string_type;
    union u u;
};

#define T_INVALID	0x0
#define T_LVALUE	0x1
#define T_NUMBER	0x2
#define T_STRING	0x4
#define T_POINTER	0x8
#define T_OBJECT	0x10
#define T_MAPPING	0x20
#define T_FLOAT         0x40

#define STRING_MALLOC	0	/* Allocated by malloc() */
#define STRING_CONSTANT	1	/* Do not has to be freed at all */
#define STRING_SHARED	2	/* Allocated by the shared string library */

struct vector {
    short size;
    short ref;
#ifdef DEBUG
    int extra_ref;
#endif
    struct svalue item[1];
};

#define ALLOC_VECTOR(nelem) \
    (struct vector *)xalloc(sizeof (struct vector) + \
			    sizeof(struct svalue) * (nelem - 1))

struct lnode_def;
void free_vector (struct vector *), free_all_values();

/*
 * Control stack element.
 * 'prog' is usually same as 'ob->prog' (current_object), except when
 * when the current function is defined by inheritance.
 * The pointer, csp, will point to the values that will be used at return.
 */
struct control_stack {
    struct object *ob;		/* Current object */
    struct object *prev_ob;	/* Save previous object */
    struct program *prog;	/* Current program */
    int num_local_variables;	/* Local + arguments */
    unsigned pc;
    unsigned pc_save;
    struct svalue *fp;
    int extern_call;		/* Flag if evaluator should return */
    struct function *funp;	/* Only used for tracebacks */
    int inh_offset;
    char ext_call;
};

struct control_stack *csp;	/* Points to last element pushed */

extern int variable_index_found;
extern int variable_inherit_found;    
extern int variable_type_mod_found;

extern int function_index_found;
extern struct program *function_prog_found;
extern unsigned short function_type_mod_found;
extern int function_inherit_found;
extern struct control_stack *csp;