Beispiel #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 );
}
Beispiel #2
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 );
}