cgbkcmds.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 736 行 · 第 1/2 页
C
736 行
SE* se ) // - state entry
{
CMD_CTOR_TEST* cmd; // - command
cmd = stateTableCmdAllocVar( carveCMD_CTOR_TEST
, &ringCmdsCtorTest
, 1 + CgbkInfo.size_offset );
cmd->flag_no = se->ctor_test.flag_no;
return cmd->base.sym;
}
#define cgGenerateCmdCode( code ) DGInteger( code, T_UINT_1 )
static boolean cgGenerateCmdBase( // EMIT BASE FOR COMMAND
CMD_BASE* base, // - base for command
uint_8 code ) // - code for command
{
boolean genning; // - TRUE ==> genning entry
if( base->emitted ) {
genning = FALSE;
} else {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "CMD[%x]: ", base->sym );
}
#endif
base->emitted = TRUE;
CgBackGenLabelInternal( base->sym );
#if 1 // this kludge allows old run-time systems to work
switch( code ) {
case DTC_ACTUAL_DBASE :
case DTC_ACTUAL_VBASE :
code = DTC_COMP_DBASE;
break;
}
#endif
cgGenerateCmdCode( code );
genning = TRUE;
}
return genning;
}
static void cgGenerateCmdsSetSv(// EMIT SET_SV COMMANDS
void )
{
CMD_SET_SV* curr; // - current command
RingIterBegSafe( ringCmdsSetSv, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_SET_SV ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_SET_SV state=%d\n"
, curr->state_var );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->state_var );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsTestFlag(// EMIT TEST_FLAG COMMANDS
void )
{
CMD_TEST_FLAG* curr; // - current command
RingIterBegSafe( ringCmdsTestFlag, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_TEST_FLAG ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_TEST_FLAG index=%d true=%d false=%d\n"
, curr->index
, curr->state_var_true
, curr->state_var_false );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->index );
DgOffset( curr->state_var_true );
DgOffset( curr->state_var_false );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsTry( // EMIT TRY COMMANDS
void )
{
CMD_TRY* curr; // - current command
RingIterBegSafe( ringCmdsTry, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_TRY ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_CATCH %x state=%x buf=%x var=%x count="
, DTC_TRY
, curr->state
, curr->offset_jmpbuf
, curr->offset_var );
}
#endif
cgGenerateCmdCode( DTC_CATCH );
DgAlignPad( 2 * sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->state );
DgOffset( curr->offset_jmpbuf );
DgOffset( curr->offset_var );
BeGenTypeSigEnts( curr->sigs );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsFnExc(// EMIT FN_EXC CMDS
void )
{
CMD_FN_EXC* curr; // - current command
RingIterBegSafe( ringCmdsFnExc, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_FN_EXC ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_FN_EXC count=" );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
BeGenTypeSigEnts( curr->sigs );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsComponent(// EMIT COMPONENT CMDS
void )
{
CMD_COMPONENT* curr; // - current command
RingIterBegSafe( ringCmdsComponent, curr ) {
if( cgGenerateCmdBase( &curr->base, curr->cmd_type ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
const char* code;
switch( curr->cmd_type ) {
case DTC_COMP_VBASE : code = "DTC_COMP_VBASE"; break;
case DTC_COMP_DBASE : code = "DTC_COMP_DBASE"; break;
case DTC_ACTUAL_VBASE : code = "DTC_ACTUAL_VBASE"; break;
case DTC_ACTUAL_DBASE : code = "DTC_ACTUAL_DBASE"; break;
case DTC_COMP_MEMB : code = "DTC_COMP_MEMB "; break;
default: code = "*****BAD******"; break;
}
printf( "%s obj-offset=%x var-offset=%x %s\n"
, code
, curr->obj->offset
, curr->offset
, DbgSymNameFull( curr->dtor ) );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->obj->offset );
DgOffset( curr->offset );
DgPtrSymCode( curr->dtor );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsArrayInit( // EMIT ARRAY-INIT CMDS
void )
{
CMD_ARRAY_INIT* curr; // - current command
RingIterBegSafe( ringCmdsArrayInit, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_ARRAY_INIT ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_ARRAY_INIT offset=%x\n"
, curr->reg->offset );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->reg->offset );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsDel1( // EMIT DELETE-1 CMDS
void )
{
CMD_DEL_1* curr; // - current command
RingIterBegSafe( ringCmdsDel1, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_DLT_1 ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_DLT_1 offset=%x %s\n"
, curr->offset
, DbgSymNameFull( curr->op_del ) );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->offset );
DgPtrSymCode( curr->op_del );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsDel1Array( // EMIT DELETE-1-ARRAY CMDS
void )
{
CMD_DEL_1* curr; // - current command
RingIterBegSafe( ringCmdsDel1Array, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_DLT_1_ARRAY ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_DLT_1_ARRAY offset=%x %s\n"
, curr->offset
, DbgSymNameFull( curr->op_del ) );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->offset );
DgPtrSymCode( curr->op_del );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsDel2( // EMIT DELETE-2 CMDS
void )
{
CMD_DEL_2* curr; // - current command
RingIterBegSafe( ringCmdsDel2, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_DLT_2 ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_DLT_2 offset=%x size=%x %s\n"
, curr->offset
, curr->size
, DbgSymNameFull( curr->op_del ) );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->offset );
DgPtrSymCode( curr->op_del );
DgOffset( curr->size );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsDel2Array( // EMIT DELETE-2-ARRAY CMDS
void )
{
CMD_DEL_2* curr; // - current command
RingIterBegSafe( ringCmdsDel2Array, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_DLT_2_ARRAY ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_DLT_2_ARRAY offset=%x size=%x %s\n"
, curr->offset
, curr->size
, DbgSymNameFull( curr->op_del ) );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->offset );
DgPtrSymCode( curr->op_del );
DgOffset( curr->size );
}
} RingIterEndSafe( curr )
}
static void cgGenerateCmdsCtorTest( // EMIT CTOR_TEST CMDS
void )
{
CMD_CTOR_TEST* curr; // - current command
RingIterBegSafe( ringCmdsCtorTest, curr ) {
if( cgGenerateCmdBase( &curr->base, DTC_CTOR_TEST ) ) {
#ifndef NDEBUG
if( PragDbgToggle.dump_stab ) {
printf( "DTC_CTOR_TEST %d\n"
, curr->flag_no );
}
#endif
DgAlignPad( sizeof( DTOR_CMD_CODE ) );
DgOffset( curr->flag_no );
}
} RingIterEndSafe( curr )
}
void CgCmdsGenerate( // GENERATE DTOR CMD.S
void )
{
cgGenerateCmdsSetSv();
cgGenerateCmdsTestFlag();
cgGenerateCmdsComponent();
cgGenerateCmdsTry();
cgGenerateCmdsFnExc();
cgGenerateCmdsArrayInit();
cgGenerateCmdsDel1();
cgGenerateCmdsDel2();
cgGenerateCmdsDel1Array();
cgGenerateCmdsDel2Array();
cgGenerateCmdsCtorTest();
}
static void cgCmdInit( // INITIALIZATION FOR CGBKCMDS.C
INITFINI* def ) // - init/fini definition
{
def = def;
ringCmdsSetSv = NULL;
ringCmdsTestFlag = NULL;
ringCmdsComponent = NULL;
ringCmdsTry = NULL;
ringCmdsFnExc = NULL;
ringCmdsDel1 = NULL;
ringCmdsDel2 = NULL;
ringCmdsDel1Array = NULL;
ringCmdsDel2Array = NULL;
ringCmdsArrayInit = NULL;
ringCmdsCtorTest = NULL;
carveCMD_TRY = CarveCreate( sizeof( CMD_TRY ), 4 );
carveCMD_FN_EXC = CarveCreate( sizeof( CMD_FN_EXC ), 4 );
carveCMD_SET_SV = CarveCreate( sizeof( CMD_SET_SV ), 8 );
carveCMD_TEST_FLAG = CarveCreate( sizeof( CMD_TEST_FLAG ), 16 );
carveCMD_COMPONENT = CarveCreate( sizeof( CMD_COMPONENT ), 32 );
carveCMD_ARRAY_INIT = CarveCreate( sizeof( CMD_ARRAY_INIT ), 8 );
carveCMD_DEL_1 = CarveCreate( sizeof( CMD_DEL_1 ), 4 );
carveCMD_DEL_2 = CarveCreate( sizeof( CMD_DEL_2 ), 4 );
carveCMD_DEL_1_ARRAY = CarveCreate( sizeof( CMD_DEL_1_ARRAY ), 4 );
carveCMD_DEL_2_ARRAY = CarveCreate( sizeof( CMD_DEL_2_ARRAY ), 4 );
carveCMD_CTOR_TEST = CarveCreate( sizeof( CMD_CTOR_TEST ), 1 );
}
static void cgCmdFini( // COMPLETION FOR CGBKCMDS.C
INITFINI* def ) // - init/fini definition
{
def = def;
CarveDestroy( carveCMD_TRY );
CarveDestroy( carveCMD_FN_EXC );
CarveDestroy( carveCMD_SET_SV );
CarveDestroy( carveCMD_TEST_FLAG );
CarveDestroy( carveCMD_COMPONENT );
CarveDestroy( carveCMD_ARRAY_INIT );
CarveDestroy( carveCMD_DEL_1 );
CarveDestroy( carveCMD_DEL_2 );
CarveDestroy( carveCMD_DEL_1_ARRAY );
CarveDestroy( carveCMD_DEL_2_ARRAY );
CarveDestroy( carveCMD_CTOR_TEST );
}
INITDEFN( cg_cmds, cgCmdInit, cgCmdFini )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?