21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
|
auto funcType = BuildTFuncType( returnType, params );
// Build the signature
immer::vector< Term > v;
auto vt = v.transient();
bool success = true;
ForEachInTuple( params, [&]( auto&& param )
{
auto teSig = BuildTemplateSignature( c, ValueToIRExpr( param ) );
if( !teSig )
{
cout << "Invalid template parameter.\n";
success = false;
|
55
56
57
58
59
60
61
62
|
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
TVEC(
TERM( make_shared< Vector >( vt.persistent(), false ) ),
*rtSig
),
AppendToVectorTerm( c.identity(), TERM( id ) ),
move( pToks ) ) );
}
}
optional< Term > BuildArgPatternFromTFuncType( const Context& c, const Value& tfuncType )
{
const auto& ftype = *FromValue< TFuncType >( tfuncType );
immer::vector< Term > apv;
auto apvt = apv.transient();
bool success = true;
ForEachInVectorTerm( ftype.params(), [&]( auto&& param )
{
auto teArgPat = BuildTemplateArgPattern( c, param );
if( !teArgPat )
{
cout << "Invalid template parameter.\n";
success = false;
return false;
}
apvt.push_back( move( *teArgPat ) );
return true;
} );
if( !success )
return nullopt;
auto rtArgPat = BuildTemplateArgPattern( c, ftype.returnType() );
if( !rtArgPat )
{
cout << "Invalid template return type or texpr.\n";
return nullopt;
}
return TVEC(
TERM( make_shared< Vector >( apvt.persistent(), false ) ),
*rtArgPat
);
}
}
|