Goose  Diff

Differences From Artifact [5392146526]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [88099a9cee] at 2019-03-15 19:18:16 on branch trunk — Overloading: added tests for, and fixed utrie unification. (user: achavasse size: 3002)

To Artifact [d82f206eaf]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [44403d3ab8] at 2019-03-16 17:39:36 on branch trunk — Overloading: implemented OverloadSet's invocation rule. (user: achavasse size: 2974)

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
78
79
80
81
82
83
                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;
            }
    };

    void SetupFunctionInvocationRule( Env& e )
    {







|


|













|







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
78
79
80
81
82
83
                if( !bestSol )
                {
                    // TODO error mgmt
                    cout << "function arguments mismatch.\n";
                    return nullopt;
                }

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

            optional< Value > invoke( 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 optional< Term > getSignature( const Value& callee ) const final
            {
                return GetFuncSigAndRType( callee ).first;
            }
    };

    void SetupFunctionInvocationRule( Env& e )
    {