1
2
3
4
5
6
7
8
9
10
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
45
46
47
48
49
50
|
#include "builtins/builtins.h"
using namespace goose::builtins;
namespace goose::builtins
{
bool IsDecl( const Value& d )
{
auto typeVal = ValueFromIRExpr( d.type() );
auto result = Decompose( typeVal->val(),
Vec(
Lit( "decl"_sid ),
SubTerm()
)
);
return !!result;
}
const Term& Decl::Pattern::GetPattern()
{
static auto pattern = ValueToIRExpr(
Value( TypeType(), VEC( TSID( decl ), HOLE( "_"_sid ) ) ) );
return pattern;
}
}
namespace goose::eir
{
Term Bridge< Decl >::Type( const Term& declType )
{
return ValueToIRExpr( Value( TypeType(), VEC( TSID( decl ), declType ) ) );
}
Value Bridge< Decl >::ToValue( const Decl& d )
{
return Value( Type( d.type() ), TERM( d.name() ) );
}
optional< Decl > Bridge< Decl >::FromValue( const Value& v )
{
auto typeVal = ValueFromIRExpr( v.type() );
auto result = Decompose( typeVal->val(),
Vec(
Lit( "decl"_sid ),
SubTerm()
)
);
|
|
|
|
|
|
1
2
3
4
5
6
7
8
9
10
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
45
46
47
48
49
50
|
#include "builtins/builtins.h"
using namespace goose::builtins;
namespace goose::builtins
{
bool IsDecl( const Value& d )
{
auto typeVal = ValueFromEIR( d.type() );
auto result = Decompose( typeVal->val(),
Vec(
Lit( "decl"_sid ),
SubTerm()
)
);
return !!result;
}
const Term& Decl::Pattern::GetPattern()
{
static auto pattern = ValueToEIR(
Value( TypeType(), VEC( TSID( decl ), HOLE( "_"_sid ) ) ) );
return pattern;
}
}
namespace goose::eir
{
Term Bridge< Decl >::Type( const Term& declType )
{
return ValueToEIR( Value( TypeType(), VEC( TSID( decl ), declType ) ) );
}
Value Bridge< Decl >::ToValue( const Decl& d )
{
return Value( Type( d.type() ), TERM( d.name() ) );
}
optional< Decl > Bridge< Decl >::FromValue( const Value& v )
{
auto typeVal = ValueFromEIR( v.type() );
auto result = Decompose( typeVal->val(),
Vec(
Lit( "decl"_sid ),
SubTerm()
)
);
|