11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
{
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() ) );
return Value( Type( tf ), TVEC( tf.signature(),
TERM( static_pointer_cast< void >( tf.toks() ) ) ) );
}
optional< TFunc > Bridge< TFunc >::FromValue( const Value& v )
{
auto typeVal = ValueFromIRExpr( v.type() );
auto type = ::FromValue< TFuncType >( *typeVal );
if( !type )
return nullopt;
auto result = Decompose( v.val(),
Vec(
SubTerm(), // signature
Val< ptr< void > >() // toks
)
);
if( !result )
return nullopt;
auto&& [signature, toks] = *result;
auto pBodyToks = static_pointer_cast< vector< Term > >( toks );
return TFunc( move( *type ), get< pvec >( v.val().content() ) );
return TFunc( move( *type ), move( signature ), move( pBodyToks ) );
}
}
|