Beispiel #1
0
static void typeSigAccessVar(   // ACCESS A DTOR, DEFAULT-CTOR, COPY-CTOR
    TYPE_SIG_ACCESS acc_var,    // - access type (variable)
    SYMBOL *a_sym,              // - addr[ symbol for item accessed ]
    ACCINFO *info )             // - access information
{
    SYMBOL sym;                 // - symbol for routine
    TYPE type;                  // - class type
    TOKEN_LOCN *err_locn;       // - error location
    boolean fill_out;           // - TRUE ==> fill out the entry

    sym = *a_sym;
    if( acc_var & info->acc ) {
        fill_out = info->acc & TSA_FILL_OUT;
        if( fill_out ) {
            SetCurrScope(info->class_scope);
        } else {
            SetCurrScope (info->access_scope);
        }
    } else {
        fill_out = TRUE;
        SetCurrScope(info->class_scope);
    }
    if( ( GetCurrScope() != info->class_scope ) || ( sym == NULL ) ) {
        type = info->type;
        err_locn = info->err_locn;
        switch( acc_var ) {
          case TSA_DTOR :
            sym = DtorFindLocn( type, err_locn );
            break;
          case TSA_DEFAULT_CTOR :
            sym = DefaultCtorFind( type, err_locn, fill_out );
            break;
          case TSA_COPY_CTOR :
            sym = CopyCtorFind( type, err_locn );
            break;
          default :
#ifndef NDEBUG
            CFatal( "typeSigAccessVar -- impossible type" );
#endif
            sym = NULL;
        }
        if( sym == NULL ) {
            if( ! fill_out ) {
                *info->err_occurred = TRUE;
            }
        } else {
            sym = ClassFunMakeAddressable( sym );
            sym->flag |= SF_ADDR_TAKEN;
            if( ! ( info->acc & TSA_NO_REF ) ) {
                if( acc_var & info->acc ) {
                    sym = SymMarkRefed( sym );
                }
            }
            *a_sym = sym;
            CDtorScheduleArgRemap( sym );
        }
    }
}
Beispiel #2
0
static void throwBaseCnv(       // CONVERSION TO A BASE CLASS
    SCOPE base,                 // - scope for base class
    void* dat )                 // - control area
{
    THROW_CNV_CTL *ctl;         // - control area

    ctl = dat;
    if( validateBase( base, ctl ) ) {
        SCOPE curr_scope = GetCurrScope();
        if( base->owner.type != ctl->src_type ) {
            SetCurrScope(base);
        }
        makeThrowCnv( ctl, ScopeClass( base ), ctl->offset );
        SetCurrScope(curr_scope);
    }
}
Beispiel #3
0
void ScopeGenAccessSet(         // SET ACCESS SCOPE FOR GENERATION
    TYPE cltype )               // - type for inlining
{
    DbgVerify( tempScope == NULL, "ScopeAccessSet -- tempScope != NULL" );
    tempScope = GetCurrScope();
    SetCurrScope (TypeScope( cltype ));
}
Beispiel #4
0
SCOPE ModuleInitResume(         // RESUME MODULE-INITIALIZATION FUNCTION
    void )
{
    SCOPE curr_scope;

    curr_scope = moduleInitSave();
    SetCurrScope(module_init_scope);
    return( curr_scope );
}
Beispiel #5
0
void RtnGenerate( void )
/**********************/
{
    RTN_GEN *c;
    bool keep_going = true;

    SetCurrScope( GetFileScope() );
    while( keep_going ) {
        keep_going = false;

        CtxSetCurrContext( CTX_FUNC_GEN );
        keep_going = ClassDefineRefdDefaults();

        ScopeEmitIndexMappings();

        while( useSYMBOL != NULL ) {
            c = useSYMBOL;
            useSYMBOL = c->next;
            keep_going = true;
            (*execSYMBOL[c->index])( c->parm );
            CarveFree( carveRTN_GEN, c );
        }
        while( useTYPE != NULL ) {
            c = useTYPE;
            useTYPE = c->next;
            keep_going = true;
            (*execTYPE[c->index])( c->parm );
            CarveFree( carveRTN_GEN, c );
        }
        CtxSetCurrContext( CTX_SOURCE );

        keep_going = TemplateProcessInstantiations() || keep_going;
        SetCurrScope( GetFileScope() );
    }

    TemplateFreeDefns();
}
Beispiel #6
0
void ModuleInitInit(            // START MODULE-INITIALIZATION FUNCTION
    void )
{
    SYMBOL module_init;         // - SYMBOL for mod-init. function
    SCOPE curr_scope;           // - current scope
    TYPE fn_type;               // - type for init function

    curr_scope = moduleInitSave();
    fn_type = TypeVoidFunOfVoid();
    module_init = SymCreateFileScope( fn_type
                                    , SC_STATIC
                                    , 0
                                    , CppSpecialName( SPECIAL_INIT_FUNCTION ) );
    module_init_func = module_init;
    SetCurrScope(GetFileScope());
    ScopeBeginFunction( module_init );
    FunctionBodyStartup( module_init, &module_fd, FUNC_NULL );
    module_fd.retn_opt = false;
    module_init_scope = GetCurrScope();
    ScopeKeep( module_init_scope );
    moduleInitRestore( curr_scope );
}
Beispiel #7
0
static void typeSigAccess(      // HANDLE ACCESS FOR TYPE-SIGNATURE
    TYPE_SIG_ACCESS acc,        // - access type
    TYPE_SIG *sig,              // - current signature
    TOKEN_LOCN* err_locn,       // - error location for access errors
    bool *error_occurred )      // - to set error indication
{
    ACCINFO info;               // - access information

    if( (TSA_GEN & acc) == 0 ) {
        info.acc = acc;
        info.type = StructType( sig->type );
        if( info.type != NULL ) {
            info.err_occurred = error_occurred;
            info.err_locn = err_locn;
            info.access_scope = GetCurrScope();
            info.class_scope = TypeScope( info.type );
            typeSigAccessVar( TSA_DTOR,         &sig->dtor,         &info );
            typeSigAccessVar( TSA_DEFAULT_CTOR, &sig->default_ctor, &info );
            typeSigAccessVar( TSA_COPY_CTOR,    &sig->copy_ctor,    &info );
            SetCurrScope(info.access_scope);
        }
    }
}
Beispiel #8
0
static void moduleInitRestore(  // RESTORE ENVIRONMENT AFTER MOD-INIT.
    SCOPE scope )               // - scope to restore to
{
    SetCurrScope(scope);
    LabelSwitchFunc( &module_fd.label_mem );
}
Beispiel #9
0
void ScopeGenAccessReset(       // RESET ACCESS SCOPE FOR GENERATION
    void )
{
    SetCurrScope (tempScope);
    tempScope = NULL;
}