nesasm/source/symbol.c
/* ----
 * stinstall()
 * ----
 * install symbol into symbol hash table
 */
stinstall()

install symbol into symbol hash table
stinstall () install symbol into symbol hash table
struct t_symbol *stinstall(int hash, int type)
{
	struct t_symbol *sym;
	if ((sym = (void *)malloc(sizeof(struct t_symbol))) == NULL) {
		fatal_error("Out of memory!");
		return (NULL);
	}
	sym->type  = if_expr ? IFUNDEF : UNDEF;
	sym->value = 0;
	sym->local = NULL;
	sym->proc  = NULL;
	sym->bank  = RESERVED_BANK;
	sym->nb    = 0;
	sym->size  = 0;
	sym->page  = -1;
	sym->vram  = -1;
	sym->pal   = -1;
	sym->refcnt = 0;
	sym->reserved = 0;
	sym->data_type = -1;
	sym->data_size = 0;
	strcpy(sym->name, symbol);
	if (type) {
		sym->next = glablptr->local;
		glablptr->local = sym;
	}
	else {
		sym->next = hash_tbl[hash];
		hash_tbl[hash] = sym;
	}
	return (sym);
}
struct t_symbol * stinstall ( int hash , int type ) { struct t_symbol * sym ; if ( ( sym = ( void * ) malloc ( sizeof ( struct t_symbol ) ) ) == NULL ) { fatal_error ( " " ) ; return ( NULL ) ; } sym -> type = if_expr ? IFUNDEF : UNDEF ; sym -> value = 0 ; sym -> local = NULL ; sym -> proc = NULL ; sym -> bank = RESERVED_BANK ; sym -> nb = 0 ; sym -> size = 0 ; sym -> page = -1 ; sym -> vram = -1 ; sym -> pal = -1 ; sym -> refcnt = 0 ; sym -> reserved = 0 ; sym -> data_type = -1 ; sym -> data_size = 0 ; strcpy ( sym -> name , symbol ) ; if ( type ) { sym -> next = glablptr -> local ; glablptr -> local = sym ; } else { sym -> next = hash_tbl [ hash ] ; hash_tbl [ hash ] = sym ; } return ( sym ) ; }
stinstall()
 
 install symbol into symbol hash table
stinstall () install symbol into symbol hash table
/* allocate symbol structure */ /* init the symbol struct */ /* add the symbol to the hash table */ /* local */ /* global */ /* ok */