Ejemplo n.º 1
0
SYMBOL DefaultCtorFind(         // GET SYMBOL FOR DEFAULT CTOR
    TYPE type,                  // - class type
    TOKEN_LOCN* err_locn,       // - error location
    boolean optional )          // - TRUE ==> is optional
{
    unsigned retn;              // - return from attempt to find
    SYMBOL ctor;                // - constructor

    retn = ClassDefaultCtorFind( type, &ctor, err_locn );
    switch( retn ) {
      case CNV_OK :
        break;
      case CNV_IMPOSSIBLE :
        if( optional ) break;
        SetErrLoc( err_locn );
        CErr2p( ERR_NO_DEFAULT_INIT_CTOR, type );
        ctor = NULL;
        break;
      case CNV_AMBIGUOUS :
        if( optional ) break;
        SetErrLoc( err_locn );
        CErr2p( ERR_NO_UNIQUE_DEFAULT_CTOR, type );
        ctor = NULL;
        break;
      case CNV_ERR :
        ctor = NULL;
        break;
#ifndef NDEBUG
      default :
        CFatal( "DefaultCtorFind -- impossible return" );
#endif
    }
    return ctor;
}
Ejemplo n.º 2
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;
    }
}
Ejemplo n.º 3
0
static void FuncDefn( SYMPTR sym )
{
    SYM_NAMEPTR sym_name;
    size_t      sym_len;
    TYPEPTR     typ;

    /* duplicate name in near space */
    sym_name = SymName( sym, CurFuncHandle );
    sym_len = strlen( sym_name ) + 1;
    sym->name = CMemAlloc( sym_len );
    memcpy( sym->name, sym_name, sym_len );
    if( sym->flags & SYM_DEFINED ) {
        CErr2p( ERR_SYM_ALREADY_DEFINED, sym->name );
    }
    typ = sym->sym_type->object;                /* get return type */
    SKIP_TYPEDEFS( typ );

    if( typ->decl_type != TYPE_VOID ) {
        if( TypeSize( typ ) == 0 ) {
            CErr2p( ERR_INCOMPLETE_TYPE, sym_name );
        }
    }
    sym->flags |= SYM_DEFINED /* | SYM_REFERENCED */;

    if( (GenSwitches & NO_OPTIMIZATION) == 0 ) {
        sym->flags |= SYM_OK_TO_RECURSE;
    }

    if( sym->attribs.stg_class == SC_EXTERN || sym->attribs.stg_class == SC_FORWARD ) {
        sym->attribs.stg_class = SC_NONE;       /* indicate exported function */
    }

    CompFlags.external_defn_found = 1;
    if( Toggles & TOGGLE_CHECK_STACK )
        sym->flags |= SYM_CHECK_STACK;

    if( !CompFlags.zu_switch_used ) {
        if( (sym->mods & FLAG_INTERRUPT) == FLAG_INTERRUPT ) {
            /* interrupt function */
            TargetSwitches |= FLOATING_SS;      /* force -zu switch on */
        } else {
            TargetSwitches &= ~FLOATING_SS;     /* turn it back off */
        }
    }
    if( CMPLIT( CurFunc->name, "main" ) == 0 || CMPLIT( CurFunc->name, "wmain" ) == 0 ) {
        sym->mods &= ~MASK_LANGUAGES;  // Turn off any language flags
        sym->mods |= LANG_WATCALL;     // Turn on __watcall calling convention for main
    }
    SymReplace( sym, CurFuncHandle );
}
Ejemplo n.º 4
0
static REWRITE *defArgError( REWRITE *r, TOKEN_LOCN *locn )
{
    CErr1( ERR_DEF_ARG_REWRITE_ERROR );
    CErr2p( INF_DEF_ARG_STARTED_HERE, locn );
    RewriteFree( r );
    return( NULL );
}
Ejemplo n.º 5
0
static REWRITE *memInitError( REWRITE *r, TOKEN_LOCN *locn )
{
    CErr1( ERR_MEM_INIT_REWRITE_ERROR );
    CErr2p( INF_CTOR_INIT_STARTED_HERE, locn );
    RewriteFree( r );
    return( NULL );
}
Ejemplo n.º 6
0
static int GrabLabels( void )
{
    LABELPTR    label;

    label = NULL;
    for( ;; ) {
        if( CurToken == T_SAVED_ID ) {          /* 09-jul-95 */
            SrcLoc = SavedTokenLoc;
        } else {
            SrcLoc = TokenLoc;
            if( CurToken != T_ID ) break;
            LookAhead();
        }
        if( LAToken != T_COLON ) break; /* quit if look ahead not : */
        label = LkLabel( SavedId );
        if( label->defined != 0 ) {
            CErr2p( ERR_LABEL_ALREADY_DEFINED, label->name );
        } else {
            DropLabel( label->ref_list );
            label->defined = 1;         /* indicate label defined now */
        }
        CMemFree( SavedId );            /* free the saved id */
        SavedId = NULL;
        NextToken();                    /* get next token */
    }
    if( label != NULL ) {                       /* label was found */
        if( CurToken == T_RIGHT_BRACE ) {
            CErr1( ERR_STMT_REQUIRED_AFTER_LABEL );
        }
        return( 1 );                    // indicate label found
    }
    return( 0 );
}
Ejemplo n.º 7
0
hw_reg_set PragRegName(         // GET REGISTER NAME
    char *str )                 // - register
{
    register int index;
    register char *p;
    hw_reg_set      name;

    if( *str == '\0' ) {
        HW_CAsgn( name, HW_EMPTY );
        return( name );
    }
    if( *str == '_' ) {
        ++str;
        if( *str == '_' ) {
            ++str;
        }
    }
    index = 0;
    p = Registers;
    while( *p != '\0' ) {
        if( stricmp( p, str ) == 0 )
            return( RegBits[ index ] );
        index++;
        while( *p++ != '\0' ) {
            ;
        }
    }
    if( strcmp( str, "8087" ) == 0 ) {
        HW_CAsgn( name, HW_FLTS );
    } else {
        CErr2p( ERR_BAD_REGISTER_NAME, str );
        HW_CAsgn( name, HW_EMPTY );
    }
    return( name );
}
Ejemplo n.º 8
0
hw_reg_set PragRegName( const char *str, size_t len )
/***************************************************/
{
    int             index;
    hw_reg_set      name;

    if( len != 0 ) {
        if( *str == '_' ) {
            ++str;
            --len;
            if( *str == '_' ) {
                ++str;
                --len;
            }
        }
        // search register or alias name
        index = PragRegIndex( Registers, str, len, true );
        if( index != -1 ) {
            return( RegBits[RegMap[index]] );
        }
        if( len == 4 && memcmp( str, "8087", 4 ) == 0 ) {
            HW_CAsgn( name, HW_FLTS );
            return( name );
        }
        CErr2p( ERR_BAD_REGISTER_NAME, str );
    }
    HW_CAsgn( name, HW_EMPTY );
    return( name );
}
Ejemplo n.º 9
0
static REWRITE *templateError( REWRITE *r, TOKEN_LOCN *locn )
{
    CErr1( ERR_CLASS_TEMPLATE_REWRITE_ERROR );
    CErr2p( INF_CLASS_TEMPLATE_STARTED_HERE, locn );
    RewriteFree( r );
    return( NULL );
}
Ejemplo n.º 10
0
static void AddCaseLabel( unsigned long value )
{
    CASEPTR         ce, prev_ce, new_ce;
    unsigned long   old_value, converted_value;
    TREEPTR         tree;
    char            buffer[12];

    prev_ce = NULL;
#if 0
    leaf.u.ulong_konst = value;
    leaf.data_type = SwitchStack->case_type;
    SetLeafType( &leaf, 1 );
//      converted_value = value & SwitchStack->case_mask;
    converted_value = leaf.u.ulong_konst;
#else
    converted_value = value;
#endif
    old_value = converted_value + 1;  /* make old_value different */
    for( ce = SwitchStack->case_list; ce; ce = ce->next_case ) {
        old_value = ce->value;
        if( old_value >= converted_value ) break;
        prev_ce = ce;
    }
    if( converted_value == old_value ) {   /* duplicate case value found */
        sprintf( buffer, SwitchStack->case_format, value );
        CErr2p( ERR_DUPLICATE_CASE_VALUE, buffer );
    } else {
        new_ce = (CASEPTR)CMemAlloc( sizeof( CASEDEFN ) );
        new_ce->value = converted_value;
        if( prev_ce == NULL ) {
            new_ce->next_case = SwitchStack->case_list;
            SwitchStack->case_list = new_ce;
        } else {
            prev_ce->next_case = new_ce;
            new_ce->next_case = ce;
        }
        /* Check if the previous statement was a 'case'. If so, reuse the label, as generating
         * too many labels seriously slows down code generation.
         */
        if( prev_ce && LastStmt->op.opr == OPR_STMT && LastStmt->right->op.opr == OPR_CASE ) {
            new_ce->label = SwitchStack->last_case_label;
            new_ce->gen_label = FALSE;
        } else {
            new_ce->label = NextLabel();
            new_ce->gen_label = TRUE;
        }
        SwitchStack->number_of_cases++;
        if( converted_value < SwitchStack->low_value ) {
            SwitchStack->low_value = converted_value;
        }
        if( converted_value > SwitchStack->high_value ) {
            SwitchStack->high_value = converted_value;
        }
        SwitchStack->last_case_label = new_ce->label;
        tree = LeafNode( OPR_CASE );
        tree->op.case_info = new_ce;
        AddStmt( tree );
    }
}
Ejemplo n.º 11
0
int ExpectingConstant( void )
{
    if( CurToken == T_CONSTANT ) {
        return( 1 );
    }
    CErr2p( ERR_EXPECTING_CONSTANT_BUT_FOUND, NameOfCurToken() );
    return( 0 );
}
Ejemplo n.º 12
0
extern bool MacroDel( char *name )
/********************************/
{
    MEPTR       mentry;
    MEPTR       prev_entry;
    int         len;
    bool        ret;

    ret = FALSE;
    if( strcmp( name, "defined" ) == 0 ) {
        CErr2p( ERR_CANT_UNDEF_THESE_NAMES, name  );
        return( ret );
    }
    prev_entry = NULL;
    len = strlen( name ) + 1;
    mentry = MacHash[ MacHashValue ];
    while( mentry != NULL ) {
        if( memcmp( mentry->macro_name, name, len ) == 0 )
            break;
        prev_entry = mentry;
        mentry = mentry->next_macro;
    }
    if( mentry != NULL ) {
        if( mentry->macro_defn == 0 ) {
            CErr2p( ERR_CANT_UNDEF_THESE_NAMES, name );
        } else {
            if( prev_entry != NULL ) {
                prev_entry->next_macro = mentry->next_macro;
            } else {
                MacHash[ MacHashValue ] = mentry->next_macro;
            }
            if( (InitialMacroFlag & MFLAG_DEFINED_BEFORE_FIRST_INCLUDE) == 0 ) {
                /* remember macros that were defined before first include */
                if( mentry->macro_flags & MFLAG_DEFINED_BEFORE_FIRST_INCLUDE ) {
                    mentry->next_macro = UndefMacroList;
                    UndefMacroList = mentry;
                }
            }
            ret = TRUE;
        }
    }
    return( ret );
}
Ejemplo n.º 13
0
void PragmaExtrefsValidate      // VALIDATE EXTREFS FOR PRAGMAS
    ( void )
{
    PRAG_EXT_REF* entry;        // - current entry

    RingIterBeg( pragmaExtrefs, entry ) {
        if( entry->symbol != NULL ) {
            SYMBOL symbol = entry->symbol;
            if( SymIsExtern( symbol ) ) {
                if( IsOverloadedFunc( symbol ) ) {
                    CErr2p( ERR_PRAG_EXTREF_OVERLOADED, symbol );
                    entry->symbol = NULL;
                }
            } else {
                CErr2p( ERR_PRAG_EXTREF_EXTERN, symbol );
                entry->symbol = NULL;
            }
        }
    } RingIterEnd( entry );
}
Ejemplo n.º 14
0
static LINKAGE checkLinkage( char *name )
{
    LINKAGE p;

    p = findLinkage( name );
    if( p != NULL ) {
        return( p );
    }
    CErr2p( ERR_UNKNOWN_LINKAGE, name );
    return( CppLinkage );
}
Ejemplo n.º 15
0
// forms: #pragma extref( symbol [, ...] )
//        #pragma extref( "name" [, ...] )
//
// causes a external reference to be emitted for the symbol or "name"
//
static void parseExtRef(     // PARSE SYMBOL NAME
    void )
{
    PRAG_EXT_REF *entry;

    if( CurToken == T_STRING ) {
        entry = RingAlloc( &pragmaExtrefs, offsetof( PRAG_EXT_REF, name ) + TokenLen + 1 );
        memcpy( entry->name, Buffer, TokenLen + 1 );
        entry->symbol = NULL;
    } else if( IS_ID_OR_KEYWORD( CurToken ) ) {
        SEARCH_RESULT* result;
        NAME name = NameCreateLen( Buffer, TokenLen );

        result = ScopeFindNaked( GetCurrScope(), name );
        if( result == NULL ) {
            CErr2p( ERR_PRAG_EXTREF_NONE, Buffer );
        } else {
            SYMBOL_NAME sname = result->sym_name;
            SYMBOL sym = sname->name_syms;
            ScopeFreeResult( result );
            if( sym == NULL ) {
                CErr2p( ERR_PRAG_EXTREF_BAD, Buffer );
            } else if( SymIsFunction( sym ) ) {
                if( IsOverloadedFunc( sym ) ) {
                    CErr2p( ERR_PRAG_EXTREF_OVERLOADED, sym );
                    sym = NULL;
                }
            } else if( SymIsData( sym ) ) {
                // no checks now
            } else {
                CErr2p( ERR_PRAG_EXTREF_BAD, sym );
                sym = NULL;
            }
            if( sym != NULL ) {
                entry = RingAlloc( &pragmaExtrefs, offsetof( PRAG_EXT_REF, name ) + 1 );
                entry->symbol = sym;
                entry->name[0] = '\0';
            }
        }
    }
}
Ejemplo n.º 16
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();
    }
}
Ejemplo n.º 17
0
local void FuncDefn( SYMPTR sym )
{
    SYM_NAMEPTR sym_name;
    int         sym_len;
    TYPEPTR     typ;

    /* duplicate name in near space */
    sym_name = SymName( sym, CurFuncHandle );
    sym_len = far_strlen_plus1( sym_name );
    sym->name = CMemAlloc( sym_len );
    far_memcpy( sym->name, sym_name, sym_len );
    if( sym->flags & SYM_DEFINED ) {
        CErr2p( ERR_SYM_ALREADY_DEFINED, sym->name );   /* 03-aug-88 */
    }
    typ = sym->sym_type->object;                /* get return type */
    SKIP_TYPEDEFS( typ );

    if( typ->decl_type != TYPE_VOID ) {         /* 26-mar-91 */
        if( TypeSize( typ ) == 0 ) {
            CErr( ERR_INCOMPLETE_TYPE, sym_name );
        }
    }
    sym->flags |= /*SYM_REFERENCED | 18-jan-89 */ SYM_DEFINED;

    if( !(GenSwitches & NO_OPTIMIZATION) ) {
        sym->flags |= SYM_OK_TO_RECURSE;                /* 25-sep-91 */
    }

    if( sym->stg_class == SC_EXTERN  ||  sym->stg_class == SC_FORWARD ) {
        sym->stg_class = SC_NULL;       /* indicate exported function */
    }

    CompFlags.external_defn_found = 1;
    if( Toggles & TOGGLE_CHECK_STACK )
        sym->flags |= SYM_CHECK_STACK;

    if( !CompFlags.zu_switch_used ) {
        if( (sym->attrib & FLAG_INTERRUPT) == FLAG_INTERRUPT ) {
            /* interrupt function */
            TargetSwitches |= FLOATING_SS;      /* force -zu switch on */
        } else {
            TargetSwitches &= ~FLOATING_SS;     /* turn it back off */
        }
    }
    if( strcmp( CurFunc->name, "main" ) == 0 || strcmp( CurFunc->name, "wmain" ) == 0 ) {
        sym->attrib &= ~FLAG_LANGUAGES;  // Turn off any language flags
        sym->attrib |= LANG_WATCALL;     // Turn on __watcall calling convention for main
    }
    SymReplace( sym, CurFuncHandle );
}
Ejemplo n.º 18
0
static void pragDumpObjectModel( // DUMP OBJECT MODEL
    void )
{
    if( IS_ID_OR_KEYWORD( CurToken ) ) {
        NAME name = NameCreateLen( Buffer, TokenLen );
        SEARCH_RESULT* result = ScopeFindNaked( GetCurrScope(), name );
        if( result == NULL ) {
            CErr2p( ERR_DUMP_OBJ_MODEL, Buffer );
        } else {
            SYMBOL_NAME sname = result->sym_name;
            ScopeFreeResult( result );
            if( sname->name_syms == NULL ) {
                TYPE type = sname->name_type->sym_type;
                if( TypeDefined( type ) ) {
                    TYPE dump_type;
                    dump_type = StructType( type );
                    if( dump_type != NULL ) {
                        DumpObjectModelClass( dump_type );
                    } else {
                        dump_type = EnumType( type );
                        if( dump_type != NULL ) {
                            DumpObjectModelEnum( dump_type );
                        } else {
                            CErr2p( ERR_DUMP_OBJ_MODEL, Buffer );
                        }
                    }
                } else {
                    CErr2p( ERR_DUMP_OBJ_MODEL, Buffer );
                }
            } else {
                CErr2p( ERR_DUMP_OBJ_MODEL, Buffer );
            }
        }
        NextToken();
    }
}
Ejemplo n.º 19
0
void PCHWarn2p( MSG_NUM msg, void *p )
/************************************/
{
    if( CompFlags.no_pch_warnings ) {
        return;
    }
    if( CompFlags.fhr_switch_used ) {
        return;
    }
    if( CompFlags.fhwe_switch_used ) {
        CWarnDontCount( msg, p );
    } else {
        CErr2p( msg, p );
    }
}
Ejemplo n.º 20
0
/* splits the dataquad pointed to by dql so that the current one
   will have size "size" and the new one "oldsize - size" */
