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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
}
namespace empathy::ir
{
//// Half
Value Bridge< RTHalf >::ToValue( const RTHalf& i )
{
return Value( Type(), TSID( rt_half ) );
}
optional< RTHalf > Bridge< RTHalf >::FromValue( const Value& v )
{
if( !v.isType() || v.val() != TSID( rt_half ) )
return nullopt;
return {};
}
//// Float
Value Bridge< RTFloat >::ToValue( const RTFloat& i )
{
return Value( Type(), TSID( rt_float ) );
}
optional< RTFloat > Bridge< RTFloat >::FromValue( const Value& v )
{
if( !v.isType() || v.val() != TSID( rt_float ) )
return nullopt;
return {};
}
//// Double
Value Bridge< RTDouble >::ToValue( const RTDouble& i )
{
return Value( Type(), TSID( rt_double ) );
}
optional< RTDouble > Bridge< RTDouble >::FromValue( const Value& v )
{
if( !v.isType() || v.val() != TSID( rt_double ) )
return nullopt;
return {};
}
//// Integer
Value Bridge< RTInteger >::ToValue( const RTInteger& i )
{
return Value( Type(), TVEC( TSID( rt_integer ), TERM( i.m_numBits ) ) );
}
optional< RTInteger > Bridge< RTInteger >::FromValue( const Value& v )
{
auto result = Decompose( v.val(),
Vec(
Lit( "rt_integer"_sid ),
Val< uint64_t >()
)
);
if( !result )
return nullopt;
|
|
|
|
|
|
|
|
>
|
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
}
namespace empathy::ir
{
//// Half
Value Bridge< RTHalf >::ToValue( const RTHalf& i )
{
return Value( Type(), TVEC( TSID( rt_type ), TSID( rt_half ) ) );
}
optional< RTHalf > Bridge< RTHalf >::FromValue( const Value& v )
{
if( v != ToValue( RTHalf() ) )
return nullopt;
return {};
}
//// Float
Value Bridge< RTFloat >::ToValue( const RTFloat& i )
{
return Value( Type(), TVEC( TSID( rt_type ), TSID( rt_float ) ) );
}
optional< RTFloat > Bridge< RTFloat >::FromValue( const Value& v )
{
if( v != ToValue( RTFloat() ) )
return nullopt;
return {};
}
//// Double
Value Bridge< RTDouble >::ToValue( const RTDouble& i )
{
return Value( Type(), TVEC( TSID( rt_type ), TSID( rt_double ) ) );
}
optional< RTDouble > Bridge< RTDouble >::FromValue( const Value& v )
{
if( v != ToValue( RTDouble() ) )
return nullopt;
return {};
}
//// Integer
Value Bridge< RTInteger >::ToValue( const RTInteger& i )
{
return Value( Type(), TVEC( TSID( rt_type ), TSID( rt_integer ), TERM( i.m_numBits ) ) );
}
optional< RTInteger > Bridge< RTInteger >::FromValue( const Value& v )
{
auto result = Decompose( v.val(),
Vec(
Lit( "rt_type"_sid ),
Lit( "rt_integer"_sid ),
Val< uint64_t >()
)
);
if( !result )
return nullopt;
|