void CgFrontScopeCall( // GENERATE IC_SCOPE_CALL, IF REQ'D SYMBOL fun, // - function called SYMBOL dtor, // - dtor, when function is ctor DTOR_KIND kind ) // - kind of dtoring { boolean keep_scope; // - TRUE ==> keep the current scope keep_scope = FALSE; if( dtor != NULL ) { switch( kind ) { case DTORING_SCOPE : CgFrontCodePtr( IC_SCOPE_CALL_BDTOR, dtor ); keep_scope = TRUE; break; case DTORING_TEMP : CgFrontCodePtr( IC_SCOPE_CALL_TDTOR, dtor ); break; case DTORING_COMPONENT : CgFrontCodePtr( IC_SCOPE_CALL_CDTOR, dtor ); keep_scope = TRUE; break; DbgDefault( "CgFrontScopeCall -- bad DTOR_KIND" ); } } if( fun != NULL && ( fun->flag & SF_NO_LONGJUMP ) ) { fun = NULL; } if( fun != NULL || dtor != NULL ) { CgFrontCodePtr( IC_SCOPE_CALL_FUN, fun ); } if( keep_scope ) { ScopeKeep( GetCurrScope() ); } }
void CgExprDtored( // DTOR CG EXPRESSION cg_name expr, // - expression cg_type type, // - expression type DGRP_FLAGS pop_type, // - type of popping destruction FN_CTL* fctl ) // - function control { #if 0 cg_type type; // - expression type switch( CgExprStackSize() ) { case 0 : break; case 1 : { boolean temp_dtoring = fctl->temp_dtoring; SYMBOL temp = getExprTempSym( &type, fctl, pop_type ); if( temp_dtoring ) { if( fctl->ctor_test ) { pop_type |= DGRP_CTOR; } CgDestructExprTemps( pop_type, fctl ); if( NULL != temp ) { CgExprPush( CgFetchSym( temp ), type ); } } } break; DbgDefault( "CgExprDtored -- too many temps" ); } #else SYMBOL temp; // - NULL or copied temp DbgVerify( 0 == CgExprStackSize(), "CgExprDtored -- more than one expr" ); if( expr != NULL ) { if( pop_type & DGRP_DONE ) { CGDone( expr ); temp = NULL; } else if( pop_type & DGRP_TRASH ) { CGTrash( expr ); temp = NULL; } else if( fctl->temp_dtoring ) { temp = CgVarTempTyped( type ); CGDone( CGLVAssign( CgSymbol( temp ), expr, type ) ); } else { CgExprPush( expr, type ); temp = NULL; } if( fctl->temp_dtoring ) { fctl->temp_dtoring = FALSE; if( fctl->ctor_test ) { pop_type |= DGRP_CTOR; } CgDestructExprTemps( pop_type, fctl ); if( NULL != temp ) { CgExprPush( CgFetchSym( temp ), type ); } } } #endif }
unsigned ThrowCnvInit( // THROW CONVERSIONS: INITIALIZE THROW_CNV_CTL *ctl, // - control area TYPE type ) // - type thrown { type_flag not_used; // - not used THROBJ thr_obj; // - type of throw object ctl->carver = CarveCreate( sizeof( THROW_CNV ), 8 ); ctl->hdr = NULL; ctl->cur = NULL; type = TypeCanonicalThr( type ); ctl->error_occurred = false; thr_obj = ThrowCategory( type ); if( thr_obj == THROBJ_REFERENCE ) { makeThrowCnvNoAcc( ctl, type, 0 ); } else { makeThrowCnv( ctl, type, 0 ); } switch( thr_obj ) { case THROBJ_VOID_STAR : case THROBJ_ANYTHING : case THROBJ_SCALAR : break; case THROBJ_PTR_SCALAR : makeCnvVoidStar( ctl ); break; case THROBJ_REFERENCE : type = TypeReference( type ); if( NULL != StructType( type ) ) { throwClassCnvs( type, ctl ); } else { type = TypePointedAt( type, ¬_used ); if( type != NULL ) { type = StructType( type ); if( type != NULL ) { throwClassPtrCnvs( type, ctl ); } makeCnvVoidStar( ctl ); } } break; case THROBJ_CLASS : case THROBJ_CLASS_VIRT : throwClassCnvs( type, ctl ); break; case THROBJ_PTR_CLASS : throwClassPtrCnvs( type, ctl ); makeCnvVoidStar( ctl ); break; case THROBJ_PTR_FUN : if( CgCodePtrSize() <= CgDataPtrSize() ) { makeCnvVoidStar( ctl ); } break; DbgDefault( "EXCEPT -- illegal throw object" ); } return RingCount( ctl->hdr ); }
RKD RkdForTypeId( // GET RKD FOR TYPE ID type_id id ) // - id { RKD retn; // - RKD for id switch( id ) { case TYP_ERROR : retn = RKD_ERROR; break; case TYP_BOOL : case TYP_CHAR : case TYP_SCHAR : case TYP_UCHAR : case TYP_WCHAR : case TYP_SSHORT : case TYP_USHORT : case TYP_SINT : case TYP_UINT : case TYP_SLONG : case TYP_ULONG : case TYP_SLONG64 : case TYP_ULONG64 : case TYP_FLOAT : case TYP_DOUBLE : case TYP_LONG_DOUBLE : retn = RKD_ARITH; break; case TYP_ENUM : retn = RKD_ENUM; break; case TYP_POINTER : retn = RKD_POINTER; break; case TYP_CLASS : retn = RKD_CLASS; break; case TYP_FUNCTION : retn = RKD_FUNCTION; break; case TYP_DOT_DOT_DOT : retn = RKD_ELLIPSIS; break; case TYP_VOID : retn = RKD_VOID; break; case TYP_MEMBER_POINTER : retn = RKD_MEMBPTR; break; case TYP_GENERIC : case TYP_TYPENAME : retn = RKD_GENERIC; break; DbgDefault( "invalid RKD detected" ); } return retn; }
static void ideDisplay // DISPLAY USING IDE INTERFACE ( IDEMsgSeverity severity // - message severity , MSG_NUM msgnum // - message number , char* msg // - message , TOKEN_LOCN* msg_locn ) // - message location or NULL { IDECallBacks* cbs; // - pointer to call backs IDEMsgInfo inf; // - message information char *fname; // - file name boolean goes_in_err_file; // - output msg into .err file IdeMsgInit( &inf, severity, msg ); IdeMsgSetMsgNo( &inf, msgnum ); IdeMsgSetHelp( &inf, "wpperrs.hlp", msgnum + 1 ); if( CompFlags.ew_switch_used ) { IdeMsgSetReadable( &inf ); } if( NULL != msg_locn ) { if( msg_locn->src_file != NULL ) { fname = fileName( msg_locn->src_file ); IdeMsgSetSrcFile( &inf, fname ); IdeMsgSetSrcLine( &inf, msg_locn->line ); IdeMsgSetSrcColumn( &inf, msg_locn->column ); } notes_locn = *msg_locn; } goes_in_err_file = FALSE; switch( severity ) { case IDEMSGSEV_WARNING: case IDEMSGSEV_ERROR: case IDEMSGSEV_NOTE: goes_in_err_file = TRUE; break; case IDEMSGSEV_BANNER: case IDEMSGSEV_DEBUG: break; case IDEMSGSEV_NOTE_MSG: if( CompFlags.log_note_msgs ) { goes_in_err_file = TRUE; } break; DbgDefault( "unknown severity" ); } cbs = CompInfo.dll_callbacks; if( goes_in_err_file ) { if( ! ( CompFlags.eq_switch_used && CompFlags.ide_console_output ) ) { (*cbs->PrintWithInfo)( CompInfo.dll_handle, &inf ); } idePrt( CompInfo.dll_handle, &inf ); } else { (*cbs->PrintWithInfo)( CompInfo.dll_handle, &inf ); } }
void CmdLnCtxInfo( // PRINT CONTEXT INFO void ) { CTX_CL* entry; // - current entry VBUF buf; // - buffer VbufInit( &buf ); for( entry = VstkTop( &cmdLnContexts ) ; entry != NULL ; entry = VstkNext( &cmdLnContexts, entry ) ) { VbufRewind( &buf ); switch( entry->base.ctx_type ) { case CTX_CLTYPE_ENV : VbufConcChr( &buf, '@' ); VbufConcStr( &buf, entry->env.var ); break; case CTX_CLTYPE_FC : VbufConcStr( &buf, "batch file of commands, line " ); VbufConcDecimal( &buf, CompInfo.fc_file_line ); break; case CTX_CLTYPE_PGM : VbufConcStr( &buf, "command line" ); break; case CTX_CLTYPE_FILE : VbufConcStr( &buf, SrcFileFullName( entry->file.source ) ); break; DbgDefault( "bad command-line context" ); } if( entry->base.sw_ptr != NULL ) { size_t size; char const * not_used; char const* old = CmdScanAddr(); CmdScanInit( entry->base.sw_ptr ); CmdScanChar(); size = CmdScanOption( ¬_used ) + 1; CmdScanInit( old ); VbufConcStr( &buf, ", switch: " ); for( old = entry->base.sw_ptr; size > 0; ++old, --size ) { VbufConcChr( &buf, *old ); } } InfMsgPtr( INF_SWITCH, VbufString( &buf ) ); } VbufFree( &buf ); }
DT_METHOD DtmDirect( // CONVERT DTOR METHOD TO DIRECT COUNTERPART DT_METHOD dtm ) // - default method { switch( dtm ) { DbgDefault( "DtmDirect -- bad method" ); case DTM_DIRECT : case DTM_DIRECT_SMALL : break; case DTM_TABLE_SMALL : dtm = DTM_DIRECT_SMALL; break; case DTM_DIRECT_TABLE : case DTM_TABLE : dtm = DTM_DIRECT; break; } return dtm; }
CNV_RETN ConversionDiagnose( // DIAGNOSE RETURN FROM A CONVERSION CNV_RETN retn, // - return value: CNV_... PTREE expr, // - current expression CNV_DIAG *diagnosis ) // - diagnosis information { switch( retn ) { case CNV_OK_TRUNC : NodeWarnPtrTrunc( expr ); retn = CNV_OK; break; case CNV_OK_TRUNC_CAST : NodeWarnPtrTruncCast( expr ); retn = CNV_OK; break; case CNV_ERR : PTreeErrorNode( expr ); ConversionDiagnoseInf(); retn = CNV_ERR; break; case CNV_IMPOSSIBLE : retn = conversionErr( expr, diagnosis->msg_impossible ); break; case CNV_AMBIGUOUS : retn = conversionErr( expr, diagnosis->msg_ambiguous ); break; case CNV_PRIVATE : retn = conversionErr( expr, diagnosis->msg_private ); break; case CNV_PROTECTED : retn = conversionErr( expr, diagnosis->msg_protected ); break; case CNV_VIRT_DER : retn = conversionErr( expr, diagnosis->msg_virt_der ); break; case CNV_TRUNC_THIS : ConversionInfDisable(); retn = conversionErr( expr, ERR_THIS_OBJ_MEM_MODEL ); break; case CNV_OK : break; DbgDefault( "ConversionDiagnose: unexpected 'retn' value" ); } return retn; }
static fe_seg_id cgSegIdBased( SYMBOL sym, type_flag flags ) { fe_seg_id id; // - segment id target_offset_t align; // - alignment for symbol target_size_t size; // - size of symbol TYPE base_mod; // - __based modifier size = CgMemorySize( sym->sym_type ); #ifdef _CHECK_SIZE // only defined if needed if( !(flags & TF1_HUGE) ) { if( _CHECK_SIZE( size ) ) { CErr2p( ERR_DATA_TOO_BIG, sym ); return( SEG_NULL ); } } #endif if( SymIsExtern( sym ) ) { // not defined in this compilation unit id = SegmentImport(); } else { switch( flags & TF1_BASED ) { case TF1_BASED_STRING: id = SegmentFindBased( sym->sym_type ); break; case TF1_BASED_SELF: case TF1_BASED_VOID: id = SEG_NULL; break; case TF1_BASED_FETCH: case TF1_BASED_ADD: base_mod = BasedType( sym->sym_type ); id = CgSegIdData( (SYMBOL)base_mod->u.m.base, SI_DEFAULT ); break; DbgDefault( "invalid based cgsegid call" ); } if( id != SEG_NULL ) { align = cgSegIdAlign( sym, flags ); id = SegmentAddSym( sym, id, size, align ); } } return( id ); }
static boolean dtmTabular( // DETERMINE IF METHOD IS TABULAR DT_METHOD method ) // - the method { boolean retn; // - TRUE ==> is tabular switch( method ) { DbgDefault( "dtmTabular -- bad method" ); case DTM_DIRECT : retn = FALSE; break; case DTM_DIRECT_SMALL : case DTM_TABLE_SMALL : case DTM_DIRECT_TABLE : case DTM_TABLE : retn = TRUE; break; } return retn; }
static bool dtmTabular( // DETERMINE IF METHOD IS TABULAR DT_METHOD method ) // - the method { bool retb; // - true ==> is tabular switch( method ) { DbgDefault( "dtmTabular -- bad method" ); case DTM_DIRECT : retb = false; break; case DTM_DIRECT_SMALL : case DTM_TABLE_SMALL : case DTM_DIRECT_TABLE : case DTM_TABLE : retb = true; break; } return( retb ); }
PTREE CopyOptimize // COPY OPTIMIZATION ( PTREE right // - base source operand (function call) , PTREE src // - original source operand , PTREE left // - target operand , PTREE dtor // - NULL or CO_DTOR expression , CALL_OPT opt ) // - type of optimization { PTREE expr; // - resultant expression PTREE parm; // - parameter node to be replaced switch( opt ) { case CALL_OPT_NONE : DbgVerify( 0, "CopyOptimize -- CALL_OPT_NONE" ); break; case CALL_OPT_CTOR : for( parm = right->u.subtree[1] ; 0 == ( parm->flags & PTF_ARG_THIS ) ; parm = parm->u.subtree[0] ) ; expr = doCopyElimination( parm, src, left, dtor ); break; case CALL_OPT_FUN_CALL : for( parm = right->u.subtree[1] ; 0 == ( parm->flags & PTF_ARG_RETURN ) ; parm = parm->u.subtree[0] ) ; expr = doCopyElimination( parm, src, left, dtor ); break; case CALL_OPT_BIN_COPY : expr = doCopySubstitution( &right->u.subtree[0], src, left, dtor ); break; case CALL_OPT_ERR : PTreeErrorNode( left ); NodeFreeDupedExpr( src ); expr = left; break; DbgDefault( "CopyOptimize -- impossible optimization" ); } return expr; }
static bool validateBase( // VALIDATE BASE CLASS OK SCOPE base_scope, // - scope for base class THROW_CNV_CTL *ctl ) // - control area { bool retb; // - true ==> generate conversion SCOPE thr_scope; // - scope for throw retb = false; thr_scope = TypeScope( ctl->src_type ); switch( ScopeDerived( thr_scope, base_scope ) ) { DbgDefault( "validateBase -- impossible derived type" ); case DERIVED_YES : case DERIVED_YES_BUT_VIRTUAL : ctl->offset = ThrowBaseOffset( thr_scope, base_scope ); retb = true; break; case DERIVED_YES_BUT_AMBIGUOUS : case DERIVED_YES_BUT_PRIVATE : case DERIVED_YES_BUT_PROTECTED : break; } return( retb ); }
static void outputCallTriggeredWarning( PTREE expr, SYMBOL sym ) { MSG_NUM msg; char *name; msg = ERR_NULL; name = sym->name->name; if( name == CppSpecialName( SPECIAL_BEGINTHREAD ) ) { msg = WARN_MUST_BE_MULTITHREADED; } else if( name == CppSpecialName( SPECIAL_BEGINTHREADEX ) ) { msg = WARN_MUST_BE_MULTITHREADED; } if( msg != ERR_NULL ) { switch( msg ) { case WARN_MUST_BE_MULTITHREADED: if( !CompFlags.bm_switch_used ) { PTreeErrorExprName( expr, msg, name ); } break; DbgDefault( "unexpected message number" ); } } }
static unsigned typeSigNameSize(// COMPUTE SIZE OF NAME IN TYPE SIGNATURE THROBJ thr ) // - category of object { unsigned size; // - size of mangled name in type signature size = 0; switch( thr ) { case THROBJ_SCALAR : case THROBJ_PTR_FUN : case THROBJ_CLASS : case THROBJ_CLASS_VIRT : size = CgDataPtrSize(); break; case THROBJ_PTR_SCALAR : case THROBJ_PTR_CLASS : case THROBJ_REFERENCE : case THROBJ_VOID_STAR : case THROBJ_ANYTHING : break; DbgDefault( "typeSigNameSize -- bad THROBJ_..." ); } return( size ); }
static SYMBOL makeTemporary( // ALLOCATE A TEMPORARY TYPE type, // - type of temporary boolean storage ) // - allocate storage if needed { SYMBOL sym; // - symbol for temporary char *name; // - name for temporary symbol_class id; // - class for symbol #if 0 if( ( type->id == TYP_POINTER ) && ( type->flag & TF1_REFERENCE ) ) { type = type->of; } #endif sym = SymMakeDummy( type, &name ); switch( tempClass ) { case TEMP_TYPE_EXPR : case TEMP_TYPE_BLOCK : id = SC_AUTO; break; case TEMP_TYPE_STATIC : id = SC_STATIC; break; DbgDefault( "makeTemporary -- bad tempClass" ); } sym->id = id; if( id == SC_STATIC ) { ScopeInsert( GetFileScope(), sym, name ); if( storage ) { CgSegIdData( sym, SI_ALL_ZERO ); DgSymbol( sym ); } } else { ScopeInsert( ScopeForTemps(), sym, name ); } return sym; }
static void macroDefs( void ) { if( TargetSwitches & I_MATH_INLINE ) { DefSwitchMacro( "OM" ); } switch( TargetSwitches & (BIG_DATA|BIG_CODE|CHEAP_POINTER|FLAT_MODEL) ) { case CHEAP_POINTER: DefSwitchMacro( "MS" ); break; case BIG_CODE|CHEAP_POINTER: DefSwitchMacro( "MM" ); break; case BIG_DATA|CHEAP_POINTER: DefSwitchMacro( "MC" ); break; case BIG_CODE|BIG_DATA|CHEAP_POINTER: DefSwitchMacro( "ML" ); break; case BIG_CODE|BIG_DATA: DefSwitchMacro( "MH" ); break; case FLAT_MODEL|CHEAP_POINTER: DefSwitchMacro( "MF" ); break; } if( TargetSwitches & FLOATING_FS ) { DefSwitchMacro( "ZFF" ); } else { DefSwitchMacro( "ZFP" ); } if( TargetSwitches & FLOATING_GS ) { DefSwitchMacro( "ZGF" ); } else { DefSwitchMacro( "ZGP" ); } if( TargetSwitches & FLOATING_DS ) { DefSwitchMacro( "ZDF" ); } else { DefSwitchMacro( "ZDP" ); } if( TargetSwitches & FLOATING_SS ) { DefSwitchMacro( "ZU" ); } if( TargetSwitches & INDEXED_GLOBALS ) { DefSwitchMacro( "XGV" ); } if( TargetSwitches & WINDOWS ) { DefSwitchMacro( "ZW" ); } if( TargetSwitches & SMART_WINDOWS ) { DefSwitchMacro( "ZWS" ); } if( TargetSwitches & NO_CALL_RET_TRANSFORM ) { DefSwitchMacro( "OC" ); } if( TargetSwitches & NEED_STACK_FRAME ) { DefSwitchMacro( "OF" ); } if( GenSwitches & NO_OPTIMIZATION ) { DefSwitchMacro( "OD" ); } if( GenSwitches & RELAX_ALIAS ) { DefSwitchMacro( "OA" ); } if( GenSwitches & BRANCH_PREDICTION ) { DefSwitchMacro( "OB" ); } if( GenSwitches & LOOP_OPTIMIZATION ) { DefSwitchMacro( "OL" ); } if( GenSwitches & INS_SCHEDULING ) { DefSwitchMacro( "OR" ); } if( GenSwitches & FPU_ROUNDING_INLINE ) { DefSwitchMacro( "ZRI" ); } if( GenSwitches & FPU_ROUNDING_OMIT ) { DefSwitchMacro( "ZRO" ); } if( TargetSwitches & GEN_FWAIT_386 ) { DefSwitchMacro( "ZFW" ); } if( CompFlags.signed_char ) { DefSwitchMacro( "J" ); } if( CompFlags.use_pcheaders ) { DefSwitchMacro( "FH" ); } if( CompFlags.no_pch_warnings ) { DefSwitchMacro( "FHQ" ); } if( CompFlags.inline_intrinsics ) { DefSwitchMacro( "OI" ); } if( CompFlags.zu_switch_used ) { DefSwitchMacro( "ZU" ); } if( CompFlags.unique_functions ) { DefSwitchMacro( "OU" ); } #if _CPU == 386 if( CompFlags.register_conventions ) { DefSwitchMacro( "3R" ); } else { DefSwitchMacro( "3S" ); } #endif if( CompFlags.emit_names ) { DefSwitchMacro( "EN" ); } if( CompFlags.save_restore_segregs ) { DefSwitchMacro( "R" ); } if( CompFlags.zc_switch_used ) { DefSwitchMacro( "ZC" ); } if( CompFlags.use_unicode ) { DefSwitchMacro( "ZK" ); } if( CompFlags.sg_switch_used ) { DefSwitchMacro( "SG" ); } if( CompFlags.st_switch_used ) { DefSwitchMacro( "ST" ); } if( CompFlags.bm_switch_used ) { PreDefineStringMacro( "_MT" ); DefSwitchMacro( "BM" ); } if( CompFlags.bd_switch_used ) { DefSwitchMacro( "BD" ); } if( CompFlags.br_switch_used ) { PreDefineStringMacro( "_DLL" ); DefSwitchMacro( "BR" ); } if( CompFlags.bw_switch_used ) { DefSwitchMacro( "BW" ); } if( CompFlags.zm_switch_used ) { DefSwitchMacro( "ZM" ); } if( CompFlags.ep_switch_used ) { DefSwitchMacro( "EP" ); } if( CompFlags.ee_switch_used ) { DefSwitchMacro( "EE" ); } switch( CompInfo.dt_method_speced ) { case DTM_DIRECT : DefSwitchMacro( "XDT" ); DefSwitchMacro( "XD" ); break; case DTM_DIRECT_SMALL : DefSwitchMacro( "XDS" ); break; case DTM_TABLE : DefSwitchMacro( "XS" ); break; case DTM_DIRECT_TABLE : DefSwitchMacro( "XST" ); break; case DTM_TABLE_SMALL : DefSwitchMacro( "XSS" ); break; DbgDefault( "macroDefs -- invalid exception switch" ); } switch( GET_CPU( CpuSwitches ) ) { case CPU_86: DefSwitchMacro( "0" ); break; case CPU_186: DefSwitchMacro( "1" ); break; case CPU_286: DefSwitchMacro( "2" ); break; case CPU_386: DefSwitchMacro( "3" ); break; case CPU_486: DefSwitchMacro( "4" ); break; case CPU_586: DefSwitchMacro( "5" ); break; case CPU_686: DefSwitchMacro( "6" ); break; } switch( GET_FPU_LEVEL( CpuSwitches ) ) { case FPU_NONE: CompFlags.op_switch_used = 0; DefSwitchMacro( "FPC" ); break; case FPU_87: DefSwitchMacro( "FP287" ); defEmu(); break; case FPU_387: DefSwitchMacro( "FP387" ); defEmu(); break; case FPU_586: DefSwitchMacro( "FP5" ); defEmu(); break; case FPU_686: DefSwitchMacro( "FP6" ); defEmu(); break; } if( CompFlags.op_switch_used ) { DefSwitchMacro( "OP" ); } PreDefineStringMacro( "_INTEGRAL_MAX_BITS=64" ); #if _CPU == 386 PreDefineStringMacro( "_STDCALL_SUPPORTED" ); #endif if( CompFlags.oldmacros_enabled ) { #if _CPU == 8086 if( TargetSwitches & WINDOWS ) { PreDefineStringMacro( "SOMLINK=__cdecl" ); PreDefineStringMacro( "SOMDLINK=__far" ); } #else PreDefineStringMacro( "SOMLINK=_Syscall" ); PreDefineStringMacro( "SOMDLINK=_Syscall" ); #endif } }
bool StabGenerate( // GENERATE A STATE TABLE STAB_CTL* sctl ) // - state-table information { STAB_DEFN* defn; // - state-table definition SE* se; // - current state entry SE* state_table; // - the state table segment_id old_seg; // - old segment if( sctl->rw == NULL ) return FALSE; defn = sctl->defn; old_seg = DgSetSegSym( defn->ro ); CgBackGenLabelInternal( defn->ro ); DgOffset( defn->kind ); #if _CPU == _AXP if( defn->kind == DTRG_FUN ) { DgOffset( - CgOffsetRw( 0 ) ); } #endif state_table = defn->state_table; RingIterBeg( state_table, se ) { if( se->base.gen ) { switch( se->base.se_type ) { case DTC_SYM_AUTO : DbgVerify( UNDEF_AREL != se->sym_auto.offset, "cgStateTable -- no offset for SYM_AUTO" ); DgPtrSymCode( se->sym_auto.dtor ); DgOffset( CgOffsetRw( se->sym_auto.offset ) ); padOffsetToPtrSize(); break; case DTC_SYM_STATIC : DgPtrSymCode( se->sym_static.dtor ); DgPtrSymData( se->sym_static.sym ); break; case DTC_TEST_FLAG : cgStateTableCmd( CgCmdTestFlag( se ), 0 ); break; case DTC_TRY : se->try_blk.sym = cgStateTableCmd( CgCmdTry( se ), 0 ); break; case DTC_CATCH : cgStateTableCmd( se->catch_blk.try_blk->try_blk.sym, sizeof( DTOR_CMD_CODE ) ); break; case DTC_FN_EXC : cgStateTableCmd( CgCmdFnExc( se ), 0 ); break; case DTC_SET_SV : if( se != state_table ) { cgStateTableCmd( CgCmdSetSv( se ), 0 ); } break; case DTC_ACTUAL_DBASE : case DTC_ACTUAL_VBASE : case DTC_COMP_VBASE : case DTC_COMP_DBASE : case DTC_COMP_MEMB : cgStateTableCmd( CgCmdComponent( se ), 0 ); break; case DTC_ARRAY_INIT : cgStateTableCmd( CgCmdArrayInit( se ), 0 ); break; case DTC_DLT_1 : cgStateTableCmd( CgCmdDlt1( se ), 0 ); break; case DTC_DLT_2 : cgStateTableCmd( CgCmdDlt2( se ), 0 ); break; case DTC_DLT_1_ARRAY : cgStateTableCmd( CgCmdDlt1Array( se ), 0 ); break; case DTC_DLT_2_ARRAY : cgStateTableCmd( CgCmdDlt2Array( se ), 0 ); break; case DTC_CTOR_TEST : cgStateTableCmd( CgCmdCtorTest( se ), 0 ); break; DbgDefault( "cgStateTable -- impossible" ); } } } RingIterEnd( se ) #if !defined( NDEBUG ) || !defined( _INTEL_CPU ) DgPtrSymCode( NULL ); DgPtrSymData( NULL ); #endif BESetSeg( old_seg ); StabDefnFreeStateTable( defn ); return TRUE; }
void MsgDisplay // DISPLAY A MESSAGE ( IDEMsgSeverity severity // - message severity , MSG_NUM msgnum // - message number , va_list args ) // - substitution arguments { VBUF buffer; // - formatting buffer SYMBOL sym; // - sym requiring location TOKEN_LOCN prt_locn; // - print location TOKEN_LOCN *msg_locn; // - message location CTX context; // - current context void *inf; // - information about context char *inf_prefix; // - prefix for information boolean context_changed; // - TRUE ==> new context from last time context_changed = CtxCurrent( &context, &inf, &inf_prefix ); setMsgLocation( context ); prt_locn = err_locn; ++reserveDepth; VbufInit( &buffer ); sym = msgBuild( msgnum, args, &buffer ); switch( severity ) { case IDEMSGSEV_ERROR : case IDEMSGSEV_WARNING : if( CompFlags.ew_switch_used ) { switch( context ) { case CTX_INIT : case CTX_FINI : case CTX_CMDLN_VALID : case CTX_CG_OPT : case CTX_ENDFILE : if( context_changed ) { fmt_inf_hdr( inf_prefix ); } break; case CTX_CMDLN_ENV : case CTX_CMDLN_PGM : if( context_changed ) { fmt_inf_hdr_switch( inf_prefix, inf ); } break; case CTX_CG_FUNC : case CTX_FUNC_GEN : if( context_changed ) { fmt_inf_hdr_sym( inf_prefix, inf ); } break; case CTX_FORCED_INCS : case CTX_SOURCE : build_file_nesting(); break; DbgDefault( "Unexpected message context" ); } } msg_locn = &prt_locn; break; case IDEMSGSEV_NOTE : case IDEMSGSEV_NOTE_MSG : msg_locn = ¬es_locn; break; default : msg_locn = NULL; break; } ideDisplay( severity , msgnum , VbufString( &buffer ) , msg_locn ); if( context_changed && ! CompFlags.ew_switch_used && ( severity == IDEMSGSEV_ERROR || severity == IDEMSGSEV_WARNING ) && ( context == CTX_SOURCE || context == CTX_FORCED_INCS ) ) { build_file_nesting(); } VbufFree( &buffer ); --reserveDepth; if( NULL != sym ) { notes_locn = sym->locn->tl; MsgDisplayArgs( IDEMSGSEV_NOTE , SymIsFunctionTemplateModel( sym ) ? INF_TEMPLATE_FN_DECL : INF_SYMBOL_DECLARATION , sym , &sym->locn->tl ); } }
void DumpObjectModelEnum( // DUMP OBJECT MODEL: ENUM TYPE type ) // - enum type { SYMBOL sym; // - current symbol TYPE base; // - base type VBUF buffer; // - printing buffer char buf[16]; // - buffer int numb; // - a numeric value const char *name; // - name to be printed bool sign; // - TRUE ==> signed enum unsigned mask; // - used to mask to true size unsigned val; // - value as unsigned CompFlags.log_note_msgs = TRUE; base = TypedefModifierRemoveOnly( type ); sym = base->u.t.sym; VbufInit( &buffer ); VbufConcStr( &buffer, "Object Model for: " ); if( NULL == sym->name->name || NameStr( sym->name->name )[0] == '.' ) { VbufConcStr( &buffer, "anonymous enum type" ); } else { VbufConcStr( &buffer, NameStr( sym->name->name ) ); } switch( TypedefModifierRemove( base->of ) -> id ) { case TYP_CHAR : case TYP_UCHAR : name = "unsigned char"; sign = FALSE; break; case TYP_SCHAR : name = "signed char"; sign = TRUE; break; case TYP_SSHORT : name = "signed short"; sign = TRUE; break; case TYP_USHORT : name = "unsigned short"; sign = FALSE; break; case TYP_SINT : name = "signed int"; sign = TRUE; break; case TYP_UINT : name = "unsigned int"; sign = FALSE; break; case TYP_SLONG : name = "signed long"; sign = TRUE; break; case TYP_ULONG : name = "unsigned long"; sign = FALSE; break; case TYP_SLONG64 : name = "__int64"; sign = TRUE; break; case TYP_ULONG64 : name = "unsigned __int64"; sign = FALSE; break; DbgDefault( "DumpObjectModelEnum -- bad underlying type" ); } VbufConcStr( &buffer, ", base type is " ); VbufConcStr( &buffer, name ); vbufWrite( &buffer ); mask = CgMemorySize( base ); if( mask == sizeof( unsigned ) ) { mask = -1; } else { mask = ( 1 << ( mask * 8 ) ) - 1; } for( ; ; ) { sym = sym->thread; if( ! SymIsEnumeration( sym ) ) break; VbufRewind( &buffer ); VbufConcStr( &buffer, " " ); VbufConcStr( &buffer, NameStr( sym->name->name ) ); VbufConcStr( &buffer, " = " ); numb = sym->u.sval; if( sign && numb < 0 ) { VbufConcChr( &buffer, '-' ); VbufConcDecimal( &buffer, -numb ); } else { VbufConcDecimal( &buffer, numb ); } val = mask & numb; if( val > 10 ) { itoa( val, buf, 16 ); VbufConcStr( &buffer, " /0x" ); VbufConcStr( &buffer, buf ); } vbufWrite( &buffer ); } VbufFree( &buffer ); CompFlags.log_note_msgs = FALSE; }