Changeset bb87dd0


Ignore:
Timestamp:
Nov 24, 2020, 5:48:06 PM (10 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
4702a2c
Parents:
4a359e2
Message:

Fixing test init1-ERROR on new ast. Applying equivalent of b81fd95, #189, to new AST.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    r4a359e2 rbb87dd0  
    299299};
    300300
    301 /// Whether a cast existed in the program source or not
     301/// Inidicates whether the cast is introduced by the CFA type system.
     302/// GeneratedCast for casts that the resolver introduces to force a return type
     303/// ExplicitCast for casts from user code
     304/// ExplicitCast for casts from desugaring advanced CFA features into simpler CFA
     305/// example
     306///   int * p;     // declaration
     307///   (float *) p; // use, with subject cast
     308/// subject cast being GeneratedCast means we are considering an interpretation with a type mismatch
     309/// subject cast being ExplicitCast means someone in charge wants it that way
    302310enum GeneratedFlag { ExplicitCast, GeneratedCast };
    303311
  • src/ResolvExpr/CandidateFinder.cpp

    r4a359e2 rbb87dd0  
    10661066                                // unification run for side-effects
    10671067                                unify( toType, cand->expr->result, cand->env, need, have, open, symtab );
    1068                                 Cost thisCost = castCost( cand->expr->result, toType, cand->expr->get_lvalue(),
    1069                                                 symtab, cand->env );
     1068                                Cost thisCost =
     1069                                        (castExpr->isGenerated == ast::GeneratedFlag::GeneratedCast)
     1070                            ? conversionCost( cand->expr->result, toType, cand->expr->get_lvalue(), symtab, cand->env )
     1071                            : castCost( cand->expr->result, toType, cand->expr->get_lvalue(), symtab, cand->env );
     1072
    10701073                                PRINT(
    10711074                                        std::cerr << "working on cast with result: " << toType << std::endl;
     
    15431546
    15441547                                        // unification run for side-effects
    1545                                         unify( toType, cand->expr->result, env, need, have, open, symtab );
     1548                                        bool canUnify = unify( toType, cand->expr->result, env, need, have, open, symtab );
     1549                    (void) canUnify;
    15461550                                        Cost thisCost = computeConversionCost( cand->expr->result, toType, cand->expr->get_lvalue(),
     1551                                                symtab, env );
     1552                                        PRINT(
     1553                                                Cost legacyCost = castCost( cand->expr->result, toType, cand->expr->get_lvalue(),
    15471554                                                        symtab, env );
    1548 
     1555                                                std::cerr << "Considering initialization:";
     1556                                                std::cerr << std::endl << "  FROM: " << cand->expr->result << std::endl;
     1557                                                std::cerr << std::endl << "  TO: "   << toType             << std::endl;
     1558                                                std::cerr << std::endl << "  Unification " << (canUnify ? "succeeded" : "failed");
     1559                                                std::cerr << std::endl << "  Legacy cost " << legacyCost;
     1560                                                std::cerr << std::endl << "  New cost " << thisCost;
     1561                                                std::cerr << std::endl;
     1562                                        )
    15491563                                        if ( thisCost != Cost::infinity ) {
    15501564                                                // count one safe conversion for each value that is thrown away
  • tests/.expect/init1-ERROR.nast.txt

    r4a359e2 rbb87dd0  
    77init1.cfa:61:1 error: Invalid application of existing declaration(s) in expression Untyped Init Expression
    88  Name: cpx  InitAlternative: pointer to float
    9 init1.cfa:104:1 error: No reasonable alternatives for expression Generated Cast of:
     9init1.cfa:104:1 error: Invalid application of existing declaration(s) in expression Generated Cast of:
    1010  Name: rx
    1111... to:
     
    2020  Name: px
    2121
    22 init1.cfa:114:1 error: No reasonable alternatives for expression Generated Cast of:
     22init1.cfa:114:1 error: Invalid application of existing declaration(s) in expression Generated Cast of:
    2323  Name: crx
    2424... to:
     
    3333  Name: cpx
    3434
    35 init1.cfa:124:1 error: No reasonable alternatives for expression Generated Cast of:
     35init1.cfa:124:1 error: Invalid application of existing declaration(s) in expression Generated Cast of:
    3636  Name: s
    3737... to:
Note: See TracChangeset for help on using the changeset viewer.