Goose  Artifact [162dde70ac]

Artifact 162dde70aca1d940706a59fa5cf7afb0e35df1ca63deeffec090118be2fd7e11:

  • File bs/sema/overloadset.cpp — part of check-in [46e87c202b] at 2021-08-28 17:55:26 on branch trunk —
    • Instead of falling back to unification as the default type checking rule, implemented default type checking rules similar to the default unification ones
    • Fixed a nasty generator bug
    • Fixed reference type parsing not generating a location
    • Fixed where operator not generating a location that spanned both the types and the predicates
    • Various fixes to accomodate random api changes in the latest llvm
    • Updates fmt and catch2 versions
    (user: achavasse size: 1241)

#include "builtins/builtins.h"

using namespace goose::sema;

bool OverloadSet::add( const Env& e, const Value& callee )
{
    auto pInvRule = GetInvocationRule( e, callee );
    assert( pInvRule );
    return add( e, callee, pInvRule );
}

bool OverloadSet::add( const Env& e, const Value& callee, const ptr< InvocationRule >& pInvRule )
{
    auto signature = pInvRule->getSignature( callee );
    assert( signature );

    auto sigDecomp = Decompose( *signature,
        Val< pvec >()
    );

    assert( sigDecomp );

    bool success = false;
    m_trie = m_trie->merge( *sigDecomp->get(), [&]( auto&& previous ) -> Overload
    {
        if( previous.callee )
            return move( previous );

        success = true;
        return { pInvRule, callee };
    } );

    return success;
}

OverloadSet::TCGen OverloadSet::typeCheck( const Term& callPat, const TypeCheckingContext& tcc ) const
{
    auto callDecomp = Decompose( callPat,
        Val< pvec >()
    );

    if( !callDecomp )
        co_return;

    for( auto&& [callVec,uniCallVec,ovl,tcc] : m_trie->typeCheck( *callDecomp->get(), tcc ) )
    {
        auto uniCall = TERM( make_shared< Vector >( uniCallVec ) );
        co_yield { move( uniCall ), ovl, tcc };
    }
}