Goose  Diff

Differences From Artifact [cefaf7d2b0]:

  • File bs/builtins/types/runtime/basic.cpp — part of check-in [1f7039ee83] at 2019-07-16 20:06:39 on branch trunk — builtins:
    • fixed runtime type definitions.
    • added definitions for runtime struct types.
    (user: achavasse size: 2314)

To Artifact [2d6c4e2c94]:

  • File bs/builtins/types/runtime/basic.cpp — part of check-in [64244c6d0c] at 2019-07-22 14:50:03 on branch trunk — builtins: runtime types: added a common prefix to easily be able to check if a type is a runtime type. (user: achavasse size: 2393)

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;