nesasm/source/symbol.c
/* ----
 * stlook()
 * ----
 * symbol table lookup
 * if found, return pointer to symbol
 * else, install symbol as undefined and return pointer
 */
stlook()

symbol table lookup
if found, return pointer to symbol
else, install symbol as undefined and return pointer
stlook () symbol table lookup if found return pointer to symbol else install symbol as undefined and return pointer
struct t_symbol *stlook(int flag)
{
	struct t_symbol *sym;
	int sym_flag = 0;
	int hash;
	if (symbol[1] == '.') {
		if (glablptr) {
			sym = glablptr->local;
			while (sym) {
				if (!strcmp(symbol, sym->name))
					break;			
				sym = sym->next;
			}
			if (sym == NULL) {
				if (flag) {
					sym = stinstall(0, 1);
					sym_flag = 1;
				}
			}
		}
		else {
			error("Local symbol not allowed here!");
			return (NULL);
		}
	}
	else {
		hash = symhash();
		sym  = hash_tbl[hash];
		while (sym) {
			if (!strcmp(symbol, sym->name))
				break;			
			sym = sym->next;
		}
		if (sym == NULL) {
			if (flag) {
				sym = stinstall(hash, 0);
				sym_flag = 1;
			}
		}
	}
	if (sym_flag == 0) {
		if (sym)
			sym->refcnt++;
	}
	return (sym);
}
struct t_symbol * stlook ( int flag ) { struct t_symbol * sym ; int sym_flag = 0 ; int hash ; if ( symbol [ 1 ] == ' ' ) { if ( glablptr ) { sym = glablptr -> local ; while ( sym ) { if ( ! strcmp ( symbol , sym -> name ) ) break ; sym = sym -> next ; } if ( sym == NULL ) { if ( flag ) { sym = stinstall ( 0 , 1 ) ; sym_flag = 1 ; } } } else { error ( " " ) ; return ( NULL ) ; } } else { hash = symhash ( ) ; sym = hash_tbl [ hash ] ; while ( sym ) { if ( ! strcmp ( symbol , sym -> name ) ) break ; sym = sym -> next ; } if ( sym == NULL ) { if ( flag ) { sym = stinstall ( hash , 0 ) ; sym_flag = 1 ; } } } if ( sym_flag == 0 ) { if ( sym ) sym -> refcnt ++ ; } return ( sym ) ; }
stlook()
 
 symbol table lookup
 if found, return pointer to symbol
 else, install symbol as undefined and return pointer
stlook () symbol table lookup if found return pointer to symbol else install symbol as undefined and return pointer
/* local symbol */ /* search the symbol in the local list */ /* new symbol */ /* global symbol */ /* search symbol */ /* new symbol */ /* incremente symbol reference counter */ /* ok */