intrface.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 1,942 行 · 第 1/4 页

C
1,942
字号

extern  cg_name _CGAPI CGPreGets( cg_op op, cg_name dest, cg_name src, cg_type tipe )
/***********************************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGPreGets( %o, %n, %n, %t )", op, dest, src, tipe );
    hdlUseOnce( CG_NAMES, dest );
    hdlUseOnce( CG_NAMES, src );
    retn = TGPreGets( op, dest, src, TypeAddress( tipe ) );
    hdlAddBinary( CG_NAMES, retn, dest, src );
    return EchoAPICgnameReturn( retn );
#else
    return( TGPreGets( op, dest, src, TypeAddress( tipe ) ) );
#endif
}

extern  cg_name _CGAPI CGLVPreGets( cg_op op, cg_name dest, cg_name src, cg_type tipe )
/*************************************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGLVPreGets( %o, %n, %n, %t )", op, dest, src, tipe );
    hdlUseOnce( CG_NAMES, dest );
    hdlUseOnce( CG_NAMES, src );
    retn = TGLVPreGets( op, dest, src, TypeAddress( tipe ) );
    hdlAddBinary( CG_NAMES, retn, dest, src );
    return EchoAPICgnameReturn( retn );
#else
    return( TGLVPreGets( op, dest, src, TypeAddress( tipe ) ) );
#endif
}

/**/
/* Arithmetic/logical operations*/
/**/

extern  cg_name _CGAPI CGBinary( cg_op op, cg_name name1,
                          cg_name name2, cg_type tipe )
/*******************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGBinary( %o, %n, %n, %t )", op, name1, name2, tipe );
    hdlUseOnce( CG_NAMES, name1 );
    hdlUseOnce( CG_NAMES, name2 );
    if( op != O_COMMA ) verifyNotUserType( tipe );
#endif
    if( op == O_COMMA ) {
        name1 = TGTrash( name1 );
    } else if( op == O_SIDE_EFFECT ) {
        name2 = TGTrash( name2 );
    }
#ifndef NDEBUG
    retn = TGBinary( op, name1, name2, TypeAddress(tipe) );
    hdlAddBinary( CG_NAMES, retn, name1, name2 );
    return EchoAPICgnameReturn( retn );
#else
    return( TGBinary( op, name1, name2, TypeAddress( tipe ) ) );
#endif
}

extern  cg_name _CGAPI CGUnary( cg_op op, cg_name name, cg_type tipe )
/********************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGUnary( %o, %n, %t )", op, name, tipe );
    hdlUseOnce( CG_NAMES, name );
    if( op != O_POINTS ) verifyNotUserType( tipe );
    retn = TGUnary( op, name, TypeAddress( tipe ) );
    hdlAddUnary( CG_NAMES, retn, name );
    return EchoAPICgnameReturn( retn );
#else
    return( TGUnary( op, name, TypeAddress( tipe ) ) );
#endif
}

extern  cg_name _CGAPI CGIndex( cg_name name, cg_name by,
                         cg_type tipe, cg_type ptipe )
/*******************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGIndex( %n, %n, %t, %t )", name, by, tipe, ptipe );
#endif
    return( TGIndex( name, by, TypeAddress( tipe ), TypeAddress( ptipe ) ) );
}

/**/
/* Routine calling*/
/**/

extern  call_handle _CGAPI      CGInitCall( cg_name name, cg_type tipe,
                                            sym_handle aux_info )
/*********************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGInitCall( %n, %t, %s )", name, tipe, aux_info );
    hdlUseOnce( CG_NAMES, name );
    retn = TGInitCall( name, TypeAddress( tipe ), aux_info );
    hdlAddUnary( CG_NAMES, retn, name );
    return EchoAPICallHandleReturn( retn );
#else
    return( TGInitCall( name, TypeAddress( tipe ), aux_info ) );
#endif
}

extern  void _CGAPI     CGAddParm( call_handle call, cg_name name, cg_type tipe )
/*******************************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGAddParm( %C, %n, %t )\n", call, name, tipe );
    hdlExists( CG_NAMES, call );
    hdlUseOnce( CG_NAMES, name );
#endif
    TGAddParm( call, name, TypeAddress( tipe ) );
}

extern  cg_name _CGAPI CGCall( call_handle call )
/***********************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGCall( %C )\n", call );
    hdlUseOnce( CG_NAMES, call );
    retn = TGCall( call );
    hdlAddUnary( CG_NAMES, retn, call );
    return retn;
#else
    return( TGCall( call ) );
#endif
}

/**/
/* Comparison/short-circuit operations*/
/**/

extern  cg_name _CGAPI CGCompare( cg_op op, cg_name name1,
                           cg_name name2, cg_type tipe )
