Goose  Artifact [aa76ad6e76]

Artifact aa76ad6e760da162f5c6e6fd55569fd155bcd3432339f54d3803777e9ad8a5c2:

  • File bs/builtins/types/template/tdecl.cpp — part of check-in [054862b9f5] at 2019-02-16 16:48:49 on branch trunk — Some reorganization of template types. (user: achavasse size: 928)
  • File bs/builtins/types/texpr/tdecl.cpp — part of check-in [aec44da323] at 2019-02-14 23:11:46 on branch trunk — Templates: added TFunc type. (user: achavasse size: 928)

#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( TSID( type ), TSID( tdecl ) ) );
        return type;
    }

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

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

        auto result = Decompose( v.val(),
            Vec(
                SubTerm(),
                SubTerm()
            )
        );

        if( !result )
            return nullopt;

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

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