static void declareAuto( // DECLARE AN AUTO SYMBOL SYMBOL sym ) // - symbol to be declared { CGAutoDecl( (cg_sym_handle)sym, CgTypeSym( sym ) ); if( SymRequiresDtoring( sym ) ) { SymScope( sym )->u.s.dtor_reqd = true; } }
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 VfnAncestralWalk( // WALK ANCESTRAL VIRTUAL FUNCTIONS SYMBOL sym, // - a virtual function void (*rtn)( // - routine called for self, ancestors SYMBOL orig, // - - original virtual function SYMBOL vfun, // - - self or ancestor void *data ), // - - data passed void *data ) // - data passed to routine { struct walk_data wdata; // - internal data for walker wdata.vfun = sym; wdata.data = data; wdata.rtn = rtn; ScopeWalkAncestry( SymScope( sym ), &classVisit, &wdata ); }
back_handle FEBack( // GET BACK HANDLE FOR A SYMBOL SYMBOL sym ) // - the symbol { SCOPE scope; // - scope for symbol SYMBOL check_sym; // - SYMBOL temp void* cg_handle; // - handle for symbol #ifndef NDEBUG SYMBOL orig // - original symbol = sym; #endif check_sym = SymIsAnonymous( sym ); if( check_sym != NULL ) { sym = check_sym; } if( sym->flag2 & SF2_CG_HANDLE ) { cg_handle = sym->locn->u.cg_handle; } else { cg_handle = BENewBack( (cg_sym_handle)sym ); if( NULL != cg_handle ) { SYM_TOKEN_LOCN* locn = SymbolLocnAlloc( &sym->locn ); locn->u.cg_handle = cg_handle; scope = SymScope( sym ); if( scope != NULL ) { switch( scope->id ) { case SCOPE_CLASS : cgBackStatHandleAdd( sym ); break; case SCOPE_FUNCTION : case SCOPE_BLOCK : if( SymIsStaticData( sym ) ) { cgBackStatHandleAdd( sym ); } break; } } sym->flag2 &= ~SF2_HDL_MASK; sym->flag2 |= SF2_CG_HANDLE; } } #ifndef NDEBUG if( PragDbgToggle.auxinfo ) { printf( "FEBack( %p ) -> bh[%p]\n", orig, cg_handle ); } #endif return cg_handle; }
void DgInitBegin( // START INITIALIZATION OF SYMBOL SYMBOL sym ) // - the symbol { CGFILE_GEN *gen; // - generation data ins_init_beg.value.pvalue = sym; gen = getGenData(); flags.init_data_beg = TRUE; flags.init_data_end = FALSE; gen->init_sym = sym; if( sym->id == SC_STATIC && ScopeId( SymScope( sym ) ) != SCOPE_FILE ) { emitDataCGFILE = &codeCGFILE; } else { gen->emit_init_beg = TRUE; gen->emit_init_end = FALSE; } }
static void formatScopedSym( SYMBOL sym, VBUF *pvbuf, FMT_CONTROL control ) /*************************************************************************/ { VBUF prefix; boolean ctordtor; VbufInit( &prefix ); if( sym->name == NULL ) { ctordtor = fmtSymName( sym, NULL, &prefix, pvbuf, control ); } else { ctordtor = fmtSymName( sym, sym->name->name, &prefix, pvbuf, control ); } if( !SymIsAnonymous( sym ) ) { fmtSymScope( SymScope( sym ), pvbuf, TRUE ); } if( !ctordtor ) { VbufConcVbuf( pvbuf, &prefix ); } VbufFree( &prefix ); }
static TYPE getThisBaseType( SYMBOL sym ) { SCOPE scope; // - scope for symbol TYPE class_type; // - type from function's class scope TYPE base; // - return: NULL or TYPE of "this" for symbol base = NULL; if( sym != NULL ) { scope = ScopeNearestNonTemplate( SymScope( sym ) ); if( scope != NULL ) { class_type = ScopeClass( scope ); if( class_type != NULL ) { if( sym->id != SC_STATIC ) { base = class_type; } } } } return( base ); }
static char *formatScopedSym( SYMBOL sym, VBUF *pvbuf, FMT_CONTROL control ) /**************************************************************************/ { VBUF prefix; bool ctordtor; VbufInit( &prefix ); if( sym->name == NULL ) { ctordtor = fmtSymName( sym, NULL, &prefix, pvbuf, control ); } else { ctordtor = fmtSymName( sym, sym->name->name, &prefix, pvbuf, control ); } if( !SymIsAnonymous( sym ) ) { fmtSymScope( SymScope( sym ), pvbuf, true ); } if( !ctordtor ) { VbufConcVbuf( pvbuf, &prefix ); } VbufFree( &prefix ); return( VbufString( pvbuf ) ); }
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 ); }
static void verifyFileScopeSym( SYMBOL sym ) { if( ! ScopeType( SymScope( sym ), SCOPE_FILE ) ) { CFatal( "linkage symbol is not from file-scope" ); } }
boolean RunTimeIsThrow( // TEST IF FUNCTION IS A C++ THROW SYMBOL func ) // - function symbol { return GetInternalScope() == SymScope( func ) && ( func->flag & SF_IS_THROW ) != 0; }