#include "genht/htsp.h"

typedef struct scope_s scope_t;

struct scope_s {
	htsp_t *typedefs;             /* typename -> type declaration subtree clone for typedefs*/
	htsp_t *negative_typedefs;    /* typename -> (1) for those IDs which are typedef'd in parent scopes but redeclared as variables in the current scope */
	node_t *compound;             /* pointer for return node of a compound being assambled */
	scope_t *parent, *child;
};

/* current scope */
extern scope_t *scope;

/* enter a new scope (upon '{') */
void scope_enter();

/* leave current scope (upon '}') */
void scope_leave();

/* register a typedef */
void scope_add_typedef(const char *name, node_t *new);

/* get a type subtree by "type" if "type" is a typedef'd type in the current
   scope or any parent of the current scope */
const node_t *scope_get_typedef(const char *type);

/* create a typedef */
void scope_typedef_add(node_t *type, node_t *ids);

/* create a negative typedef */
void scope_negative_typedef_add(const char *name);