local void SplitDataQuad( DATA_QUAD_LIST *dql, unsigned long size )
{
    DATA_QUAD_LIST  *ndql;
    DATA_QUAD       *ndq;
    DATA_QUAD       *dq;
    unsigned long   oldsize;

    ndql = NewDataQuad();
    ndql->next = dql->next;
    ndql->prev = dql;
    dql->next = ndql;
    if( ndql->next != NULL )
        ndql->next->prev = ndql;
    oldsize = dql->size;
    ndql->size = oldsize - size;
    dql->size = size;

    ndq = &ndql->dq;
    dq = &dql->dq;
    memcpy( ndq, dq, sizeof( *dq ) );

    if( dq->flags & Q_DATA ) {
        if( dq->flags & Q_2_INTS_IN_ONE ) {
            dq->flags = ndq->flags = Q_DATA;
            ndq->u.long_values[0] = dq->u.long_values[1];
            ndq->u.long_values[1] = dq->u.long_values[1] = 0;
            size = 0;
        } else if( dq->flags & Q_REPEATED_DATA ) {
            dq->u.long_values[1] = size / (oldsize / dq->u.long_values[1]);
            ndq->u.long_values[1] -= dq->u.long_values[1];
            size = 0;
        } else if( dq->type == QDT_CONSTANT ) {
            dq->u.long_values[0] = size;
            ndq->u.long_values[0] -= dq->u.long_values[0];
            size = 0;
        } else if( dq->type == QDT_CONST ) {
            dq->u.string_leaf->length = size;
            ndq->u.string_leaf->literal += size;
            ndq->u.string_leaf->length = oldsize - size;
            size = 0;
        }
    }
    if( size != 0 ) {
        /* can't happen ! */
        CErr2p( ERR_FATAL_ERROR, "Bad initializer quad" );
        CSuicide();
    }
}
Ejemplo n.º 21
0
static void parseExtRef ( void )
/******************************/
{
    SYM_HANDLE   extref_sym;

    if( CurToken == T_STRING ) {
        AddExtRefN( Buffer );
    } else {
        extref_sym = SymLook( HashValue, Buffer );
        if( extref_sym != NULL ) {
            AddExtRefS( extref_sym );
        } else {
            CErr2p( ERR_UNDECLARED_SYM, Buffer );
        }
    }
}
Ejemplo n.º 22
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 );
    }
}
Ejemplo n.º 23
0
static fe_seg_id cgSegIdBased( SYMBOL sym, type_flag flags )
{
    fe_seg_id       id;         // - segment id
    target_offset_t align;      // - alignment for symbol
    target_size_t   size;       // - size of symbol
    TYPE            base_mod;   // - __based modifier

    size = CgMemorySize( sym->sym_type );
    #ifdef _CHECK_SIZE      // only defined if needed
        if( !(flags & TF1_HUGE) ) {
            if( _CHECK_SIZE( size ) ) {
                CErr2p( ERR_DATA_TOO_BIG, sym );
                return( SEG_NULL );
            }
        }
    #endif

    if( SymIsExtern( sym ) ) {
        // not defined in this compilation unit
        id = SegmentImport();
    } else {
        switch( flags & TF1_BASED ) {
        case TF1_BASED_STRING:
            id = SegmentFindBased( sym->sym_type );
            break;
        case TF1_BASED_SELF:
        case TF1_BASED_VOID:
            id = SEG_NULL;
            break;
        case TF1_BASED_FETCH:
        case TF1_BASED_ADD:
            base_mod = BasedType( sym->sym_type );
            id = CgSegIdData( (SYMBOL)base_mod->u.m.base, SI_DEFAULT );
            break;
        DbgDefault( "invalid based cgsegid call" );
        }
        if( id != SEG_NULL ) {
            align = cgSegIdAlign( sym, flags );
            id = SegmentAddSym( sym, id, size, align );
        }
    }
    return( id );
}
Ejemplo n.º 24
0
static void CError( void )
{
    size_t      len;
    bool        save;

    len = 0;
    while( CurrChar != '\n' && CurrChar != '\r' && CurrChar != EOF_CHAR ) {
        if( len != 0 || CurrChar != ' ' ) {
            Buffer[len++] = CurrChar;
        }
        NextChar();
    }
    Buffer[len] = '\0';
    /* Force #error output to be reported, even with preprocessor */
    save = CompFlags.cpp_output;
    CompFlags.cpp_output = FALSE;
    CErr2p( ERR_USER_ERROR_MSG, Buffer );
    CompFlags.cpp_output = save;
}
Ejemplo n.º 25
0
static fe_seg_id cgSegIdVariable( SYMBOL sym, type_flag flags, SEGID_CONTROL control )
{
    fe_seg_id id;
    target_size_t size;

    size = CgMemorySize( sym->sym_type );
    #ifdef _CHECK_SIZE      // only defined if needed
        if( !(flags & TF1_HUGE) ) {
            if( _CHECK_SIZE( size ) ) {
                CErr2p( ERR_DATA_TOO_BIG, sym );
                return( SEG_NULL );
            }
        }
    #endif
    if( flags & TF1_NEAR ) {
        id = cgSegIdNearVariable( sym, flags, size, control );
    } else if( flags & TF1_HUGE ) {
        id = cgSegIdHugeVariable( sym, flags, size, control );
    } else if( flags & TF1_FAR ) {
        id = cgSegIdFarVariable( sym, flags, size, control );
    } else {
        boolean assume_near = TRUE;
        if( IsBigData() ) {
            if( flags & TF1_DEFAULT_FAR ) {
                assume_near = FALSE;
            } else if( size == 0 || size > DataThreshold ) {
                assume_near = FALSE;
            } else if( CompFlags.zc_switch_used ) {
                if( cgSegIdConst( sym, flags, control ) ) {
                    // symbol may have been placed in code segment
                    assume_near = FALSE;
                }
            }
        }
        if( assume_near ) {
            id = cgSegIdNearVariable( sym, flags, size, control );
        } else {
            id = cgSegIdFarVariable( sym, flags, size, control );
        }
    }
    return( id );
}
Ejemplo n.º 26
0
void LoadUnicodeTable( unsigned codePage )
{
    FILE        *fp;
    char        filename[20];

    sprintf( filename, "unicode.%3.3u", codePage );
    if( filename[11] != '\0' ) {
        filename[7] = filename[8];
        filename[8] = '.';
    }
    fp = OpenUnicodeFile( filename );
    if( fp != NULL ) {
        ReadUnicodeFile( fp );
        fclose( fp );
    } else {
        CBanner();
        CErr2p( ERR_CANT_OPEN_FILE, filename );
    }
    return;
}
Ejemplo n.º 27
0
local void CError( void )
{
    int i;
    int save;

    i = 0;
    while( CurrChar != '\n' && CurrChar != '\r' && CurrChar != EOF_CHAR ) {
        if( i != 0 || CurrChar != ' ' ) {
            Buffer[ i ] = CurrChar;
            ++i;
        }
        NextChar();
    }
    Buffer[ i ] = '\0';
    /* Force #error output to be reported, even with preprocessor */
    save = CompFlags.cpp_output;
    CompFlags.cpp_output = 0;
    CErr2p( ERR_USER_ERROR_MSG, Buffer );
    CompFlags.cpp_output = save;
}
Ejemplo n.º 28
0
char *BadCmdLine( int error_code, const char *str )
{
    char        *p;
    auto char   buffer[128];

    p = buffer;
    for( ; *str != '\0'; ) {
        *p++ = *str++;
        if( *str == ' ' )
            break;
        if( *str == '-' )
            break;
        if( *str == SwitchChar ) {
            break;
        }
    }
    *p = '\0';
    CBanner();
    CErr2p( error_code, buffer );
    return( (char *)str );
}
Ejemplo n.º 29
0
static void displayDiagInfo(    // DISPLAY DIAG_INFO FOR ARGUMENT
    DIAG_INFO* diag,            // - diagnostic information
    unsigned msg,               // - error message
    PTREE expr,                 // - expression
    SYMBOL orig )               // - original function
{
    ConversionTypesSet( diag->bad_src, diag->bad_tgt );
    PTreeErrorExpr( expr, msg  );
    InfSymbolDeclaration( orig );
    if( diag->bad_parm == 0 ) {
        CErr1( INF_THIS_MISMATCH );
        ConversionDiagnoseInf();
    } else if( diag->bad_fn == NULL ) {
        displayParmMismatch( diag );
        ConversionDiagnoseInf();
    } else {
        displayParmMismatch( diag );
        CErr2p( INF_BAD_FN_OVERLOAD, diag->bad_fn );
        ConversionDiagnoseInfTgt();
    }
}
Ejemplo n.º 30
0
static void loadUnicodeTable( unsigned code_page )
{
    unsigned amt;
    int fh;
    char filename[ 20 ];

    sprintf( filename, "unicode.%3.3u", code_page );
    if( filename[ 11 ] != '\0' ) {
        filename[ 7 ] = filename[ 8 ];
        filename[ 8 ] = '.';
    }
    fh = openUnicodeFile( filename );
    if( fh != -1 ) {
        amt = 256 * sizeof( unsigned short );
        if( (unsigned)read( fh, UniCode, amt ) != amt ) {
            CErr( ERR_IO_ERR, filename, strerror( errno ) );
        }
        close( fh );
    } else {
        CErr2p( ERR_CANT_OPEN_FILE, filename );
    }
}