#include "builtins/builtins.h"
#include "lex/lex.h"
#include "parse/parse.h"
using namespace empathy::builtins;
using namespace empathy::parse;
namespace empathy::ir
{
const Term& Bridge< TFunc >::Type( const builtins::TFunc& tf )
{
static auto type = ValueToIRExpr( ::ToValue( tf.type() ) );
return type;
}
Value Bridge< TFunc >::ToValue( const TFunc& tf )
{
// TODO build and include the signature
return Value( Type( tf ), TERM( tf.toks() ) );
}
optional< TFunc > Bridge< TFunc >::FromValue( const Value& v )
{
auto typeVal = ValueFromIRExpr( v.type() );
auto type = ::FromValue< TFuncType >( *typeVal );
if( !type )
return nullopt;
return TFunc( move( *type ), get< pvec >( v.val().content() ) );
}
}