Пример #1
0
unsigned StaticInitFuncBeg(     // START INITIALIZATION OF STATIC IN FUNCTION
    void )
{
    CGLABEL init_label;         // - label #
    INIT_VAR *init_var;

    CgFrontStatInit();
    init_var = FunctionBodyGetInit( NULL );
    if( init_var->var == NULL ) {
        init_var->var = staticInitFuncVar();
    } else {
        init_var->mask <<= 1;
        if( init_var->mask >= 0x100 ) {
            ++init_var->var->sym_type->u.a.array_size;
            init_var->mask = 1;
        }
    }
    if( CompFlags.bm_switch_used ) {
        SYMBOL rtf;
        rtf = RunTimeCallSymbol( RTF_STATIC_INIT );
        CgFrontSymbol( rtf );
        CgSetType( GetBasicType( TYP_SINT ) );
        CgFrontCodePtr( IC_CALL_SETUP, rtf );
        CgSetType( GetBasicType( TYP_SINT ) );
        CgFrontCodeUint( IC_LEAF_CONST_INT, init_var->mask );
        CgFrontCode( IC_CALL_PARM );
        moduleInitVar( init_var->var, false );
        CgFrontCode( IC_CALL_PARM );
        CgFrontCode( IC_CALL_EXEC );
    } else {
        moduleInitVar( init_var->var, true );
        CgFrontCodeUint( IC_OPR_UNARY, CO_FETCH );
        CgFrontCodeUint( IC_LEAF_CONST_INT, init_var->mask );
        CgFrontCodeUint( IC_OPR_BINARY, CO_AND );
    }
    CgFrontCodeUint( IC_LEAF_CONST_INT, 0 );
    CgFrontCodeUint( IC_OPR_BINARY, CO_NE );
    init_label = CgFrontLabelCs();
    CgFrontGotoNear( IC_LABEL_CS, O_IF_TRUE, init_label );
    if( !CompFlags.bm_switch_used ) {
        moduleInitVar( init_var->var, true );
        CgFrontCodeUint( IC_LEAF_CONST_INT, init_var->mask );
        CgFrontCodeUint( IC_OPR_BINARY, CO_OR_EQUAL );
        CgFrontCode( IC_EXPR_DONE );
    }
    return( init_label );
}
Пример #2
0
void CgFrontSymbol(             // EMIT A SYMBOL
    SYMBOL sym )                // - the symbol
{
    CGFILE_GEN *gen;            // - generation data

    gen = getGenData();
    gen->emit_type = sym->sym_type;
    CgSetType( sym->sym_type );
    CgFrontCodePtr( IC_LEAF_NAME_FRONT, sym );
}
Пример #3
0
static void moduleInitVar(      // GENERATE REFERENCE TO MODULE-INIT VAR.
    SYMBOL var,                 // - variable
    bool base_type )            // - base_type or pointer to it
{
    unsigned offset;            // - offset to be tested
    TYPE type;                  // - type for flags variable

    type = var->sym_type;
    offset = type->u.a.array_size - 1;
    if( offset != 0 ) {
        CgSetType( GetBasicType( TYP_UINT ) );
        CgFrontCodeUint( IC_LEAF_CONST_INT, offset );
        CgFrontSymbol( var );
        CgSetType( MakePointerTo( type->of ) );
        CgFrontCodeUint( IC_OPR_BINARY, CO_PLUS );
    } else {
        CgFrontSymbol( var );
    }
    if( base_type ) {
        CgSetType( type->of );
    } else {
        CgSetType( MakePointerTo( type->of ) );
    }
}