Changeset bb87dd0 for src


Ignore:
Timestamp:
Nov 24, 2020, 5:48:06 PM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4702a2c
Parents:
4a359e2
Message:

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

Location:
src
Files:
2 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
Note: See TracChangeset for help on using the changeset viewer.