Goose  Artifact [051df9f0ea]

Artifact 051df9f0ea4e675799ed4e7b8928be3957ee0c8c0aedbfe8da4a060e9a999730:

  • File bs/sema/hole.cpp — part of check-in [326d403e6c] at 2019-06-29 13:43:02 on branch trunk — Build fixes to work with the latest git version of libc++. (user: achavasse size: 867)

#include "sema.h"

namespace empathy::sema
{
    Term MkHole( const Hole& h )
    {
        return visit( [&]( auto&& x )
        {
            return TVEC( TSID( hole ), TERM( x ) );
        }, h );
    }

    optional< Hole > HoleFromIRExpr( const Term& t )
    {
        auto resultUnnamed = Decompose( t,
            Vec(
                Lit( "hole"_sid ),
                Val< uint64_t >()
            )
        );

        if( resultUnnamed )
        {
            auto&& [index] = *resultUnnamed;
            return static_cast< uint32_t >( index );
        }

        auto resultNamed = Decompose( t,
            Vec(
                Lit( "hole"_sid ),
                Val< StringId >()
            )
        );

        if( resultNamed )
        {
            auto&& [name] = *resultNamed;
            return name;
        }

        return nullopt;
    }
}