OBJECT SearchSym(FULL_CHAR *str, int len) { register int rlen, sum; register FULL_CHAR *x, *y; OBJECT p, q, link, plink, entry; int s; debug2(DST, DDD, "SearchSym( %c..., %d )", str[0], len); hash(str, len, sum); rlen = len; entry = (OBJECT) &symtab[sum]; for( plink = Down(entry); plink != entry; plink = NextDown(plink) ) { Child(p, plink); if( rlen == length(p) ) { x = str; y = string(p); do; while( *x++ == *y++ && --rlen ); if( rlen == 0 ) { debug1(DST, DDD, " found %s", string(p)); s = scope_top; do { s--; for( link = Down(p); link != p; link = NextDown(link) ) { Child(q, link); { debugcond4(DST, DDD, enclosing(q) == scope[s], " !npars_only[s] = %s, !vis_only[s] = %s, body_ok[s] = %s, !ss = %s", bool(!npars_only[s]), bool(!vis_only[s]), bool(body_ok[s]), bool(!suppress_scope)); } if( enclosing(q) == scope[s] && (!npars_only[s] || type(q) == NPAR) && (!vis_only[s] || visible(q) || suppress_visible ) && (body_ok[s] || type(q)!=RPAR || !has_body(enclosing(q)) || suppress_visible ) && (!suppress_scope || StringEqual(string(p), KW_INCLUDE) || StringEqual(string(p), KW_SYSINCLUDE)) ) { debug3(DST, DD, "SearchSym returning %s %s%%%s", Image(type(q)), SymName(q), SymName(enclosing(q))); return q; } } } while( scope[s] != StartSym ); } } rlen = len; } debug0(DST, DDD, "SearchSym returning <nilobj>"); return nilobj; } /* end SearchSym */
static void DumpBaseType( TYPEPTR typ, STRCHUNK *pch ) { SYM_ENTRY sym; TYPEPTR obj; for( ; typ->decl_type != TYPE_TYPEDEF && typ->decl_type != TYPE_ENUM; ) { obj = Object( typ ); if( obj == NULL ) break; typ = obj; } SKIP_DUMMY_TYPEDEFS( typ ); if( typ->decl_type == TYPE_TYPEDEF ) { SymGet( &sym, typ->u.typedefn ); ChunkSaveStrWord( pch, SymName( &sym, typ->u.typedefn ) ); } else { if( typ->type_flags & TF2_TYPE_PLAIN_CHAR ) { ChunkSaveStrWord( pch, "char" ); } else { ChunkSaveStrWord( pch, CTypeNames[typ->decl_type] ); } if( typ->decl_type == TYPE_STRUCT || typ->decl_type == TYPE_UNION || typ->decl_type == TYPE_ENUM ) { /* if there is no tag name, then should print out the entire structure or union definition or enum list */ DumpTagName( typ->u.tag->name, pch ); } } }
void ObjEmitLabel( sym_handle sym ) { //*********************************** // Stacks up the label in the list for ObjEmitData to emit owl_sym_type type; owl_sym_linkage linkage; sym_linkage symbol_linkage; owl_section_type section_type; if( ObjLabelDefined( sym ) ) { Error( SYM_ALREADY_DEFINED, SymName( sym ) ); return; } section_type = OWLTellSectionType( CurrentSection ); if( section_type & OWL_SEC_ATTR_CODE ) { type = OWL_TYPE_FUNCTION; } else { type = OWL_TYPE_OBJECT; } symbol_linkage = SymGetLinkage( sym ); if( symbol_linkage == SL_UNKNOWN ) { SymSetLinkage( sym, SL_STATIC ); // from now on it's static } linkage = linkage_table[symbol_linkage]; doStackLabel( sym, type, linkage ); }
extern void AsNumLabelEmit( uint_32 label_num, owl_section_handle section, owl_offset offset, owl_sym_type type ) { //***************************************************************************************************************** // These symbols are used for matching l^ & h^ garbage. sym_handle new_fw_sym; // forward char *new_fw_name; sym_reloc reloc; int_32 numlabel_ref; new_fw_name = AsNumLabelMakeName( label_num ); new_fw_sym = SymLookup( new_fw_name ); if( new_fw_sym ) { // check if it still has some unemitted relocs if( new_fw_sym->hi_relocs ) { Error( UNMATCHED_HIGH_RELOC, "<numeric reference>" ); while( new_fw_sym->hi_relocs ) { SymDestroyReloc( new_fw_sym, new_fw_sym->hi_relocs ); } } if( new_fw_sym->lo_relocs ) { _DBGMSG1( "emitting all the unemitted l^relocs\n" ); while( ( reloc = new_fw_sym->lo_relocs ) != NULL ) { numlabel_ref = AsNumLabelGetNum( SymName( new_fw_sym ) ); #ifdef _STANDALONE_ ObjDirectEmitReloc( reloc->location.section, #else ObjDirectEmitReloc( #endif reloc->location.offset, &numlabel_ref, OWL_RELOC_HALF_LO, FALSE ); SymDestroyReloc( new_fw_sym, reloc ); reloc = new_fw_sym->lo_relocs; } } assert( new_fw_sym->hi_relocs == NULL && new_fw_sym->lo_relocs == NULL ); } else {
static bool dirFuncUnsupported( directive_t *dir, dir_table_enum parm ) //********************************************************************* { /* unused parameters */ (void)parm; Error( DIRECTIVE_NOT_SUPPORTED, SymName( dir->dir_sym ) ); return( true ); }
static bool dirFuncStorageAlloc( directive_t *dir, dir_table_enum parm ) //********************************************************************** // e.g.) .comm name, expr // Emit a label name, then emit expr bytes of data { dir_operand *dirop; sym_handle sym; int_32 expr; char *buffer; owl_section_handle curr_section; reserved_section as_section = 0; if( !dirNumOperandsVerify( dir->num_operands, 2 ) ) { return( TRUE ); } dirop = dir->operand_list; if( dirop->type != DIROP_SYMBOL ) { Error( IMPROPER_DIROP, 0 ); return( TRUE ); } sym = SYMBOL_HANDLE( dirop ); dirop = dirop->next; if( dirop->type != DIROP_INTEGER ) { Error( IMPROPER_DIROP, 1 ); return( TRUE ); } expr = NUMBER_INTEGER( dirop ); if( expr <= 0 ) { Error( OP_OUT_OF_RANGE, 1 ); return( TRUE ); } if( ObjLabelDefined( sym ) ) { // then such label has already been emitted Error( SYM_ALREADY_DEFINED, SymName( sym ) ); return( TRUE ); } curr_section = CurrentSection; switch( parm ) { case DT_SEC_DATA: // .comm => globl as_section = AS_SECTION_DATA; SymSetLinkage( sym, SL_GLOBAL ); break; case DT_SEC_BSS: // .lcomm, .bss as_section = AS_SECTION_BSS; break; default: assert( FALSE ); } ObjSwitchSection( as_section ); // Have to switch to the right ObjEmitLabel( sym ); // section before emitting label. buffer = MemAlloc( expr ); memset( buffer, 0, expr ); ObjEmitData( CurrentSection, buffer, expr, TRUE ); // Align the data also. MemFree( buffer ); CurrentSection = curr_section; // Switch back to where you were. return( TRUE ); }
void PushScope(OBJECT x, BOOLEAN npars, BOOLEAN vis) { debug3(DST, DD, "[ PushScope(%s, %s, %s)", SymName(x), bool(npars), bool(vis)); assert( suppress_scope == FALSE, "PushScope: suppress_scope!" ); if( scope_top >= MAX_STACK ) { #if DEBUG_ON int i; for( i = 0; i < scope_top; i++ ) Error(29, 1, " scope[%2d] = %s", WARN, &fpos(x), i, SymName(scope[i])); #endif Error(29, 2, "scope depth limit exceeded", INTERN, &fpos(x)); } scope[scope_top] = x; npars_only[scope_top] = npars; vis_only[scope_top] = vis; body_ok[scope_top] = FALSE; scope_top++; } /* end PushScope */
int IsSym (char* S) /* If a symbol follows, read it and return 1, otherwise return 0 */ { if (IsIdent (CurC)) { SymName (S); return 1; } else { return 0; } }
OBJECT ChildSym(OBJECT s, unsigned typ) { OBJECT link, y; for( link = Down(s); link != s; link = NextDown(link) ) { Child(y, link); if( type(y) == typ && enclosing(y) == s ) return y; } Error(29, 10, "symbol %s has missing %s", FATAL, &fpos(s), SymName(s), Image(typ)); return nilobj; } /* end ChildSym */
extern void ObjEmitLabel( sym_handle sym ) { //****************************************** // Stacks up the label in the list for ObjEmitData to emit if( ObjLabelDefined( sym ) ) { Error( SYM_ALREADY_DEFINED, SymName( sym ) ); return; } doStackLabel( sym ); }
/* Check parameters of function that were called before a prototype was seen */ extern void ChkCallParms( void ) { call_list *nextcall; nextcall = CallNodeList; while( nextcall != NULL ) { call_list *next; TREEPTR callnode; TREEPTR callsite; SYM_ENTRY sym; TYPEPTR typ; callnode = nextcall->callnode; if( callnode != NULL ) { callsite = callnode->left; // point to OPR_FUNCNAME node SymGet( &sym, callsite->op.sym_handle ); typ = sym.sym_type; SKIP_TYPEDEFS( typ ); if( !(sym.flags & SYM_TEMP) ) SetDiagSymbol( &sym, callsite->op.sym_handle ); if( typ->u.fn.parms != NULL ) { TREEPTR parms; bool reverse; parms = callnode->right; reverse = ( ParmsToBeReversed( sym.attrib, NULL ) && ( parms != NULL ) ); if( reverse ) { parms = reverse_parms_tree( parms ); } CompareParms( typ->u.fn.parms, parms, &nextcall->src_loc ); if( reverse ) { reverse_parms_tree( parms ); } } else { // Unprototyped function called. Note that for indirect calls, there // is no symbol associated with the function and diagnostic information // is hence limited. SetErrLoc( &nextcall->src_loc ); if( sym.flags & SYM_TEMP ) { CWarn( WARN_NONPROTO_FUNC_CALLED_INDIRECT, ERR_NONPROTO_FUNC_CALLED_INDIRECT ); } else { CWarn( WARN_NONPROTO_FUNC_CALLED, ERR_NONPROTO_FUNC_CALLED, SymName( &sym, callsite->op.sym_handle ) ); } } if( !(sym.flags & SYM_TEMP) ) { SetDiagPop(); } } next = nextcall->next; CMemFree( nextcall ); nextcall = next; } }
OBJECT ChildSymWithCode(OBJECT s, unsigned char code) { OBJECT link, y; for( link = Down(actual(s)); link != actual(s); link = NextDown(link) ) { Child(y, link); if( type(y) == NPAR && enclosing(y) == actual(s) && npar_code(y) == code ) return y; } Error(29, 11, "symbol %s has erroneous code %c (database out of date?)", FATAL, &fpos(s), SymName(actual(s)), (char) code); return nilobj; } /* end ChildSym */
void DetachGalley(OBJECT hd) { OBJECT prnt, index; assert( type(hd) == HEAD && Up(hd) != hd, "DetachGalley: precondition!" ); debug1(DGA, D, "DetachGalley( %s )", SymName(actual(hd))); Parent(prnt, Up(hd)); assert( Up(prnt) != prnt, "DetachGalley: parent!" ); New(index, UNATTACHED); pinpoint(index) = nilobj; MoveLink(Up(hd), index, PARENT); Link(NextDown(Up(prnt)), index); debug0(DGA, D, "DetachGalley returning."); } /* end DetachGalley */
void ObjRelocsFini( void ) { //************************** // If the parse was successful, we need to check whether there're any unmatched // relocs still hanging around. If there're unmatched h^relocs, we issue an // error. If there're unmatched l^relocs, we should be able to emit them. sym_reloc reloc; sym_handle sym; int_32 numlabel_ref; reloc = SymGetReloc( TRUE, &sym ); while( reloc != NULL ) { if( reloc->named ) { Error( UNMATCHED_HIGH_RELOC, SymName( sym ) ); } else { // TODO: actually show the numref (eg. 2f) Error( UNMATCHED_HIGH_RELOC, "<numeric reference>" ); } SymDestroyReloc( sym, reloc ); reloc = SymGetReloc( TRUE, &sym ); } reloc = SymGetReloc( FALSE, &sym ); while( reloc != NULL ) { if( reloc->named ) { doEmitReloc( reloc->location.section, reloc->location.offset, SymName( sym ), OWL_RELOC_HALF_LO, TRUE ); } else { numlabel_ref = AsNumLabelGetNum( SymName( sym ) ); doEmitReloc( reloc->location.section, reloc->location.offset, &numlabel_ref, OWL_RELOC_HALF_LO, FALSE ); } SymDestroyReloc( sym, reloc ); reloc = SymGetReloc( FALSE, &sym ); } #ifdef AS_DEBUG_DUMP (void)SymRelocIsClean( TRUE ); #endif ObjFlushLabels(); // In case there're still pending labels AsNumLabelFini(); // resolve all numeric label relocs }
extern void ObjRelocsFini( void ) { //********************************* // After all lines have been parsed, we need to check whether there're any // unmatched relocs still hanging around. If there're unmatched h^relocs, // we issue an error. If there're unmatched l^relocs, we should be able // to emit them. sym_reloc reloc; sym_handle sym; int_32 numlabel_ref; reloc = SymGetReloc( TRUE, &sym ); while( reloc != NULL ) { if( reloc->named ) { Error( UNMATCHED_HIGH_RELOC, SymName( sym ) ); } else { Error( UNMATCHED_HIGH_RELOC, "<numeric reference>" ); } SymDestroyReloc( sym, reloc ); reloc = SymGetReloc( TRUE, &sym ); } reloc = SymGetReloc( FALSE, &sym ); while( reloc != NULL ) { if( reloc->named ) { doEmitReloc( reloc->location.offset, SymName( sym ), OWL_RELOC_HALF_LO, TRUE ); } else { numlabel_ref = AsNumLabelGetNum( SymName( sym ) ); doEmitReloc( reloc->location.offset, &numlabel_ref, OWL_RELOC_HALF_LO, FALSE ); } SymDestroyReloc( sym, reloc ); reloc = SymGetReloc( FALSE, &sym ); } #ifdef AS_DEBUG_DUMP (void)SymRelocIsClean( TRUE ); #endif AsNumLabelFini(); // resolve all numeric label relocs resolveRelativeRelocs(); }
STATIC walk_result loadRoutineInfo( sym_walk_info swi, sym_handle *sym, void *_new_mod ) /*********************************************************************/ { mod_info *new_mod = _new_mod; sym_info sinfo; file_info *sym_file; rtn_info *new_rtn; int rtn_count; int name_len; int sym_size; int demangle_type; if( swi != SWI_SYMBOL ) { return( WR_CONTINUE ); } SymInfo( sym, NULL, &sinfo ); if( sinfo.kind != SK_CODE && sinfo.kind != SK_PROCEDURE ) { return( WR_CONTINUE ); } sym_file = loadFileInfo( new_mod, sym ); name_len = SymName( sym, NULL, SN_DEMANGLED, NULL, 0 ); if( name_len == 0 ) { name_len = SymName( sym, NULL, SN_SOURCE, NULL, 0 ); demangle_type = SN_SOURCE; } else { demangle_type = SN_DEMANGLED; } new_rtn = ProfCAlloc( sizeof( rtn_info ) + name_len ); SymName( sym, NULL, demangle_type, new_rtn->name, name_len + 1 ); sym_size = DIPHandleSize( HK_SYM ); new_rtn->sh = ProfAlloc( sym_size ); memcpy( new_rtn->sh, sym, sym_size ); rtn_count = sym_file->rtn_count; sym_file->rtn_count++; sym_file->routine = ProfRealloc( sym_file->routine, sym_file->rtn_count * sizeof( pointer ) ); sym_file->routine[rtn_count] = new_rtn; return( WR_CONTINUE ); }
/* * doFindSymbol */ BOOL doFindSymbol( ADDRESS *addr, syminfo *si, int getsrcinfo ) { sym_handle *symhdl; cue_handle *cue; search_result sr; location_list ll; address dipaddr; BOOL ret; si->segnum = -1; si->name[0] = 0; if( !StatShowSymbols || curProcess == NULL ) { return( FALSE ); } symhdl = MemAlloc( DIPHandleSize( HK_SYM ) ); dipaddr.sect_id = 0; dipaddr.indirect = FALSE; dipaddr.mach.offset = addr->offset; dipaddr.mach.segment = addr->seg; sr = AddrSym( NO_MOD, dipaddr, symhdl ); switch( sr ) { case SR_CLOSEST: SymLocation( symhdl, NULL, &ll ); si->symoff = addr->offset - ll.e[0].u.addr.mach.offset; break; case SR_EXACT: si->symoff = 0; break; case SR_NONE: ret = FALSE; break; } if( sr != SR_NONE ) { SymName( symhdl, NULL, SN_OBJECT, si->name, MAX_SYM_NAME ); // SymName( symhdl, NULL, SN_SOURCE, si->name, MAX_SYM_NAME ); if( getsrcinfo ) { cue = MemAlloc( DIPHandleSize( HK_CUE ) ); if( AddrCue( NO_MOD, dipaddr, cue ) == SR_NONE ) { MemFree( cue ); ret = FALSE; } else { CueFile( cue, si->filename, MAX_FILE_NAME ); si->linenum = CueLine( cue ); MemFree( cue ); ret = TRUE; } } } MemFree( symhdl ); return( ret ); }
local void FuncDefn( SYMPTR sym ) { SYM_NAMEPTR sym_name; int sym_len; TYPEPTR typ; /* duplicate name in near space */ sym_name = SymName( sym, CurFuncHandle ); sym_len = far_strlen_plus1( sym_name ); sym->name = CMemAlloc( sym_len ); far_memcpy( sym->name, sym_name, sym_len ); if( sym->flags & SYM_DEFINED ) { CErr2p( ERR_SYM_ALREADY_DEFINED, sym->name ); /* 03-aug-88 */ } typ = sym->sym_type->object; /* get return type */ SKIP_TYPEDEFS( typ ); if( typ->decl_type != TYPE_VOID ) { /* 26-mar-91 */ if( TypeSize( typ ) == 0 ) { CErr( ERR_INCOMPLETE_TYPE, sym_name ); } } sym->flags |= /*SYM_REFERENCED | 18-jan-89 */ SYM_DEFINED; if( !(GenSwitches & NO_OPTIMIZATION) ) { sym->flags |= SYM_OK_TO_RECURSE; /* 25-sep-91 */ } if( sym->stg_class == SC_EXTERN || sym->stg_class == SC_FORWARD ) { sym->stg_class = SC_NULL; /* indicate exported function */ } CompFlags.external_defn_found = 1; if( Toggles & TOGGLE_CHECK_STACK ) sym->flags |= SYM_CHECK_STACK; if( !CompFlags.zu_switch_used ) { if( (sym->attrib & FLAG_INTERRUPT) == FLAG_INTERRUPT ) { /* interrupt function */ TargetSwitches |= FLOATING_SS; /* force -zu switch on */ } else { TargetSwitches &= ~FLOATING_SS; /* turn it back off */ } } if( strcmp( CurFunc->name, "main" ) == 0 || strcmp( CurFunc->name, "wmain" ) == 0 ) { sym->attrib &= ~FLAG_LANGUAGES; // Turn off any language flags sym->attrib |= LANG_WATCALL; // Turn on __watcall calling convention for main } SymReplace( sym, CurFuncHandle ); }
static void FuncDefn( SYMPTR sym ) { SYM_NAMEPTR sym_name; size_t sym_len; TYPEPTR typ; /* duplicate name in near space */ sym_name = SymName( sym, CurFuncHandle ); sym_len = strlen( sym_name ) + 1; sym->name = CMemAlloc( sym_len ); memcpy( sym->name, sym_name, sym_len ); if( sym->flags & SYM_DEFINED ) { CErr2p( ERR_SYM_ALREADY_DEFINED, sym->name ); } typ = sym->sym_type->object; /* get return type */ SKIP_TYPEDEFS( typ ); if( typ->decl_type != TYPE_VOID ) { if( TypeSize( typ ) == 0 ) { CErr2p( ERR_INCOMPLETE_TYPE, sym_name ); } } sym->flags |= SYM_DEFINED /* | SYM_REFERENCED */; if( (GenSwitches & NO_OPTIMIZATION) == 0 ) { sym->flags |= SYM_OK_TO_RECURSE; } if( sym->attribs.stg_class == SC_EXTERN || sym->attribs.stg_class == SC_FORWARD ) { sym->attribs.stg_class = SC_NONE; /* indicate exported function */ } CompFlags.external_defn_found = 1; if( Toggles & TOGGLE_CHECK_STACK ) sym->flags |= SYM_CHECK_STACK; if( !CompFlags.zu_switch_used ) { if( (sym->mods & FLAG_INTERRUPT) == FLAG_INTERRUPT ) { /* interrupt function */ TargetSwitches |= FLOATING_SS; /* force -zu switch on */ } else { TargetSwitches &= ~FLOATING_SS; /* turn it back off */ } } if( CMPLIT( CurFunc->name, "main" ) == 0 || CMPLIT( CurFunc->name, "wmain" ) == 0 ) { sym->mods &= ~MASK_LANGUAGES; // Turn off any language flags sym->mods |= LANG_WATCALL; // Turn on __watcall calling convention for main } SymReplace( sym, CurFuncHandle ); }
FULL_CHAR *FullSymName(OBJECT x, FULL_CHAR *str) { OBJECT stack[20]; int i; static FULL_CHAR buff[MAX_BUFF], *sname; if( x == nilobj ) return AsciiToFull("<nilobj>"); assert( enclosing(x) != nilobj, "FullSymName: enclosing(x) == nilobj!" ); for( i = 0; enclosing(x) != nilobj && i < 20; i++ ) { stack[i] = x; x = enclosing(x); } StringCopy(buff, STR_EMPTY); for( i--; i > 0; i-- ) { sname = SymName(stack[i]); if( StringLength(sname)+StringLength(str)+StringLength(buff) >= MAX_BUFF ) Error(29, 8, "full name of symbol is too long", FATAL, &fpos(x)); StringCat(buff, sname); StringCat(buff, str); } sname = SymName(stack[0]); if( StringLength(sname) + StringLength(buff) >= MAX_BUFF ) Error(29, 9, "full name of symbol is too long", FATAL, &fpos(x)); StringCat(buff, sname); return buff; } /* end FullSymName */
static bool findLabel( label_list labels, char *label_name ) { //************************************************************ label_list curr_label; curr_label = labels; while( curr_label ) { if( strcmp( SymName( curr_label->sym ), label_name ) == 0 ) { return( TRUE ); } curr_label = curr_label->next; } return( FALSE ); }
void FlushInners(OBJECT inners, OBJECT hd) { OBJECT y, z, tmp, dest_index; ifdebug(DGF, D, OBJECT link; fprintf(stderr, "dgf: [ FlushInners("); for( link = Down(inners); link != inners; link = NextDown(link) ) { Child(y, link); fprintf(stderr, " %s", Image(type(y))); switch( type(y) ) { case DEAD: break; case RECEIVING: case UNATTACHED: if( Down(y) != y ) /* bug fix (was assert before) */ { assert( Down(y) != y, "FlushInners: UNATTACHED!"); Child(z, Down(y)); fprintf(stderr, " %s", SymName(actual(z))); } break; case PRECEDES: break; case GALL_PREC: break; default: break; } } fprintf(stderr, ")"); debug0(DGF, D, ""); ) /* check for root galley case */ if( hd != nilobj )
static void doStackLabel( sym_handle sym, owl_sym_type type, owl_sym_linkage linkage ) { //************************************************************************************** label_list new_label; new_label = MemAlloc( sizeof( struct asm_label ) ); new_label->section = CurrentSection; new_label->sym_name = SymName( sym ); new_label->sym_type = type; new_label->sym_linkage = linkage; new_label->sym_hdl = SymObjHandle( sym ); new_label->is_numeric = 0; new_label->next = labelList; labelList = new_label; }
OBJECT SearchGalley(OBJECT start, OBJECT sym, BOOLEAN forwards, BOOLEAN subgalleys, BOOLEAN closures, BOOLEAN input) { OBJECT y, res, z, zlink, link; debug5(DGA, DD, "[ SearchGalley(start, %s, %s, %s, %s, %s)", SymName(sym), forwards ? "fwd" : "back", subgalleys ? "subgalleys" : "nosubgalleys", closures ? "closures" : "noclosures", input ? "input" : "noinput"); assert( type(start) == LINK || type(start) == HEAD, "SearchGalley: start!" ); link = forwards ? NextDown(start) : PrevDown(start); res = nilobj; while( res == nilobj && type(link) != HEAD ) { Child(y, link); switch( type(y) ) { case UNATTACHED: case RECEIVING: debug1(DGA, DD, " examining %s", EchoIndex(y)); if( subgalleys ) for( zlink = Down(y); zlink!=y && res==nilobj; zlink=NextDown(zlink) ) { Child(z, zlink); res = SearchGalley(z, sym, TRUE, TRUE, TRUE, input); } if( res == nilobj && input && type(y) == RECEIVING && actual(actual(y)) == InputSym ) res = y; break; case RECEPTIVE: debug1(DGA, DD, " examining %s", EchoIndex(y)); if( closures && type(actual(y)) == CLOSURE && SearchUses(actual(actual(y)), sym) ) res = y; else if( input && actual(actual(y)) == InputSym ) res = y; break; default: break; } link = forwards ? NextDown(link) : PrevDown(link); } debug1(DGA, DD, "] SearchGalley returning %s", EchoIndex(res)); return res; } /* end SearchGalley */
void DebugScope(void) { int i; if( suppress_scope ) { debug0(DST, D, "suppressed"); } else for( i = 0; i < scope_top; i++ ) { debug6(DST, D, "%s %s%s%s%s%s", i == scope_top - 1 ? "->" : " ", SymName(scope[i]), npars_only[i] ? " npars_only" : "", vis_only[i] ? " vis_only" : "", body_ok[i] ? " body_ok" : "", i == scope_top - 1 && suppress_visible ? " suppress_visible" : ""); } } /* end DebugScope */
extern bool ObjLabelDefined( sym_handle sym ) { //********************************************* enum sym_state state; char *sym_name; // Check if it's been emitted by us if( sym && SymLocationKnown( sym ) ) return( TRUE ); // See if it's defined outside sym_name = SymName( sym ); state = AsmQueryState( AsmQuerySymbol( sym_name ) ); if( state != SYM_UNDEFINED ) { return( TRUE ); } // Still need to check the labelList if( findLabel( labelList, sym_name ) ) return( TRUE ); return( FALSE ); }
/* Check parameters of function that were called before a prototype was seen */ extern void ChkCallParms( void ) { call_list *nextcall; call_list *next; for( nextcall = CallNodeList; nextcall != NULL; nextcall = next ) { TREEPTR callnode; TREEPTR callsite; SYM_ENTRY sym; TYPEPTR typ; next = nextcall->next; callnode = nextcall->callnode; if( callnode != NULL ) { callsite = callnode->left; // point to OPR_FUNCNAME node SymGet( &sym, callsite->op.u2.sym_handle ); typ = sym.sym_type; SKIP_TYPEDEFS( typ ); if( (sym.flags & SYM_TEMP) == 0 ) SetDiagSymbol( &sym, callsite->op.u2.sym_handle ); SetErrLoc( &nextcall->src_loc ); if( typ->u.fn.parms != NULL ) { CompareParms( typ->u.fn.parms, callnode->right, ParmsToBeReversed( sym.mods, NULL ) ); } else { // Unprototyped function called. Note that for indirect calls, there // is no symbol associated with the function and diagnostic information // is hence limited. if( sym.flags & SYM_TEMP ) { CWarn1( WARN_NONPROTO_FUNC_CALLED_INDIRECT, ERR_NONPROTO_FUNC_CALLED_INDIRECT ); } else { CWarn2p( WARN_NONPROTO_FUNC_CALLED, ERR_NONPROTO_FUNC_CALLED, SymName( &sym, callsite->op.u2.sym_handle ) ); } } InitErrLoc(); if( (sym.flags & SYM_TEMP) == 0 ) { SetDiagPop(); } } CMemFree( nextcall ); } }
OBJECT SearchEnv(OBJECT env, OBJECT sym) { OBJECT link, y; debug2(DCE, DD, "[ SearchEnv(%s, %s)", EchoObject(env), SymName(sym)); for(;;) { debug1(DCE, DDD, " searching env %s", EchoObject(env)); assert( env != nilobj && type(env) == ENV, "SearchEnv: env!" ); if( Down(env) == env ) { debug0(DCE, DD, "] SearchEnv returning <nilobj>"); return nilobj; } Child(y, Down(env)); assert( type(y) == CLOSURE, "SearchEnv: type(y) != CLOSURE!" ); if( actual(y) == sym ) { debug1(DCE, DD, "] SearchEnv returning %s", EchoObject(y)); return y; } assert( LastDown(y) != y, "SearchEnv: LastDown(y) == y!" ); link = LastDown(env) != Down(env) ? LastDown(env) : LastDown(y); Child(env, link); } } /* end SearchEnv */
bool ObjLabelDefined( sym_handle sym ) { //************************************** owl_sym_linkage linkage; label_list curr_label; char *sym_name; linkage = OWLTellSymbolLinkage( OwlFile, SymObjHandle( sym ) ); if( linkage != OWL_SYM_UNDEFINED ) { return( TRUE ); } // Still need the check the labelList curr_label = labelList; sym_name = SymName( sym ); while( curr_label ) { if( (!curr_label->is_numeric) && strcmp( curr_label->sym_name, sym_name ) == 0 ) { return( TRUE ); } curr_label = curr_label->next; } return( FALSE ); }
void InsertAlternativeName(FULL_CHAR *str, OBJECT s, FILE_POS *xfpos) { register int sum, rlen; register unsigned char *x; int len; OBJECT entry, link, plink, p, q; debug3(DST, DD, "InsertAlternativeName(%s, %s, %s)", str, SymName(s), EchoFilePos(xfpos)); len = StringLength(str); hash(str, len, sum); ifdebug(DST, D, sym_spread[sum]++; sym_count++); entry = (OBJECT) &symtab[sum]; for( plink = Down(entry); plink != entry; plink = NextDown(plink) ) { Child(p, plink); if( length(p) == len && StringEqual(str, string(p)) ) { for( link = Down(p); link != p; link = NextDown(link) ) { Child(q, link); if( enclosing(s) == enclosing(q) ) { Error(29, 12, "symbol name %s previously defined at%s", WARN, &fpos(s), str, EchoFilePos(&fpos(q)) ); break; } } goto wrapup; } } /* need a new OBJECT as well as s */ NewWord(p, WORD, len, xfpos); length(p) = len; StringCopy(string(p), str); Link(entry, p); wrapup: Link(p, s); /* not for copies if( enclosing(s) != nilobj ) Link(enclosing(s), s); */ debug0(DST, DD, "InsertAlternativeName returning."); } /* end InsertAlternativeName */