void DbgRememberScope( // REMEMBER A NEWLY-DEFINED SCOPE SCOPE new_scope ) // - scope { SCOPE_DEFN *new_defn; new_defn = RingAlloc( &scopes, sizeof( SCOPE_DEFN ) ); new_defn->defn = new_scope; }
static void readExtrefs( void ) { SYMBOL sym; unsigned len; PRAG_EXT_REF *entry; RingFree( &pragmaExtrefs ); while( (sym = SymbolPCHRead()) != NULL ) { entry = RingAlloc( &pragmaExtrefs, offsetof( PRAG_EXT_REF, name ) + 1 ); entry->symbol = sym; entry->name[0] = '\0'; } while( (len = PCHReadUInt()) != 0 ) { entry = RingAlloc( &pragmaExtrefs, offsetof( PRAG_EXT_REF, name ) + len + 1 ); PCHRead( entry->name, len + 1 ); entry->symbol = NULL; } }
// forms: #pragma extref( symbol [, ...] ) // #pragma extref( "name" [, ...] ) // // causes a external reference to be emitted for the symbol or "name" // static void parseExtRef( // PARSE SYMBOL NAME void ) { PRAG_EXT_REF *entry; if( CurToken == T_STRING ) { entry = RingAlloc( &pragmaExtrefs, offsetof( PRAG_EXT_REF, name ) + TokenLen + 1 ); memcpy( entry->name, Buffer, TokenLen + 1 ); entry->symbol = NULL; } else if( IS_ID_OR_KEYWORD( CurToken ) ) { SEARCH_RESULT* result; NAME name = NameCreateLen( Buffer, TokenLen ); result = ScopeFindNaked( GetCurrScope(), name ); if( result == NULL ) { CErr2p( ERR_PRAG_EXTREF_NONE, Buffer ); } else { SYMBOL_NAME sname = result->sym_name; SYMBOL sym = sname->name_syms; ScopeFreeResult( result ); if( sym == NULL ) { CErr2p( ERR_PRAG_EXTREF_BAD, Buffer ); } else if( SymIsFunction( sym ) ) { if( IsOverloadedFunc( sym ) ) { CErr2p( ERR_PRAG_EXTREF_OVERLOADED, sym ); sym = NULL; } } else if( SymIsData( sym ) ) { // no checks now } else { CErr2p( ERR_PRAG_EXTREF_BAD, sym ); sym = NULL; } if( sym != NULL ) { entry = RingAlloc( &pragmaExtrefs, offsetof( PRAG_EXT_REF, name ) + 1 ); entry->symbol = sym; entry->name[0] = '\0'; } } } }
static void macroAllocSegment( // ALLOCATE MACRO SEGMENT unsigned minimum ) // - minimum size req'd { MACRO_SEG_LIST *macroSegment; if( minimum > MAC_SEGMENT_LIMIT ) { CErr1( ERR_OUT_OF_MACRO_MEMORY ); CSuicide(); } macroSegment = RingAlloc( ¯oSegmentList, sizeof( MACRO_SEG_LIST ) ); MacroOffset = macroSegment->segment; macroSegmentLimit = MAC_SEGMENT_LIMIT; ExtraRptIncrementCtr( macro_segments ); }
static PC_SEGMENT *segmentAlloc( // SEGMENT: ALLOCATE NEW SEGMENT const char *seg_name, // - segment name const char *class_name, // - segment class name fe_seg_id seg_id, // - segment id (if not SEG_NULL) unsigned attrs, // - segment attributes unsigned control ) // - control mask { PC_SEGMENT *curr; // - segment pointer size_t size; // - size of segment name #if _INTEL_CPU && COMP_CFG_COFF == 0 //alpha permits segments defined anywhere and we need it for comdat data //ditto for COFF DbgVerify( ! flags.in_back_end || ( attrs & PRIVATE ) || ( control & SA_DEFINE_ANYTIME ) , "segmentAlloc -- defining in back end" ); #endif size = strlen( seg_name ); curr = RingAlloc( &seg_list, sizeof( PC_SEGMENT ) + size ); curr->sibling = curr; stvcpy( curr->name, seg_name, size ); curr->offset = 0; curr->dgroup = (( control & SA_IN_DGROUP ) != 0 ); curr->lab_gened = FALSE; if( class_name != NULL ) { curr->class_name = strpermsave( class_name ); } else { curr->class_name = NULL; } curr->used = FALSE; curr->module_prefix = (( control & SA_MODULE_PREFIX ) != 0 ); curr->fixed_alignment = FALSE; curr->cg_defed = FALSE; curr->has_data = FALSE; curr->only_strings = FALSE; curr->label = NULL; curr->attrs = attrs; #if _INTEL_CPU HW_CAsgn( curr->binding, HW_EMPTY ); #endif if( seg_id == SEG_NULL ) { seg_id = ++seg_max; checkSegmentOverflow(); } else { if( seg_id > seg_max ) { seg_max = seg_id; checkSegmentOverflow(); } } curr->seg_id = seg_id; switch( seg_id ) { case SEG_PROF_BEG: case SEG_PROF_REF: case SEG_PROF_END: // we don't want padding introduced curr->align = TARGET_LONG; // we don't want alignment changed either curr->fixed_alignment = TRUE; break; case SEG_INIT_BEG: case SEG_INIT_REF: case SEG_INIT_END: case SEG_FINI_BEG: case SEG_FINI_REF: case SEG_FINI_END: // we don't want padding introduced #if _INTEL_CPU curr->align = TARGET_SHORT; #elif _CPU == _AXP curr->align = TARGET_POINTER; #else #error no alignment set #endif // we don't want alignment changed either curr->fixed_alignment = TRUE; break; default: curr->align = TARGET_CHAR; if( flags.in_back_end ) { segmentCgDefine( curr ); } break; } return( curr ); }