Goose  Diff

Differences From Artifact [b00450727b]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [e87aad0ef1] at 2019-03-03 15:00:39 on branch trunk — Added return types to function signatures, so that any TExpr constraint they may contain are taken into account during unification. (user: achavasse size: 2671)

To Artifact [fa51e6c8cf]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [6d6a036678] at 2019-03-03 15:39:08 on branch trunk — Overloading: split out the unification from resolveInvocation(). (user: achavasse size: 2919)

49
50
51
52
53
54
55





56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
                if( !bestSol )
                {
                    // TODO error mgmt
                    cout << "function arguments mismatch.\n";
                    return nullopt;
                }






                auto unifiedCallPat = Substitute( *bestSol, *bestUC );
                auto callDecomp = Decompose( unifiedCallPat,
                    Vec(
                        SubTerm(),  // args
                        SubTerm()   // return type
                    )
                );

                auto&& [unifiedArgs, unifiedRType] = *callDecomp;
                return Value( rtype, make_shared< llr::Element >( llr::Call( callee, unifiedArgs ) ) );
            }

            virtual Term getSignature( const Context& c, const Value& callee ) const final
            {
                return GetFuncSigAndRType( callee ).first;
            }
    };







>
>
>
>
>
|








|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
                if( !bestSol )
                {
                    // TODO error mgmt
                    cout << "function arguments mismatch.\n";
                    return nullopt;
                }

                return resolveInvocation( c, callee, *bestSol, *bestUC );
            }

            optional< Value > resolveInvocation( const Context& c, const Value& callee, const Term& uniSol, UnificationContext& uc ) const final
            {
                auto unifiedCallPat = Substitute( uniSol, uc );
                auto callDecomp = Decompose( unifiedCallPat,
                    Vec(
                        SubTerm(),  // args
                        SubTerm()   // return type
                    )
                );

                auto&& [unifiedArgs, unifiedRType] = *callDecomp;
                return Value( unifiedRType, make_shared< llr::Element >( llr::Call( callee, unifiedArgs ) ) );
            }

            virtual Term getSignature( const Context& c, const Value& callee ) const final
            {
                return GetFuncSigAndRType( callee ).first;
            }
    };