Esempio n. 1
0
// #pragma alias(id1/"name1", id2/"name2")
//
// Causes linker to replace references to id1/name1 with references
// to id2/name2. Both the alias and the substituted symbol may be defined
// either as a string name or an id of existing symbol.
//
static void PragAlias( void )
/***************************/
{
    SYM_HANDLE      alias_sym;
    SYM_HANDLE      subst_sym;
    const char      *alias_name;
    const char      *subst_name;
    alias_list      **alias;
    alias_list      *new_alias;

    alias_name = subst_name = NULL;
    alias_sym  = subst_sym  = NULL;

    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        PPNextToken();
        if( CurToken == T_ID ) {
            alias_sym = SymLook( HashValue, Buffer );
            if( alias_sym == 0 ) {
                CErr2p( ERR_UNDECLARED_SYM, Buffer );
            }
        } else if( CurToken == T_STRING ) {
            alias_name = CStrSave( Buffer );
        }
        PPNextToken();
        MustRecog( T_COMMA );
        if( CurToken == T_ID ) {
            subst_sym = SymLook( HashValue, Buffer );
            if( subst_sym == 0 ) {
                CErr2p( ERR_UNDECLARED_SYM, Buffer );
            }
        } else if( CurToken == T_STRING ) {
            subst_name = CStrSave( Buffer );
        }
        PPNextToken();
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
    }

    /* Add a new alias record - if it's valid - to the list */
    if( ( alias_name != NULL || alias_sym != NULL ) && ( subst_name != NULL || subst_sym != NULL ) ) {
        for( alias = &AliasHead; *alias != NULL; alias = &(*alias)->next )
            ; /* nothing to do */
        new_alias = (void *)CMemAlloc( sizeof( alias_list ) );
        new_alias->next = NULL;
        if( alias_name ) {
            new_alias->name = alias_name;
        } else {
            new_alias->a_sym = alias_sym;
        }
        if( subst_name ) {
            new_alias->subst = subst_name;
        } else {
            new_alias->s_sym = subst_sym;
        }
        *alias = new_alias;
    }
}
Esempio n. 2
0
// form: #pragma include_alias( "alias_name", "real_name" )
//       #pragma include_alias( <alias_name>, <real_name> )
//
// (1) causes include directives referencing alias_name to refer
//     to real_name instead
//
static void pragIncludeAlias( void )
{
    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        NextToken();
        if( CurToken == T_STRING ) {
            char    *alias_name;

            alias_name = CMemAlloc( strlen( Buffer ) + 1 );
            strcpy( alias_name, Buffer );
            NextToken();
            if( ExpectingToken( T_COMMA ) ) {
                NextToken();
            }
            if( CurToken == T_STRING ) {
                IAliasAdd( alias_name, Buffer, false );
                NextToken();
            }
            CMemFree( alias_name );
        } else if( CurToken == T_LT ) {
            char    a_buf[82];
            char    r_buf[82];

            a_buf[0] = '\0';
            for( ;; ) {
                NextToken();
                if( CurToken == T_GT ) {
                    NextToken();
                    break;
                }
                if( CurToken == T_NULL ) {
                    break;
                }
                strncat( a_buf, Buffer, sizeof( a_buf ) - 2 );
            }
            if( ExpectingToken( T_COMMA ) ) {
                NextToken();
            }
            if( CurToken == T_LT ) {
                r_buf[0] = '\0';
                for( ;; ) {
                    NextToken();
                    if( CurToken == T_GT ) {
                        NextToken();
                        break;
                    }
                    if( CurToken == T_NULL ) {
                        break;
                    }
                    strncat( r_buf, Buffer, sizeof( r_buf ) - 2 );
                }
                IAliasAdd( a_buf, r_buf, true );
            }
        }
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 3
0
static void pragPack(           // #PRAGMA PACK
    void )
{
    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        NextToken();
        PPCTL_DISABLE_MACROS();
        switch( CurToken ) {
        case T_ID:
            if( PragIdRecog( "pop" ) ) {
                popPrag( &HeadPacks, &PackAmount );
            } else if( PragIdRecog( "push" ) ) {
                if( CurToken == T_RIGHT_PAREN ) {
                    pushPrag( &HeadPacks, PackAmount );
                } else {
                    if( ExpectingToken( T_COMMA ) ) {
                        PPCTL_ENABLE_MACROS();
                        NextToken();
                        PPCTL_DISABLE_MACROS();
                    }
                    if( CurToken == T_CONSTANT ) {
                        pushPrag( &HeadPacks, PackAmount );
                        PackAmount = VerifyPackAmount( U32Fetch( Constant64 ) );
                        NextToken();
                    } else {
                        MustRecog( T_CONSTANT );
                    }
                }
            } else {
                CErr( ERR_EXPECTING_BUT_FOUND, "push or pop", Buffer );
            }
            break;
        case T_CONSTANT:
            PackAmount = VerifyPackAmount( U32Fetch( Constant64 ) );
            NextToken();
            break;
        case T_RIGHT_PAREN:
            PackAmount = GblPackAmount;
            break;
        default:
            break;
        }
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 4
0
static bool startPragRecog( char *id )
{
    bool retb;

    PPCTL_ENABLE_MACROS();
    retb = PragIdRecog( id );
    PPCTL_DISABLE_MACROS();
    return( retb );
}
Esempio n. 5
0
local int startPragRecog( char *what )
/************************************/
{
    int rc;

    PPCTL_ENABLE_MACROS();
    rc = PragIdRecog( what );
    PPCTL_DISABLE_MACROS();
    return( rc );
}
Esempio n. 6
0
local void CIf( void )
{
    int value;

    PPCTL_ENABLE_MACROS();
    PPNextToken();
    value = GetConstExpr();
    IncLevel( value );
    ChkEOL();
    PPCTL_DISABLE_MACROS();
}
Esempio n. 7
0
// forms: (1) #pragma include_alias( "alias_name", "real_name" )
//        (2) #pragma include_alias( <alias_name>, <real_name> ) 
// 
// causes include directives referencing alias_name to be refer
// to real_name instead
//
static void PragIncludeAlias( void )
/**********************************/
{
    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        NextToken();
        if( CurToken == T_STRING ) {
            char    *alias_name;

            alias_name = CStrSave( Buffer );
            NextToken();
            MustRecog( T_COMMA );
            if( CurToken == T_STRING ) {
                SrcFileIncludeAlias( alias_name, Buffer, FALSE );
                NextToken();
            }
            CMemFree( alias_name );
        } else if( CurToken == T_LT ) {
            char    a_buf[ 82 ];    /* same size as CInclude() in cmac2.c */
            char    r_buf[ 82 ];

            a_buf[ 0 ] = '\0';
            for( ;; ) {
                NextToken();
                if( CurToken == T_GT ) {
                    NextToken();
                    break;
                }
                if( CurToken == T_NULL ) {
                    break;
                }
                strncat( a_buf, Buffer, sizeof( a_buf ) - 2 );
            }
            MustRecog( T_COMMA );
            if( CurToken == T_LT ) {
                r_buf[ 0 ] = '\0';
                for( ;; ) {
                    NextToken();
                    if( CurToken == T_GT ) {
                        NextToken();
                        break;
                    }
                    if( CurToken == T_NULL ) {
                        break;
                    }
                    strncat( r_buf, Buffer, sizeof( r_buf ) - 2 );
                }
                SrcFileIncludeAlias( a_buf, r_buf, TRUE );
            }
        }
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 8
0
void CInclude( void )
{
    char        in_macro;
    auto char   buf[ 82 ];

    if( PCH_FileName != NULL && CompFlags.make_precompiled_header == 0 ) {
        if( CompFlags.ok_to_use_precompiled_hdr ) {     /* 27-jun-94 */
            CompFlags.use_precompiled_header = 1;
        }
    }
    if( CompFlags.use_precompiled_header ) {
        InitBuildPreCompiledHeader();
    }
    InitialMacroFlag = MFLAG_NONE;
    in_macro = 0;
    if( MacroPtr != NULL )
        in_macro = 1;
    PPCTL_ENABLE_MACROS();
    PPNextToken();
    if( CurToken == T_STRING ) {
        OpenSrcFile( Buffer, FALSE );
#if _CPU == 370
        if( !CompFlags.use_precompiled_header ) {
            SrcFile->colum = Column;    /* do trunc and col on  */
            SrcFile->trunc = Trunc;     /* on user source files */
        }
#endif
    } else if( CurToken == T_LT ) {
        if( !in_macro )                 /* 28-may-89 */
            PPCTL_DISABLE_MACROS();
        buf[ 0 ] = '\0';
        for( ;; ) {
            PPNextToken();
            if( CurToken == T_GT ) {
                OpenSrcFile( buf, TRUE );
                break;
            }
            strncat( buf, Buffer, sizeof( buf ) - 2 );
            if( in_macro != 0 && MacroPtr == NULL || CurToken == T_NULL || CurToken == T_EOF ) {
                CErr1( ERR_INVALID_INCLUDE );
                break;
            }
        }
    } else {
        CErr1( ERR_INVALID_INCLUDE );
    }
    PPCTL_DISABLE_MACROS();
    if( CurToken != T_EOF ) {
        PPNextToken();
    }
    CompFlags.use_precompiled_header = 0;
}
Esempio n. 9
0
static void pragError(          // #PRAGMA ERROR
    void )
{
    VBUF str;

    if( CurToken == T_STRING ) {
        PPCTL_ENABLE_MACROS();
        collectStrings( &str );
        CErr2p( ERR_USER_ERROR_MSG, VbufString( &str ) );
        VbufFree( &str );
        PPCTL_DISABLE_MACROS();
    }
}
Esempio n. 10
0
// form:
// #pragma message ("one or more " "long message " "strings")
// output these strings to stdout
// this output is _not_ dependent on setting
// of #pragma enable_message or disable_message.
static void PragMessage( void )
/*****************************/
{
    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        while( NextToken() == T_STRING ) {
            printf( "%s", Buffer );
        }
        printf( "\n" );
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 11
0
static void pragMessage(        // #PRAGMA MESSAGE
    void )
{
    VBUF str;

    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        NextToken();
        if( CurToken == T_STRING ) {
            collectStrings( &str );
            CErr2p( WARN_USER_WARNING_MSG, VbufString( &str ) );
            VbufFree( &str );
        }
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 12
0
local void PragPack( void )
/*************************/
{
    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        NextToken();
        PPCTL_DISABLE_MACROS();
        if( CurToken == T_CONSTANT ) {
            SetPackAmount();
            NextToken();
        } else if( IS_ID_OR_KEYWORD( CurToken ) ) {
            getPackArgs();
        } else if( CurToken == T_RIGHT_PAREN ) {
            PackAmount = GblPackAmount;
        }
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 13
0
local void CLine( void )
{
    FNAMEPTR        flist;
    unsigned long   src_line;

    src_line = 0;
    PPCTL_ENABLE_MACROS();
    PPNextToken();
    if( ExpectingConstant() ) {
        if( CompFlags.cpp_ignore_line == 0 ) {
            src_line = Constant; // stash in case of side effects
            SrcFile->src_loc.line = src_line - 1; /* don't count this line */
        }
        PPNextToken();
        if( CurToken == T_NULL ) {
            if( CompFlags.cpp_ignore_line == 0 ) {
                if( CompFlags.cpp_output ) {
                    EmitLine( src_line, SrcFile->src_name );
                }
            }
        } else {
            if( ExpectingToken( T_STRING ) ) {
                if( CompFlags.wide_char_string ) {
                    /* wide char string not allowed */
                    ExpectString();
                } else {
                    if( CompFlags.cpp_ignore_line == 0 ) {
                        // RemoveEscapes( Buffer );
                        flist = AddFlist( Buffer );
                        flist->rwflag = FALSE;  // not a real file so no autodep
                        SrcFile->src_name = flist->name;
                        SrcFile->src_loc.fno  = flist->index;
                        if( CompFlags.cpp_output ) {
                            EmitLine( src_line, SrcFile->src_name );
                        }
                    }
                }
            }
            PPNextToken();
            ChkEOL();
        }
    }
    PPCTL_DISABLE_MACROS();
}
Esempio n. 14
0
static void pragExtRef(     // #pragma extref ...
    void )
{
    if( CurToken == T_LEFT_PAREN ) {
        do {
            PPCTL_ENABLE_MACROS();
            NextToken();
            PPCTL_DISABLE_MACROS();
            if( !IS_ID_OR_KEYWORD( CurToken ) && CurToken != T_STRING )
                break;
            parseExtRef();
            NextToken();
        } while( CurToken == T_COMMA );
        MustRecog( T_RIGHT_PAREN );
    } else if( IS_ID_OR_KEYWORD( CurToken ) || CurToken == T_STRING ) {
        parseExtRef();
        NextToken();
    }
}
Esempio n. 15
0
static void pragComment(        // #PRAGMA COMMENT
    void )
{
    if( ExpectingToken( T_LEFT_PAREN ) ) {
        NextToken();
        if( PragRecog( "lib" ) ) {
            PPCTL_ENABLE_MACROS();
            if( ExpectingToken( T_COMMA ) ) {
                NextToken();
            }
            while( IS_ID_OR_KEYWORD( CurToken ) || CurToken == T_STRING ) {
                CgInfoAddUserLib( Buffer );
                NextToken();
            }
            PPCTL_DISABLE_MACROS();
        }
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 16
0
// #pragma data_seg ( segment [, class] )
// #pragma data_seg segment
//
// "segment" sets the default data segment for remaining objects
// "class" is ignored
//
static void pragDataSeg(        // SET NEW DATA SEGMENT
    void )
{
    char *seg_name;
    char *seg_class;

    if( CurToken == T_LEFT_PAREN ) {
        PPCTL_ENABLE_MACROS();
        NextToken();
        if( ( CurToken == T_STRING ) || ( CurToken == T_ID ) ) {
            seg_name = strsave( Buffer );
            seg_class = NULL;
            NextToken();
            if( CurToken == T_COMMA ) {
                NextToken();
                if( ( CurToken == T_STRING ) || ( CurToken == T_ID ) ) {
                    seg_class = strsave( Buffer );
                    NextToken();
                } else {
                    MustRecog( T_STRING );
                }
            }
            SegmentData( seg_name, seg_class );
            CMemFree( seg_name );
            CMemFree( seg_class );
        } else if( CurToken == T_RIGHT_PAREN ) {
            // restore back to default behaviour
            SegmentData( NULL, NULL );
        }
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
    } else if( CurToken == T_STRING ) {
        SegmentData( Buffer, NULL );
        NextToken();
    }
}
Esempio n. 17
0
static void PragCodeSeg( void )                       /* 22-oct-92 */
/*****************************/
{
    textsegment     *seg;
    char            *segname;
    char            *classname;

    if( CurToken == T_LEFT_PAREN ) {
        PPCTL_ENABLE_MACROS();
        seg = NULL;
        NextToken();
        if( ( CurToken == T_STRING ) || ( CurToken == T_ID ) ) {
            segname = CStrSave( Buffer );
            classname = CStrSave( "" );
            NextToken();
            if( CurToken == T_COMMA ) {
                NextToken();
                if( ( CurToken == T_STRING ) || ( CurToken == T_ID ) ) {
                    CMemFree( classname );
                    classname = CStrSave( Buffer );
//                  CodeClassName = CStrSave( Buffer );  /* 13-apr-93 */
                    NextToken();
                }
            }
            seg = LkSegName( segname, classname );
            CMemFree( segname );
            CMemFree( classname );
        }
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
        DefCodeSegment = seg;
#if _CPU == 8086 || _CPU == 386
        CompFlags.multiple_code_segments = 1;
#endif
    }
}
Esempio n. 18
0
void CPragma( void )                  // PROCESS A PRAGMA
{
    bool check_end = true;

    SrcFileGuardStateSig();
    CompFlags.in_pragma = 1;
    NextToken();
    if( PragRecog( "include_alias" ) ) {
        pragIncludeAlias();
    } else if( CompFlags.cpp_output ) {
        PPCTL_ENABLE_MACROS();
        fprintf( CppFile, "#pragma " );
        for( ; CurToken != T_NULL; ) {
            PrtToken();
            GetNextToken();
        }
        PPCTL_DISABLE_MACROS();
    } else if( IS_ID_OR_KEYWORD( CurToken ) ) {
        if( PragIdRecog( "on" ) ) {
            pragFlag( true );
        } else if( PragIdRecog( "off" ) ) {
            pragFlag( false );
        } else if( PragIdRecog( "aux" ) || PragIdRecog( "linkage" ) ) {
            PragAux();
        } else if( PragIdRecog( "library" ) ) {
            pragLibs();
        } else if( PragIdRecog( "once" ) ) {
            pragOnce();
        } else if( PragIdRecog( "extref" ) ) {
            pragExtRef();
        } else if( PragIdRecog( "comment" ) ) {
            pragComment();
        } else if( PragIdRecog( "pack" ) ) {
            pragPack();
        } else if( PragIdRecog( "warning" ) ) {
            if( pragWarning() ) {
                /* ignore #pragma warning */
                check_end = false;  /* skip rest of line */
            }
        } else if( PragIdRecog( "enable_message" ) ) {
            pragEnableMessage();
        } else if( PragIdRecog( "disable_message" ) ) {
            pragDisableMessage();
        } else if( PragIdRecog( "code_seg" ) ) {
            pragCodeSeg();
        } else if( PragIdRecog( "data_seg" ) ) {
            pragDataSeg();
        } else if( PragIdRecog( "initialize" ) ) {
            pragInitialize();
        } else if( PragIdRecog( "init_seg" ) ) {
            pragInitSeg();
        } else if( PragIdRecog( "inline_depth" ) ) {
            pragInlineDepth();
        } else if( PragIdRecog( "template_depth" ) ) {
            pragTemplateDepth();
        } else if( PragIdRecog( "inline_recursion" ) ) {
            pragInlineRecursion();
        } else if( PragIdRecog( "intrinsic" ) ) {
            pragIntrinsic( true );
        } else if( PragIdRecog( "function" ) ) {
            pragIntrinsic( false );
        } else if( PragIdRecog( "destruct" ) ) {
            pragDestruct();
        } else if( PragIdRecog( "enum" ) ) {
            pragEnum();
        } else if( PragIdRecog( "dump_object_model" ) ) {
            pragDumpObjectModel();
        } else if( startPragRecog( "read_only_file" ) ) {
            pragReadOnlyFile();
        } else if( startPragRecog( "read_only_directory" ) ) {
            pragReadOnlyDir();
        } else if( PragIdRecog( "include_alias" ) ) {
            pragIncludeAlias();
        } else if( PragIdRecog( "message" ) ) {
            pragMessage();
        } else if( PragIdRecog( "error" ) ) {
            pragError();
#ifndef NDEBUG
        } else if( PragIdRecog( "break" ) ) {
            pragBreak();
#endif
        } else {                /* unknown pragma */
            check_end = false;  /* skip rest of line */
        }
    } else {                    /* unknown pragma */
        check_end = false;      /* skip rest of line */
    }
    if( check_end ) {
        endOfPragma();
    }
    CompFlags.in_pragma = 0;
}
Esempio n. 19
0
void CPragma( void )
/******************/
{
    bool    check_end = TRUE;

    /* Note that the include_alias pragma must always be processed
     * because it's intended for the preprocessor, not the compiler.
     */
    CompFlags.in_pragma = 1;
    NextToken();
    if( PragRecog( "include_alias" ) ) {
        PragIncludeAlias();
    } else if( CompFlags.cpp_output ) {
        PPCTL_ENABLE_MACROS();
        CppPrtf( "#pragma " );
        for( ; CurToken != T_NULL; ) {
            CppPrtToken();
            GetNextToken();
        }
        PPCTL_DISABLE_MACROS();
    } else if( IS_ID_OR_KEYWORD( CurToken ) ) {
        if( PragIdRecog( "on" ) ) {
            PragFlag( 1 );
        } else if( PragIdRecog( "off" ) ) {
            PragFlag( 0 );
        } else if( PragIdRecog( "aux" ) || PragIdRecog( "linkage" ) ) {
            PragAux();
        } else if( PragIdRecog( "library" ) ) {
            PragLibs();
        } else if( PragIdRecog( "comment" ) ) {
            PragComment();
        } else if( PragIdRecog( "pack" ) ) {
            PragPack();
        } else if( PragIdRecog( "alloc_text" ) ) {
            PragAllocText();
        } else if( PragIdRecog( "code_seg" ) ) {
            PragCodeSeg();
        } else if( PragIdRecog( "data_seg" ) ) {
            PragDataSeg();
        } else if( PragIdRecog( "disable_message" ) ) {
            PragEnableDisableMessage( 0 );
        } else if( PragIdRecog( "enable_message" ) ) {
            PragEnableDisableMessage( 1 );
        } else if( PragIdRecog( "include_alias" ) ) {
            PragIncludeAlias();
        } else if( PragIdRecog( "message" ) ) {
            PragMessage();
        } else if( PragIdRecog( "intrinsic" ) ) {
            PragIntrinsic( 1 );
        } else if( PragIdRecog( "function" ) ) {
            PragIntrinsic( 0 );
        } else if( PragIdRecog( "enum" ) ) {
            PragEnum();
        } else if( startPragRecog( "read_only_file" ) ) {
            PragReadOnlyFile();
        } else if( startPragRecog( "read_only_directory" ) ) {
            PragReadOnlyDir();
        } else if( PragIdRecog( "once" ) ) {
            PragOnce();
        } else if( PragIdRecog( "unroll" ) ) {
            PragUnroll();
        } else if( PragIdRecog( "STDC" ) ) {
            PragSTDC();
        } else if( PragIdRecog( "extref" ) ) {
            PragExtRef();
        } else if( PragIdRecog( "alias" ) ) {
            PragAlias();
        } else {
            check_end = FALSE;
        }
    } else {
        check_end = FALSE;
    }
    if( check_end )
        EndOfPragma();
    CompFlags.in_pragma = 0;
}
Esempio n. 20
0
static int GetByteSeq( void )
{
    int             len;
    char            *name;
    unsigned        offset;
    unsigned        fixword;
    int             uses_auto;
    VBUF            code_buffer;
#if _CPU == 8086
    bool            use_fpu_emu = FALSE;
#endif

    VbufInit( &code_buffer );
    AsmSysInit();
    PPCTL_ENABLE_MACROS();
    NextToken();
    len = 0;
    offset = 0;
    name = NULL;
    for( ;; ) {
        /* reserve at least ASM_BLOCK bytes in the buffer */
        VbufReqd( &code_buffer, _RoundUp( len + ASM_BLOCK, ASM_BLOCK ) );
        if( CurToken == T_STRING ) {
            AsmCodeAddress = len;
            AsmCodeBuffer = VbufBuffer( &code_buffer );
#if _CPU == 8086
            AsmLine( Buffer, use_fpu_emu );
            use_fpu_emu = FALSE;
#else
            AsmLine( Buffer, FALSE );
#endif
            len = AsmCodeAddress;
            NextToken();
            if( CurToken == T_COMMA ) {
                NextToken();
            }
        } else if( CurToken == T_CONSTANT ) {
#if _CPU == 8086
            if( use_fpu_emu ) {
                AddAFix( len, NULL, FIX_SEG, 0 );
                use_fpu_emu = FALSE;
            }
#endif
            VbufBuffer( &code_buffer )[ len++ ] = U32Fetch( Constant64 );
            NextToken();
        } else {
#if _CPU == 8086
            use_fpu_emu = FALSE;
#endif
            fixword = FixupKeyword();
            if( fixword == FIXWORD_NONE )
                break;
            if( fixword == FIXWORD_FLOAT ) {
#if _CPU == 8086
                if( GET_FPU_EMU( CpuSwitches ) ) {
                    use_fpu_emu = TRUE;
                }
#endif
            } else { /* seg or offset */
                if( !IS_ID_OR_KEYWORD( CurToken ) ) {
                    CErr1( ERR_EXPECTING_ID );
                } else {
                    name = strsave( Buffer );
                    offset = 0;
                    NextToken();
                    if( CurToken == T_PLUS ) {
                        NextToken();
                        if( CurToken == T_CONSTANT ) {
                            offset = U32Fetch( Constant64 );
                            NextToken();
                        }
                    } else if( CurToken == T_MINUS ) {
                        NextToken();
                        if( CurToken == T_CONSTANT ) {
                            offset = - U32Fetch( Constant64 );
                            NextToken();
                        }
                    }
                }
                switch( fixword ) {
                case FIXWORD_RELOFF:
#if _CPU == 8086
                    AddAFix( len, name, FIX_RELOFF16, offset );
                    len += 2;
#else
                    AddAFix( len, name, FIX_RELOFF32, offset );
                    len += 4;
#endif
                    break;
                case FIXWORD_OFFSET:
#if _CPU == 8086
                    AddAFix( len, name, FIX_OFF16, offset );
                    len += 2;
#else
                    AddAFix( len, name, FIX_OFF32, offset );
                    len += 4;
#endif
                    break;
                case FIXWORD_SEGMENT:
                    AddAFix( len, name, FIX_SEG, 0 );
                    len += 2;
                    break;
                }
            }
        }
        VbufSetLen( &code_buffer, len );
    }
    PPCTL_DISABLE_MACROS();
    uses_auto = AsmSysInsertFixups( &code_buffer );
    AsmSysFini();
    VbufFree( &code_buffer );
    return( uses_auto );
}
Esempio n. 21
0
static bool GetByteSeq( byte_seq **code )
/**************************************/
{
    unsigned char       buff[MAXIMUM_BYTESEQ + 32];
    char                *name;
    unsigned            offset;
    fix_words           fixword;
    bool                uses_auto;
    bool                too_many_bytes;
#if _CPU == 8086
    bool                use_fpu_emu = false;
#endif

    AsmSysInit( buff );
    PPCTL_ENABLE_MACROS();
    NextToken();
    too_many_bytes = false;
    uses_auto = false;
    offset = 0;
    name = NULL;
    for( ;; ) {
        if( CurToken == T_STRING ) {
#if _CPU == 8086
            AsmLine( Buffer, use_fpu_emu );
            use_fpu_emu = false;
#else
            AsmLine( Buffer, false );
#endif
            NextToken();
            if( CurToken == T_COMMA ) {
                NextToken();
            }
        } else if( CurToken == T_CONSTANT ) {
#if _CPU == 8086
            if( use_fpu_emu ) {
                AddAFix( AsmCodeAddress, NULL, FIX_SEG, 0 );
                use_fpu_emu = false;
            }
#endif
            AsmCodeBuffer[AsmCodeAddress++] = (unsigned char)Constant;
            NextToken();
        } else {
#if _CPU == 8086
            use_fpu_emu = false;
#endif
            fixword = FixupKeyword();
            if( fixword == FIXWORD_NONE )
                break;
            if( fixword == FIXWORD_FLOAT ) {
#if _CPU == 8086
                if( GET_FPU_EMU( ProcRevision ) ) {
                    use_fpu_emu = true;
                }
#endif
            } else { /* seg or offset */
                if( !IS_ID_OR_KEYWORD( CurToken ) ) {
                    CErr1( ERR_EXPECTING_ID );
                } else {
                    name = CStrSave( Buffer );
                    NextToken();
                    if( CurToken == T_PLUS ) {
                        NextToken();
                        if( CurToken == T_CONSTANT ) {
                            offset = Constant;
                            NextToken();
                        }
                    } else if( CurToken == T_MINUS ) {
                        NextToken();
                        if( CurToken == T_CONSTANT ) {
                            offset = -(int)Constant;
                            NextToken();
                        }
                    }
                }
                switch( fixword ) {
                case FIXWORD_RELOFF:
#if _CPU == 8086
                    AddAFix( AsmCodeAddress, name, FIX_RELOFF16, offset );
                    AsmCodeAddress += 2;
#else
                    AddAFix( AsmCodeAddress, name, FIX_RELOFF32, offset );
                    AsmCodeAddress += 4;
#endif
                    break;
                case FIXWORD_OFFSET:
#if _CPU == 8086
                    AddAFix( AsmCodeAddress, name, FIX_OFF16, offset );
                    AsmCodeAddress += 2;
#else
                    AddAFix( AsmCodeAddress, name, FIX_OFF32, offset );
                    AsmCodeAddress += 4;
#endif
                    break;
                case FIXWORD_SEGMENT:
                    AddAFix( AsmCodeAddress, name, FIX_SEG, 0 );
                    AsmCodeAddress += 2;
                    break;
                }
            }
        }
        if( AsmCodeAddress > MAXIMUM_BYTESEQ ) {
            if( !too_many_bytes ) {
                CErr1( ERR_TOO_MANY_BYTES_IN_PRAGMA );
                too_many_bytes = true;
            }
            AsmCodeAddress = 0;          // reset index to we don't overrun buffer
        }
    }
    PPCTL_DISABLE_MACROS();
    if( too_many_bytes ) {
        uses_auto = false;
    } else {
        uses_auto = InsertFixups( buff, AsmCodeAddress, code );
    }
    FreeAsmFixups();
    AsmSysFini();
    return( uses_auto );
}