示例#1
0
PTREE MakeDeleteCall(   // MAKE A CALL TO 'OPERATOR DELETE'
    SYMBOL del_sym,     // - symbol for 'op del'
    PTREE ptr,          // - parm 1 for delete
    TYPE class_parm )   // - if non-NULL, use size as second parm
{
    PTREE size_arg;     // - size argument for call
    PTREE args;         // - arguments for call
    PTREE expr;         // - final expression
    arg_list *del_args; // - op del arguments

    del_args = SymFuncArgList( del_sym );
    args = NULL;
    if( class_parm != NULL ) {
        size_arg = NodeOffset( class_parm->u.c.info->size );
        size_arg = NodeConvert( del_args->type_list[1], size_arg );
        args = NodeArgument( args, size_arg );
    }
    ptr = NodeConvert( del_args->type_list[0], ptr );
    args = NodeArgument( args, ptr );
    expr = NodeMakeCall( del_sym, GetBasicType( TYP_VOID ), NULL );
    expr = CallArgsArrange( del_sym->sym_type
                          , expr
                          , args
                          , NULL
                          , NULL
                          , NULL );
    return expr;
}
示例#2
0
static SYMBOL getSymInScope(    // GET A SYMBOL IN A SCOPE
    SCOPE scope,                // - the scope
    SYMBOL orig )               // - original symbol
{
    SEARCH_RESULT *result;      // - search result for symbol
    SYMBOL sym;                 // - the symbol
    arg_list *alist;            // - arguments for function
    NAME name;                  // - symbol name

    name = orig->name->name;
    alist = SymFuncArgList( orig );
    if( name == CppConversionName() ) {
        result = ScopeFindScopedMemberConversion( scope
                                                , scope
                                                , SymFuncReturnType( orig )
                                                , alist->qualifier
                                                );
        if( result == NULL ) {
            sym = NULL;
        } else {
            sym = result->sym;
            ScopeFreeResult( result );
            if( sym != NULL ) {
                if( SymScope( sym ) != scope ) {
                    sym = NULL;
                }
            }
        }
    } else {
        result = ScopeContainsMember( scope, name );
        if( result == NULL ) {
            sym = NULL;
        } else {
            sym = result->sym_name->name_syms;
            // we may have found a type-name, so check for NULL
            if( sym != NULL && SymIsFunction( sym ) ) {
                switch( FuncOverloaded( &sym
                                      , result
                                      , sym
                                      , alist
                                      , NULL ) ) {
                case FNOV_NONAMBIGUOUS :
                    break;
                default :
                    sym = NULL;
                    break;
                }
            } else {
                sym = NULL;
            }
            ScopeFreeResult( result );
        }
    }
    return( sym );
}
示例#3
0
static void buildDiagInfo(      // BUILD DIAG_INFO FOR ARGUMENT
    DIAG_INFO *diag,            // - diagnostic information
    PTREE arg,                  // - expression for argument
    int bad_parm,               // - index of erroneous parameter
    SYMBOL fun )                // - function for argument
{
    arg_list* alist;            // - function args
    unsigned num_args;          // - # args

    diag->bad_parm = bad_parm + 1;
    alist = SymFuncArgList( fun );
    num_args = alist->num_args;
    if( bad_parm >= num_args ) {
        TYPE last_arg = alist->type_list[ num_args - 1 ];
        if( last_arg->id == TYP_DOT_DOT_DOT ) {
            diag->bad_tgt = last_arg;
        } else {
            diag->bad_tgt = NULL;
        }
    } else {
        diag->bad_tgt = alist->type_list[ bad_parm ];
    }
    PTreeExtractLocn( arg, &diag->location );
    if( PointerToFuncEquivalent( arg->type ) ) {
        PTREE operand;  // - argument operand
        operand = arg;
        if( NodeIsUnaryOp( operand, CO_ADDR_OF ) ) {
            operand = PTreeOpLeft( operand );
        }
        if( operand->op == PT_SYMBOL ) {
            diag->bad_fn = operand->u.symcg.symbol;
            if( IsActualOverloadedFunc( diag->bad_fn
                                      , operand->u.symcg.result ) ) {
                diag->bad_src = NULL;
            } else {
                diag->bad_fn = NULL;
                diag->bad_src = NodeType( arg );
            }
        } else {
            diag->bad_fn = NULL;
            diag->bad_src = NodeType( arg );
        }
    } else {
        diag->bad_fn = NULL;
        diag->bad_src = NodeType( arg );
    }
}
示例#4
0
SE* DtorForDelBeg(              // DTORING AREA TO BE DELETED: start
    FN_CTL* fctl,               // - function information
    target_size_t elem_size,    // - size of one element in area
    unsigned dlt1,              // - entry type when one arg
    unsigned dlt2,              // - entry type when two args
    SYMBOL op_del )             // - operator delete to be used
{
    SE* se_dlt;                 // - entry allocated
    SYMBOL var;                 // - var containing address of delete area
    cg_name top_expr;           // - top expression
    cg_type top_type;           // - type of top expression
    cg_name emit;               // - expression for state update
    patch_handle patch;         // - patch handle for area

    if( DtmTabular( fctl ) ) {
        if( 2 == SymFuncArgList( op_del )->num_args ) {
            se_dlt = SeAlloc( dlt2 );
            se_dlt->del_2_array.size = elem_size;
        } else {
            se_dlt = SeAlloc( dlt1 );
        }
        se_dlt->del_1_array.op_del = op_del;
        var = CgVarRw( TY_POINTER, SC_AUTO );
        if( se_dlt->base.gen ) {
            AutoRelRegister( var, &se_dlt->del_1_array.offset );
        }
        top_expr = CgExprPopType( &top_type );
        top_expr = CGLVAssign( CgSymbol( var ), top_expr, top_type );
        top_expr = CgFetchType( top_expr, top_type );
        emit = emitPatch( &patch );
        top_expr = emitPatchCallBack( top_expr
                                    , emit
                                    , top_type
                                    , &patchForDtorDelBeg
                                    , patch
                                    , se_dlt );
        CgExprPush( top_expr, top_type );
        DbgSetState( "patchForDtorDelBeg", se_dlt );
    } else {
        se_dlt = NULL;
    }
    return se_dlt;
}