Goose  Diff

Differences From Artifact [5dc3c97b5b]:

  • File bs/sema/overloadset.cpp — part of check-in [e42ae3d514] at 2019-07-23 19:44:46 on branch trunk — codegen: implemented LowerType. (user: achavasse size: 2222)

To Artifact [2be7c8ab67]:

  • File bs/sema/overloadset.cpp — part of check-in [43e22af793] at 2019-08-05 02:45:01 on branch trunk —
    • Unification now works in two passes. The second pass gives unification rules a chance to match again after all the holes have been resolved and substituted.
    • Fixed many horrible bugs in various unification rules that managed to go by unnoticed until the above change, after which they made everything catch on fire.
    • Simplified the ct_int and ct_string unification rules to take advantage of the new unification behavior. Everything finally works as intended wrt to ct_int versus RT integers.
    • Removed unification callbacks. It was a system to provide a way to perform unification work post hole substitution, so it is now obsolete.
    (user: achavasse size: 3675)

43
44
45
46
47
48
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
            return UT().merge( *params, uTrieMergeFunc );

        return paramUTrie->merge( *params, uTrieMergeFunc );
    } );

    return success;
}






































OverloadSet::UniGen OverloadSet::unify( const Term& domPat, const Term& argsPat, const Term& rtPat, UnificationContext& uc ) const
{
    auto argDecomp = Decompose( argsPat,
        Val< pvec >()
    );

    if( !argDecomp )
        co_return;

    for( auto&& [domain,paramUTrie] : Enumerate( m_trie ) )
    {
        auto localC = uc;
        for( auto&& [uniDom,uc] : Unify( domain, domPat, localC ) )
        {
            for( auto&& [uniParamsVec,rtTrie,uc] : paramUTrie->unify( *argDecomp->get(), uc ) )
            {

                auto uniParams = TERM( make_shared< Vector >( uniParamsVec ) );
                for( auto&& [rt,ovl] : Enumerate( rtTrie ) )
                {
                    auto localC = uc;
                    for( auto&& [uniRt,uc] : Unify( rt, rtPat, localC ) )
                    {
                        auto uniCall = TERM( Vector::Make( uniDom, uniParams, uniRt ) );







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>















|

>







43
44
45
46
47
48
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
            return UT().merge( *params, uTrieMergeFunc );

        return paramUTrie->merge( *params, uTrieMergeFunc );
    } );

    return success;
}

OverloadSet::UniGen OverloadSet::fullUnify( const Term& domPat, const Term& argsPat, const Term& rtPat, UnificationContext& uc ) const
{
    auto argDecomp = Decompose( argsPat,
        Val< pvec >()
    );

    if( !argDecomp )
        co_return;

    for( auto&& [domain,paramUTrie] : Enumerate( m_trie ) )
    {
        auto localC = uc;
        for( auto&& [uniDom,uc] : Unify( domain, domPat, localC ) )
        {
            for( auto&& [paramsVec,uniParamsVec,rtTrie,uc] : paramUTrie->unify( *argDecomp->get(), uc ) )
            {
                auto params = TERM( make_shared< Vector >( paramsVec ) );
                auto uniParams = TERM( make_shared< Vector >( uniParamsVec ) );

                for( auto&& [rt,ovl] : Enumerate( rtTrie ) )
                {
                    auto localC = uc;
                    for( auto&& [uniRt,uc] : Unify( rt, rtPat, localC ) )
                    {
                        auto lhs = TERM( Vector::Make( domain, params, rt ) );
                        auto rhs = TERM( Vector::Make( domPat, argsPat, rtPat ) );
                        auto uniCall = TERM( Vector::Make( uniDom, uniParams, uniRt ) );

                        for( auto&& [s, uc] : UnifyPass2( lhs, rhs, uniCall, uc ) )
                            co_yield { s, ovl, uc };
                    }
                }
            }
        }
    }
}

OverloadSet::UniGen OverloadSet::unify( const Term& domPat, const Term& argsPat, const Term& rtPat, UnificationContext& uc ) const
{
    auto argDecomp = Decompose( argsPat,
        Val< pvec >()
    );

    if( !argDecomp )
        co_return;

    for( auto&& [domain,paramUTrie] : Enumerate( m_trie ) )
    {
        auto localC = uc;
        for( auto&& [uniDom,uc] : Unify( domain, domPat, localC ) )
        {
            for( auto&& [paramsVec,uniParamsVec,rtTrie,uc] : paramUTrie->unify( *argDecomp->get(), uc ) )
            {
                auto params = TERM( make_shared< Vector >( paramsVec ) );
                auto uniParams = TERM( make_shared< Vector >( uniParamsVec ) );
                for( auto&& [rt,ovl] : Enumerate( rtTrie ) )
                {
                    auto localC = uc;
                    for( auto&& [uniRt,uc] : Unify( rt, rtPat, localC ) )
                    {
                        auto uniCall = TERM( Vector::Make( uniDom, uniParams, uniRt ) );