/********************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGCompare( %o, %n, %n, %t )", op, name1, name2, tipe );
    hdlUseOnce( CG_NAMES, name1 );
    hdlUseOnce( CG_NAMES, name2 );
    retn = TGCompare( op, name1, name2, TypeAddress( tipe ) );
    hdlAddBinary( CG_NAMES, retn, name1, name2 );
    return EchoAPICgnameReturn( retn );
#else
    return( TGCompare( op, name1, name2, TypeAddress( tipe ) ) );
#endif
}

extern  cg_name _CGAPI CGFlow( cg_op op, cg_name name1, cg_name name2 )
/*********************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGFlow( %o, %n, %n )", op, name1, name2 );
    hdlUseOnce( CG_NAMES, name1 );
    if( NULL != name2 ) {
        hdlUseOnce( CG_NAMES, name2 );
    }
    retn = TGFlow( op, name1, name2 );
    hdlAddBinary( CG_NAMES, retn, name1, name2 );
    return EchoAPICgnameReturn( retn );
#else
    return( TGFlow( op, name1, name2 ) );
#endif
}

/**/
/* Control flow operations*/
/**/

extern  cg_name _CGAPI CGChoose( cg_name sel, cg_name n1, cg_name n2, cg_type tipe )
/**********************************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGChoose( %n, %n, %n, %t )", sel, n1, n2, tipe );
    hdlUseOnce( CG_NAMES, sel );
    hdlUseOnce( CG_NAMES, n1 );
    hdlUseOnce( CG_NAMES, n2 );
    retn = TGQuestion( sel, n1, n2, TypeAddress( tipe ) );
    hdlAddTernary( CG_NAMES, retn, sel, n1, n2 );
    return EchoAPICgnameReturn( retn );
#else
    return( TGQuestion( sel, n1, n2, TypeAddress( tipe ) ) );
#endif
}

extern  cg_name _CGAPI CGWarp( cg_name before, label_handle label, cg_name after )
/********************************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGWarp( %n, %L, %n )", before, label, after );
    if( before != NULL ) { // Fortran calls with NULL first parm
        hdlUseOnce( CG_NAMES, before );
    }
    hdlUseOnce( CG_NAMES, after );
    retn = TGWarp( before, label, after );
    hdlAddUnary( CG_NAMES, retn, before );
    return EchoAPICgnameReturn( retn );
#else
    return( TGWarp( before, label, after ) );
#endif
}


extern  cg_name _CGAPI  CGCallback( cg_callback func, callback_handle parm )
/**************************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGCallback( %x, %x )", func, parm );
    retn = TGCallback( func, parm );
    hdlAdd( CG_NAMES, retn );
    EchoAPI( " -> %n\n", retn );
    return retn;
#else
    return( TGCallback( func, parm ) );
#endif
}


extern  void _CGAPI     CG3WayControl( cg_name expr, label_handle lt,
                               label_handle eq, label_handle gt )
/*******************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CG3WayControl( %n, %L, %L, %L )\n", expr, lt, eq, gt );
#endif
    TG3WayControl( expr, lt, eq, gt );  /* special TGen()*/
}

extern  void _CGAPI     CGControl( cg_op op, cg_name expr, label_handle lbl )
/***************************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGControl( %o, %n, %L )\n", op, expr, lbl );
    if( NULL != expr ) {
        hdlUseOnce( CG_NAMES, expr );
        hdlAllUsed( CG_NAMES );
    }
    if( lbl != 0 ) {
        hdlExists( LABEL_HANDLE, lbl );
    }
#endif
    TGControl( op, expr, lbl );  /* special TGen()*/
}

extern  void _CGAPI     CGBigLabel( back_handle value )
/*****************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGBigLabel( %B )\n", value );
#endif
    BGBigLabel( value );
}

extern  void _CGAPI     CGBigGoto( label_handle value, int level )
/****************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGBigLabel( %L, %i )\n", value, level );
#endif
    BGBigGoto( value, level );
}

extern  sel_handle _CGAPI       CGSelInit( void )
/***********************************************/
{
#ifndef NDEBUG
    select_node     *retn;

    EchoAPI( "CGSelInit()" );
    retn = BGSelInit();
    hdlAdd( SEL_HANDLE, retn );
    return EchoAPISelHandleReturn( retn );
#else
    return( BGSelInit() );
#endif
}

extern  void _CGAPI     CGSelCase( sel_handle s, label_handle lbl, signed_32 val )
/********************************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGSelCase( %S, %L, %i )\n", s, lbl, val );
    hdlExists( SEL_HANDLE, s );
    hdlExists( LABEL_HANDLE, lbl );
#endif

    BGSelCase( s, lbl, val );
}

extern  void _CGAPI     CGSelRange( sel_handle s, signed_32 lo,
                            signed_32 hi, label_handle lbl )
/*************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGSelRange( %S, %L, %i, %i )\n", s, lbl, lo, hi );
    hdlExists( SEL_HANDLE, s );
    hdlExists( LABEL_HANDLE, lbl );
#endif
    BGSelRange( s, lo, hi, lbl );
}

extern  void _CGAPI     CGSelOther( sel_handle s, label_handle lbl )
/******************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGSelOther( %S, %L )\n", s, lbl );
    hdlExists( SEL_HANDLE, s );
    hdlExists( LABEL_HANDLE, lbl );
#endif
    BGSelOther( s, lbl );
}

extern  void _CGAPI     CGSelectRestricted( sel_handle s, cg_name expr, cg_switch_type allowed )
/**********************************************************************************************/
{
    expr = TGen( expr, TypeAddress( T_DEFAULT ) );
    BGSelect( s, expr, allowed );
}

