Esempio n. 1
0
PTREE AsmStmt( void )
/*******************/
{
    boolean     uses_auto;
    AUX_INFO    *aux_info;
    unsigned    skip_token;
    unsigned    skip_alt_token;
    PTREE       expr;
    TYPE        fn_type;
    TYPE        ret_type;
    SYMBOL      sym;
    char        *fn_name;
    auto VBUF   code_buffer;
    ppstate_t   save_ppstate;

    save_ppstate = PPState;
    PPState = PPS_EOL;
    PPStateAsm = TRUE;
    VbufInit( &code_buffer );
    NextTokenSkipEOL();
    AsmSysInit();
    if( ( CurToken == T_LEFT_BRACE ) || ( CurToken == T_ALT_LEFT_BRACE ) ) {
        NextTokenSkipEOL();
        for(;;) {
            getAsmLine( &code_buffer );
            if( CurToken == T_RIGHT_BRACE ) break;
            if( CurToken == T_ALT_RIGHT_BRACE ) break;
            if( CurToken == T_EOF ) break;
            NextTokenSkipEOL();
        }
        skip_token = T_RIGHT_BRACE;
        skip_alt_token = T_ALT_RIGHT_BRACE;
    } else {
        getAsmLine( &code_buffer );
        skip_token = skip_alt_token = T_NULL;
    }
    PPStateAsm = FALSE;
    PPState = save_ppstate;
    if( ( CurToken == skip_token ) || ( CurToken == skip_alt_token ) ) {
        NextToken();
    }
    if( AsmCodeAddress != 0 ) {
        fn_name = NameDummy();
        aux_info = AsmSysCreateAux( fn_name );
        uses_auto = AsmSysInsertFixups( &code_buffer );
        if( uses_auto ) {
            AsmSysUsesAuto();
        }
        AsmSysDone();
        ret_type = GetBasicType( TYP_VOID );
        fn_type = MakeModifiableFunction( ret_type, NULL );
        fn_type->u.f.pragma = aux_info;
        fn_type = CheckDupType( fn_type );
        sym = SymCreateFileScope( fn_type, SC_NULL, SF_NULL, fn_name );
        LinkageSet( sym, "C" );
        expr = genFnCall( fn_name );
    } else {
        expr = NULL;
    }
    AsmSysFini();
    VbufFree( &code_buffer );
    return( expr );
}
Esempio n. 2
0
void PragAux(                   // #PRAGMA AUX ...
    void )
{
    struct {
        unsigned f_call   : 1;
        unsigned f_loadds : 1;
        unsigned f_rdosdev: 1;
        unsigned f_export : 1;
        unsigned f_parm   : 1;
        unsigned f_value  : 1;
        unsigned f_modify : 1;
        unsigned f_frame  : 1;
        unsigned uses_auto: 1;
    } have;

    if( !GetAliasInfo() ) return;
    CurrEntry = NULL;
    if( !IS_ID_OR_KEYWORD( CurToken ) ) return;
    SetCurrInfo();
    NextToken();
    AuxCopy( CurrInfo, CurrAlias );
    PragObjNameInfo();
    have.f_call   = 0;
    have.f_loadds = 0;
    have.f_rdosdev = 0;
    have.f_export = 0;
    have.f_parm   = 0;
    have.f_value  = 0;
    have.f_modify = 0;
    have.f_frame = 0;
    have.uses_auto = 0;
    for( ;; ) {
        if( !have.f_call && CurToken == T_EQUAL ) {
            have.uses_auto = GetByteSeq();
            have.f_call = 1;
        } else if( !have.f_call && PragRecog( "far" ) ) {
            CurrInfo->cclass |= FAR_CALL;
            have.f_call = 1;
        } else if( !have.f_call && PragRecog( "near" ) ) {
            CurrInfo->cclass &= ~FAR_CALL;
            have.f_call = 1;
        } else if( !have.f_loadds && PragRecog( "loadds" ) ) {
            CurrInfo->cclass |= LOAD_DS_ON_ENTRY;
            have.f_loadds = 1;
        } else if( !have.f_rdosdev && PragRecog( "rdosdev" ) ) {
            CurrInfo->cclass |= LOAD_RDOSDEV_ON_ENTRY;
            have.f_rdosdev = 1;
        } else if( !have.f_export && PragRecog( "export" ) ) {
            CurrInfo->cclass |= DLL_EXPORT;
            have.f_export = 1;
        } else if( !have.f_parm && PragRecog( "parm" ) ) {
            GetParmInfo();
            have.f_parm = 1;
        } else if( !have.f_value && PragRecog( "value" ) ) {
            GetRetInfo();
            have.f_value = 1;
        } else if( !have.f_value && PragRecog( "aborts" ) ) {
            CurrInfo->cclass |= SUICIDAL;
            have.f_value = 1;
        } else if( !have.f_modify && PragRecog( "modify" ) ) {
            GetSaveInfo();
            have.f_modify = 1;
        } else if( !have.f_frame && PragRecog( "frame" ) ) {
            CurrInfo->cclass |= GENERATE_STACK_FRAME;
            have.f_frame = 1;
        } else {
            break;
        }
    }
    if( have.uses_auto ) {
        AsmSysUsesAuto();
    }
    PragEnding( TRUE );
}
Esempio n. 3
0
PTREE AsmStmt( void )
/*******************/
{
    bool        uses_auto;
    AUX_INFO    *auxinfo;
    TOKEN       skip_token;
    TOKEN       skip_alt_token;
    PTREE       expr;
    TYPE        fn_type;
    TYPE        ret_type;
    SYMBOL      sym;
    NAME        fn_name;
    auto VBUF   code_buffer;
    ppctl_t     old_ppctl;

    old_ppctl = PPControl;
    PPCTL_ENABLE_EOL();
    PPCTL_ENABLE_ASM();
    VbufInit( &code_buffer );
    NextTokenSkipEOL();
    AsmSysInit();
    if( ( CurToken == T_LEFT_BRACE ) || ( CurToken == T_ALT_LEFT_BRACE ) ) {
        NextTokenSkipEOL();
        for(;;) {
            getAsmLine( &code_buffer );
            if( CurToken == T_RIGHT_BRACE ) break;
            if( CurToken == T_ALT_RIGHT_BRACE ) break;
            if( CurToken == T_EOF ) break;
            NextTokenSkipEOL();
        }
        skip_token = T_RIGHT_BRACE;
        skip_alt_token = T_ALT_RIGHT_BRACE;
    } else {
        getAsmLine( &code_buffer );
        skip_token = skip_alt_token = T_NULL;
    }
    PPControl = old_ppctl;
    if( ( CurToken == skip_token ) || ( CurToken == skip_alt_token ) ) {
        NextToken();
    }
    if( AsmCodeAddress != 0 ) {
        fn_name = NameDummy();
        auxinfo = AsmSysCreateAux( NameStr( fn_name ) );
        uses_auto = AsmSysInsertFixups( &code_buffer );
        if( uses_auto ) {
            AsmSysUsesAuto();
        }
        AsmSysDone();
        ret_type = GetBasicType( TYP_VOID );
        fn_type = MakeModifiableFunction( ret_type, NULL );
        fn_type->u.f.pragma = auxinfo;
        fn_type = CheckDupType( fn_type );
        sym = SymCreateFileScope( fn_type, SC_NULL, SF_NULL, fn_name );
        LinkageSet( sym, "C" );
        expr = genFnCall( fn_name );
    } else {
        expr = NULL;
    }
    AsmSysFini();
    VbufFree( &code_buffer );
    return( expr );
}