fe_seg_id CgSegIdData( SYMBOL sym, SEGID_CONTROL control ) /********************************************************/ { fe_seg_id id; type_flag flags; if( SymIsAutomatic( sym ) ) { id = cgSegIdAuto( sym ); } else if( SymIsFunction( sym ) ) { id = CgSegIdFunction( sym ); } else { id = sym->segid; if( id == SEG_NULL ) { TypeGetActualFlags( sym->sym_type, &flags ); if( flags & TF1_THREAD ) { id = cgSegIdThread( sym, flags ); } else if( flags & TF1_BASED ) { id = cgSegIdBased( sym, flags ); #if _CPU == _AXP || COMP_CFG_COFF == 1 } else if( SymIsComdatData( sym ) ) { id = SegmentAddComdatData( sym, control ); #endif } else { id = cgSegIdVariable( sym, flags, control ); } sym->segid = id; } SegmentMarkUsed( id ); } return( id ); }
static SYMBOL inlineSymbol( // CREATE TRANSLATION SYMBOL IF REQ'D SYMBOL sym ) // - original symbol { SYMBOL old; // - same as "sym" FN_CTL* fctl; // - current file control fctl = FnCtlTop(); if( sym == fctl->this_sym ) { return( sym ); } if( sym == fctl->cdtor_sym ) { return( sym ); } if( CgBackInlinedDepth() > 0 && ! SymIsFunction( sym ) && ! SymIsStaticData( sym ) ) { old = sym; sym = push_inline_sym( old ); SymTransPush( old, sym ); // code used to only have SymIsCatchAlias so we // make sure SymIsAlias includes SymIsCatchAlias DbgAssert( ! SymIsCatchAlias( sym ) || ( SymIsCatchAlias( sym ) && SymIsAlias( sym ) ) ); if( SymIsAlias( sym ) || SymIsAnonymousMember( sym ) ) { if( SymIsAutomatic( sym ) ) { sym->u.alias = SymTrans( sym->u.alias ); } } } return( sym ); }
static SYMBOL getSymInScope( // GET A SYMBOL IN A SCOPE SCOPE scope, // - the scope SYMBOL orig ) // - original symbol { SEARCH_RESULT *result; // - search result for symbol SYMBOL sym; // - the symbol arg_list *alist; // - arguments for function NAME name; // - symbol name name = orig->name->name; alist = SymFuncArgList( orig ); if( name == CppConversionName() ) { result = ScopeFindScopedMemberConversion( scope , scope , SymFuncReturnType( orig ) , alist->qualifier ); if( result == NULL ) { sym = NULL; } else { sym = result->sym; ScopeFreeResult( result ); if( sym != NULL ) { if( SymScope( sym ) != scope ) { sym = NULL; } } } } else { result = ScopeContainsMember( scope, name ); if( result == NULL ) { sym = NULL; } else { sym = result->sym_name->name_syms; // we may have found a type-name, so check for NULL if( sym != NULL && SymIsFunction( sym ) ) { switch( FuncOverloaded( &sym , result , sym , alist , NULL ) ) { case FNOV_NONAMBIGUOUS : break; default : sym = NULL; break; } } else { sym = NULL; } ScopeFreeResult( result ); } } return( sym ); }
void DgPtrSymOff( // GENERATE POINTER FOR A SYMBOL + OFFSET SYMBOL sym, // - the symbol target_size_t offset ) // - the offset { if( sym == NULL || SymIsFunction( sym ) ) { DbgVerify( offset == 0, "DgPtrSymOffset -- function with offset <> 0" ); dataGenPtrSym( NULL, offset, TY_CODE_PTR ); } else { dataGenPtrSym( sym, offset, TY_POINTER ); } }
// 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 bool fmtSymName( SYMBOL sym, NAME name, VBUF *pvprefix, VBUF *pvbuf, FMT_CONTROL control ) /***********************************************************************************************/ // returns true if sym is CTOR/DTOR so that the caller drop the return type { VBUF prefix, suffix, op_name; CGOP oper; bool ctordtor = false; if( CppLookupOperatorName( name, &oper ) ) { switch( oper ) { case CO_CONVERT: if( sym == NULL ) { VbufConcStrRev( pvbuf, operatorSuffix ); VbufConcStrRev( pvbuf, operatorUnknown ); } else { fmtSymOpName( sym, &op_name ); fmtSymFunction( sym, &prefix, &suffix, (FormatTypeDefault & ~FF_USE_VOID) | FF_DROP_RETURN ); VbufConcVbufRev( pvbuf, &suffix ); VbufConcVbuf( pvbuf, &op_name ); VbufConcStrRev( pvbuf, operatorPrefix ); VbufConcVbufRev( pvbuf, &prefix ); VbufFree( &op_name ); VbufFree( &prefix ); VbufFree( &suffix ); } break; case CO_CTOR: if( sym == NULL ) { VbufConcStrRev( pvbuf, constructorName ); } else { name = SimpleTypeName( ScopeClass( SymScope( sym ) ) ); ctordtor = true; fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault ); VbufConcVbufRev( pvbuf, &suffix ); if( name != NULL ) { VbufConcStrRev( pvbuf, NameStr( name ) ); } VbufConcVbufRev( pvprefix, &prefix ); VbufFree( &prefix ); VbufFree( &suffix ); } break; case CO_DTOR: if( sym == NULL ) { VbufConcStrRev( pvbuf, destructorName ); } else { name = SimpleTypeName( ScopeClass( SymScope( sym ) ) ); ctordtor = true; fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault ); VbufConcVbufRev( pvbuf, &suffix ); if( name != NULL ) { VbufConcStrRev( pvbuf, NameStr( name ) ); } VbufConcStrRev( pvbuf, dtorPrefix ); VbufConcVbufRev( pvprefix, &prefix ); VbufFree( &prefix ); VbufFree( &suffix ); } break; default: if( sym == NULL ) { VbufConcStrRev( pvbuf, fmtSymCgop( oper ) ); VbufConcStrRev( pvbuf, operatorPrefix ); } else { fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault | control ); VbufConcVbufRev( pvbuf, &suffix ); VbufConcStrRev( pvbuf, fmtSymCgop( oper ) ); VbufConcStrRev( pvbuf, operatorPrefix ); VbufConcVbufRev( pvprefix, &prefix ); VbufFree( &prefix ); VbufFree( &suffix ); } break; } } else if( sym != NULL ) { if( SymIsFunction( sym ) ) { fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault | control ); } else if( !SymIsTypedef( sym ) ) { FormatType( sym->sym_type, &prefix, &suffix ); } else { VbufInit( &prefix ); VbufInit( &suffix ); } VbufConcVbufRev( pvbuf, &suffix ); if( name == NULL ) { VbufConcStrRev( pvbuf, nullSymname ); } else { VbufConcStrRev( pvbuf, NameStr( name ) ); } VbufConcVbufRev( pvprefix, &prefix ); VbufFree( &prefix ); VbufFree( &suffix ); } else if( name != NULL ) { VbufConcStrRev( pvbuf, NameStr( name ) ); } else { VbufConcStrRev( pvbuf, nullSymname ); } return( ctordtor ); }