Goose  Artifact [dda04cd5f9]

Artifact dda04cd5f9d67393007ec278f9bf27009f2fcda9fb9619e78beaa0285f497c0c:

  • File bs/builtins/types/template/tdecl.cpp — part of check-in [fc331f1703] at 2019-04-06 14:16:09 on branch trunk —
    • Simplified TDecl: the right hand side can now only be a TVar. Removed the colon operator.
    • Added the possibility in unification to make hole resolution non mandatory for a sub expression.
    • Higher order polymorphism: implemented the unification of a polymorphic tfunc type param with a template lambda.
    (user: achavasse size: 935)

#include "builtins/builtins.h"

using namespace empathy::builtins;

namespace empathy::builtins
{
    bool IsTDecl( const Value& td )
    {
        return td.type() == GetValueType< TDecl >();
    }
}

namespace empathy::ir
{
    const Term& Bridge< TDecl >::Type()
    {
        static auto type = ValueToIRExpr( Value( TypeType(), TSID( tdecl ) ) );
        return type;
    }

    Value Bridge< TDecl >::ToValue( const TDecl& td )
    {
        return Value( Type(), TVEC( td.type(), TERM( td.name() ) ) );
    }

    optional< TDecl > Bridge< TDecl >::FromValue( const Value& v )
    {
        if( !IsTDecl( v ) )
            return nullopt;

        auto result = Decompose( v.val(),
            Vec(
                SubTerm(),
                Val< StringId >()
            )
        );

        if( !result )
            return nullopt;

        auto&& [type,name] = *result;

        return TDecl( move( type ), name );
    }
}