1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include "builtins/builtins.h"
using namespace empathy;
using namespace empathy::builtins;
namespace empathy::builtins
{
void SetupRuntimeArrayType( Env& e )
{
RegisterBuiltinFunc< Eager< Value > ( Value, uint64_t ) >( e, "array"_sid,
[]( const Value& containedType, uint64_t count )
{
if( !GetLLVMType( containedType ) )
{
// TODO come up with some lightweight builtin option type
// for the builtin apis, because this is a very bullshit
// way to handle errors
return ToValue( "error"s );
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include "builtins/builtins.h"
using namespace empathy;
using namespace empathy::builtins;
namespace empathy::builtins
{
void SetupRuntimeArrayType( Env& e )
{
RegisterBuiltinFunc< Eager< Value > ( Value, uint32_t ) >( e, "array"_sid,
[]( const Value& containedType, uint32_t count )
{
if( !GetLLVMType( containedType ) )
{
// TODO come up with some lightweight builtin option type
// for the builtin apis, because this is a very bullshit
// way to handle errors
return ToValue( "error"s );
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
optional< ArrayType > Bridge< ArrayType >::FromValue( const Value& v )
{
auto result = Decompose( v.val(),
Vec(
Lit( "rt_type"_sid ),
Val< void* >(),
Lit( "array"_sid ),
Val< uint64_t >(),
SubTerm()
)
);
if( !result )
return nullopt;
auto&& [llvmType, count, containedType] = *result;
return ArrayType( containedType, count );
}
}
|
|
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
optional< ArrayType > Bridge< ArrayType >::FromValue( const Value& v )
{
auto result = Decompose( v.val(),
Vec(
Lit( "rt_type"_sid ),
Val< void* >(),
Lit( "array"_sid ),
Val< uint32_t >(),
SubTerm()
)
);
if( !result )
return nullopt;
auto&& [llvmType, count, containedType] = *result;
return ArrayType( containedType, count );
}
}
|