Goose  Diff

Differences From Artifact [61ed2096c5]:

  • File bs/builtins/types/template/tfunc.cpp — part of check-in [054862b9f5] at 2019-02-16 16:48:49 on branch trunk — Some reorganization of template types. (user: achavasse size: 822)
  • File bs/builtins/types/tfunc/tfunc.cpp — part of check-in [aec44da323] at 2019-02-14 23:11:46 on branch trunk — Templates: added TFunc type. (user: achavasse size: 822)

To Artifact [66fdccbf22]:

  • File bs/builtins/types/template/tfunc.cpp — part of check-in [114cdaf51b] at 2019-02-22 21:43:18 on branch trunk — Templates: implemented BuildTFuncType() and BuildTFunc(). (user: achavasse size: 1199)

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 ) );
    }
}