Esempio n. 1
0
static boolean adjustForVirtualCall( // ADJUSTMENTS FOR POSSIBLE VIRTUAL CALL
    PTREE *this_node,           // - addr[ "this" node ]
    PTREE *routine,             // - routine to be called
    SEARCH_RESULT *result )     // - search result for routine
{
    SYMBOL sym;                 // - symbol for call
    unsigned retn;              // - return: TRUE ==> adjusted for virtual
    TYPE this_type;             // - target type for "this"
    PTREE expr;                 // - transformed expression
    boolean exact_call;         // - TRUE ==> this node is exact

    expr = *this_node;
    this_type = NodeType( expr );
    this_type = StructType( this_type );
    if( this_type != NULL ) {
        if( OMR_CLASS_VAL == ObjModelArgument( this_type ) ) {
            expr = NodeAssignTemporary( this_type, expr );
        } else {
            expr = NodeConvert( MakePointerTo( expr->type ), expr );
        }
        *this_node = expr;
    }
    sym = (*routine)->u.symcg.symbol;
    this_type = TypeThisForCall( expr, sym );
    /* virtual calls don't have to check for NULL pointers when they convert */
    expr->flags |= PTF_PTR_NONZERO;
    exact_call = expr->flags & PTF_MEMORY_EXACT;
    NodeConvertToBasePtr( this_node, this_type, result, TRUE );
    sym = SymDefaultBase( sym );
    if( ( SymIsVirtual( sym ) )
      &&( ! ( (*routine)->flags & PTF_COLON_QUALED ) )
      &&( ! exact_call ) ) {
        expr = AccessVirtualFnAddress( NodeDupExpr( this_node )
                                     , result
                                     , sym );
        expr->type = MakePointerTo( expr->type );
        *routine = NodeReplace( *routine, expr );
        retn = TRUE;
    } else {
        NodeFreeSearchResult( *routine );
        retn = FALSE;
    }
    return( retn );
}
Esempio n. 2
0
void CallDiagNoMatch(           // DIAGNOSE NO MATCHES FOR CALL
    PTREE expr,                 // - call expression
    unsigned msg_one,           // - message: one function
    unsigned msg_many,          // - message: many functions
    PTREE this_node,            // - this node (or NULL)
    SYMBOL orig,                // - original symbol for overloading
    FNOV_DIAG *fnov_diag )      // - overload diagnosis information
{
    DIAG_INFO diag;             // - diagnostic information
    PTREE arg;                  // - argument that didn't match
    int bad_parm;               // - index of bad argument

    switch( fnov_diag->num_candidates ) {
      case 0 :
        if( SymIsFunctionTemplateModel( orig ) ) {
            PTreeErrorExprSym( expr, ERR_TEMPLATE_FN_MISMATCH, orig );
        } else {
            PTreeErrorExprSym( expr, ERR_PARM_COUNT_MISMATCH, orig );
        }
        break;
      case 1 :
        if( ! SymIsFunctionTemplateModel( orig ) ) {
            bad_parm = FnovRejectParm( fnov_diag );
            if( bad_parm == -1 ) {
                diag.bad_parm = 0;
                diag.bad_src = NodeType( this_node );
                diag.bad_tgt = TypeThisForCall( this_node, orig );
            } else {
                arg = diagnoseArg( expr, bad_parm );
                orig = pickCorrectFunction( orig, expr );
                buildDiagInfo( &diag, arg, bad_parm, orig );
            }
            displayDiagInfo( &diag, msg_one, expr, orig );
            break;
        }
        // fall through
      default :
        CallDiagnoseRejects( expr, msg_many, fnov_diag );
        break;
    }
}