1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "builtins/builtins.h"
namespace goose::builtins
{
Term BuildArgPatternFromTDecl( const TDecl& td )
{
return ValueToIRExpr( ValuePattern( MkHole( "_"_sid ), td.type(), MkHole( "_"_sid ) ) );
}
UniGen UnifyTDecl( const Term& lhs, const Term& rhs, UnificationContext& uc )
{
auto tdecl = FromValue< TDecl >( *ValueFromIRExpr( lhs ) );
assert( tdecl );
auto tdeclHole = MkHole( tdecl->name() );
auto pat = ValueToIRExpr( Value( tdecl->type(), MkHole( "_"_sid ) ) );
// We are replacing lhs with a different terms and re-unifying,
// so update the complexity accordingly. The structure of the tdecl
// shouldn't count, only its pattern.
uc.subComplexity( GetComplexity( lhs ) );
uc.addComplexity( GetComplexity( pat ) );
|
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "builtins/builtins.h"
namespace goose::builtins
{
Term BuildArgPatternFromTDecl( const TDecl& td )
{
return ValueToIRExpr( ValuePattern( HOLE( "_"_sid ), td.type(), HOLE( "_"_sid ) ) );
}
UniGen UnifyTDecl( const Term& lhs, const Term& rhs, UnificationContext& uc )
{
auto tdecl = FromValue< TDecl >( *ValueFromIRExpr( lhs ) );
assert( tdecl );
auto tdeclHole = HOLE( tdecl->name() );
auto pat = ValueToIRExpr( Value( tdecl->type(), HOLE( "_"_sid ) ) );
// We are replacing lhs with a different terms and re-unifying,
// so update the complexity accordingly. The structure of the tdecl
// shouldn't count, only its pattern.
uc.subComplexity( GetComplexity( lhs ) );
uc.addComplexity( GetComplexity( pat ) );
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
auto tdecl = FromValue< TDecl >( *ValueFromIRExpr( lhs ) );
assert( tdecl );
auto tfuncType = FromValue< TFuncType >( *ValueFromIRExpr( tdecl->type() ) );
assert( tfuncType );
auto callPat = BuildArgPatternFromTDecl( *tdecl );
auto tdeclHole = MkHole( tdecl->name() );
auto rhsVal = *ValueFromIRExpr( rhs );
auto constraintPat = BuildTFuncSignature( uc.context(), *tfuncType );
assert( constraintPat );
ConstrainedFunc cfunc( *constraintPat, GetTFuncInvocationRule(), rhsVal );
|
|
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
auto tdecl = FromValue< TDecl >( *ValueFromIRExpr( lhs ) );
assert( tdecl );
auto tfuncType = FromValue< TFuncType >( *ValueFromIRExpr( tdecl->type() ) );
assert( tfuncType );
auto callPat = BuildArgPatternFromTDecl( *tdecl );
auto tdeclHole = HOLE( tdecl->name() );
auto rhsVal = *ValueFromIRExpr( rhs );
auto constraintPat = BuildTFuncSignature( uc.context(), *tfuncType );
assert( constraintPat );
ConstrainedFunc cfunc( *constraintPat, GetTFuncInvocationRule(), rhsVal );
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
auto tdecl = FromValue< TDecl >( *ValueFromIRExpr( lhs ) );
assert( tdecl );
auto tfuncType = FromValue< TFuncType >( *ValueFromIRExpr( tdecl->type() ) );
assert( tfuncType );
auto callPat = BuildArgPatternFromTDecl( *tdecl );
auto tdeclHole = MkHole( tdecl->name() );
auto rhsVal = *ValueFromIRExpr( rhs );
auto constraintPat = BuildTFuncSignature( uc.context(), *tfuncType );
assert( constraintPat );
ConstrainedFunc cfunc( *constraintPat, GetOverloadSetInvocationRule(), rhsVal );
|
|
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
auto tdecl = FromValue< TDecl >( *ValueFromIRExpr( lhs ) );
assert( tdecl );
auto tfuncType = FromValue< TFuncType >( *ValueFromIRExpr( tdecl->type() ) );
assert( tfuncType );
auto callPat = BuildArgPatternFromTDecl( *tdecl );
auto tdeclHole = HOLE( tdecl->name() );
auto rhsVal = *ValueFromIRExpr( rhs );
auto constraintPat = BuildTFuncSignature( uc.context(), *tfuncType );
assert( constraintPat );
ConstrainedFunc cfunc( *constraintPat, GetOverloadSetInvocationRule(), rhsVal );
|