Goose  Artifact [2b5b9f19eb]

Artifact 2b5b9f19ebb7b826403c3e1a5bcbaeccb25759471852b6d0cc2882bf28a40c4c:

  • File bs/builtins/types/template/tnameddecl.cpp — part of check-in [0345b9f807] at 2021-01-02 18:00:11 on branch trunk — Some more renaming. (user: achavasse size: 1115)

#include "builtins/builtins.h"

using namespace goose::builtins;

namespace goose::builtins
{
    bool IsTNamedDecl( const Value& td )
    {
        return td.type() == GetValueType< TNamedDecl >();
    }

    const Term& TNamedDecl::Pattern::GetPattern()
    {
        static auto pattern = GetValueType< TNamedDecl >();
        return pattern;
    }
}

namespace goose::eir
{
    const Term& Bridge< TNamedDecl >::Type()
    {
        static auto type = ValueToEIR( Value( TypeType(), TSID( tnameddecl ) ) );
        return type;
    }

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

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

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

        if( !result )
            return nullopt;

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

        return TNamedDecl( type, name );
    }
}