extern  void _CGAPI     CGSelect( sel_handle s, cg_name expr )
/************************************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGSelect( %S, %n )\n", s, expr );
    hdlExists( SEL_HANDLE, s );
    hdlUseOnce( CG_NAMES, expr );
    hdlUseOnce( SEL_HANDLE, s );
#endif

    CGSelectRestricted( s, expr, CG_SWITCH_ALL );
}

/**/
/* Misc. operations*/
/**/

extern  cg_name _CGAPI CGEval( cg_name name )
/*******************************************/
{
#ifndef NDEBUG
    cg_name     retn;

    EchoAPI( "CGEval( %n )", name );
    hdlUseOnce( CG_NAMES, name );
    retn = TGTmpLeaf( TGen( name, TypeAddress( T_DEFAULT ) ) );
    hdlAddUnary( CG_NAMES, retn, name );
    return EchoAPICgnameReturn( retn );
#else
    return( TGTmpLeaf( TGen( name, TypeAddress( T_DEFAULT ) ) ) );
#endif
}

extern  void _CGAPI     CGTrash( cg_name name )
/*********************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGTrash( %n )\n", name );
    hdlUseOnce( CG_NAMES, name );
    hdlAllUsed( CG_NAMES );
#endif
    BGTrash( TGen( TGTrash( name ), TypeAddress( T_DEFAULT ) ) );
}

extern  void _CGAPI     CGDone( cg_name name )
/********************************************/
{
#ifndef NDEBUG
    EchoAPI( "CGDone( %n )\n", name );
    hdlUseOnce( CG_NAMES, name );
    hdlAllUsed( CG_NAMES );
#endif
    BGTrash( TGen( TGTrash( name ), TypeAddress( T_DEFAULT ) ) );
    BGStartBlock();
}

extern  cg_type _CGAPI CGType( cg_name name )
/*******************************************/
{
#ifndef NDEBUG
    cg_type     retn;

    EchoAPI( "CGType( %n )", name );
    retn = TGType( name );
    return EchoAPICgtypeReturn( retn );
#else
    return( TGType( name ) );
#endif
}

extern  cg_name _CGAPI CGBitMask( cg_name left, byte start, byte len, cg_type tipe )
/**********************************************************************************/
{
#ifndef NDEBUG
    tn_btn      retn;

    EchoAPI( "CGBitMask( %n, %x, %x, %t )", left, start, len, tipe );
    hdlUseOnce( CG_NAMES, left );
    retn.b = TGBitMask( left, start, len, TypeAddress( tipe ) );
    hdlAddUnary( CG_NAMES, retn.t, left );
    return EchoAPICgnameReturn( retn.t );
#else
    return( TGBitMask( left, start, len, TypeAddress( tipe ) ) );
#endif
}

extern  cg_name _CGAPI CGVolatile( cg_name name )
/***********************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGVolatile( %n )", name );
    hdlUseOnce( CG_NAMES, name );
    retn = TGVolatile( name );
    hdlAddUnary( CG_NAMES, retn, name );
    return EchoAPICgnameReturn( retn );
#else
    return( TGVolatile( name ) );
#endif
}

extern cg_name _CGAPI CGAttr( cg_name name, cg_sym_attr attr )
/************************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGAttr( %n, %i )", name, attr );
    hdlUseOnce( CG_NAMES, name );
    retn = TGAttr( name, attr );
    hdlAddUnary( CG_NAMES, retn, name );
    return EchoAPICgnameReturn( retn );
#else
    return( TGAttr( name, attr ) );
#endif
}

extern cg_name _CGAPI CGAlign( cg_name name, uint alignment )
/***********************************************************/
{
#ifndef NDEBUG
    tn      retn;

    EchoAPI( "CGAlign( %n, %i )", name, alignment );
    hdlUseOnce( CG_NAMES, name );
    retn = TGAlign( name, alignment );
    hdlAddUnary( CG_NAMES, retn, name );
    return EchoAPICgnameReturn( retn );
#else
    return( TGAlign( name, alignment ) );
#endif
}

static  cg_name CGDuplicateArray[ 2 ];

extern  cg_name * _CGAPI CGDuplicate( cg_name name )
/**************************************************/
{
    an          addr;
#ifndef NDEBUG
    cg_name     *retn;

    EchoAPI( "CGDuplicate( %n )", name );
    hdlExists( CG_NAMES, name );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?