Goose  Artifact [fc5ee19e2d]

Artifact fc5ee19e2d95942359b2ec217877143ed3d646bea6cae033a363159f2029945b:

  • File bs/builtins/types/template/tvar.cpp — part of check-in [054862b9f5] at 2019-02-16 16:48:49 on branch trunk — Some reorganization of template types. (user: achavasse size: 814)
  • File bs/builtins/types/texpr/tvar.cpp — part of check-in [06665441a7] at 2019-02-16 13:19:19 on branch trunk — Templates: added TNamedDecl type. (user: achavasse size: 814)

#include "builtins/builtins.h"

using namespace empathy::builtins;

namespace empathy::builtins
{
    bool IsTVar( const Value& tv )
    {
        return tv.type() == GetValueType< TVar >();
    }
}

namespace empathy::ir
{
    const Term& Bridge< TVar >::Type()
    {
        static auto type = ValueToIRExpr( Value( TSID( type ), TVEC( TSID( texpr ), TSID( tvar ) ) ) );
        return type;
    }

    Value Bridge< TVar >::ToValue( TVar&& td )
    {
        return Value( Type(), TERM( td.name() ) );
    }

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

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

        if( !result )
            return nullopt;

        return TVar( *result );
    }
}