Goose  Diff

Differences From Artifact [a14e2c5c6d]:

  • File bs/builtins/types/runtime/array.cpp — part of check-in [99c630bf0a] at 2024-04-09 22:55:56 on branch cir-ssa-refactor — Here we go again. Life is pain. Life is suffering (user: zlodo size: 1783)

To Artifact [f281e73d61]:

  • File bs/builtins/types/runtime/array.cpp — part of check-in [0db147f117] at 2024-09-15 20:24:31 on branch cir-ssa-refactor — Add clang format settings, reformat everything (user: achavasse size: 1760)

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
51
52
53
54
55
56
57
58
59
60
#include "builtins/builtins.h"

using namespace goose;
using namespace goose::builtins;

namespace goose::builtins
{
    void SetupRuntimeArrayType( Env& e )
    {
        RegisterBuiltinFunc< Eager< Value > ( Value, uint32_t ) >( e, "array"_sid,
            []( const Value& containedType, uint32_t count )
            {
                if( !GetCodegenType( containedType ) )
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( containedType.locationId(), "runtime arrays can only contain runtime types." );

                    return PoisonValue();
                }

                return ToValue( ArrayType( ValueToEIR( containedType ), count ) );
            } );
    }

    const codegen::Type* GetCodegenType( const ArrayType& a )
    {
        // TODO_SSA reenable
        /*return codegen::Type::Get( llvm::ArrayType::get(
            *GetCodegenType( *EIRToValue( a.m_containedType ) ), a.m_count ) );*/
        return nullptr;
    }
}

namespace goose::eir
{
    Value Bridge< ArrayType >::ToValue( const ArrayType& a )
    {
        return Value( Type(), MkStdRTType( TSID( rt_type ),
            GetCodegenType( a ), TSID( array ),
            TERM( a.m_count ), a.m_containedType ) );
    }

    optional< ArrayType > Bridge< ArrayType >::FromValue( const Value& v )
    {
        auto result = Decompose( v.val(),
            Vec(
                Lit( "rt_type"_sid ),
                SubTerm(),
                Val< void* >(),
                Lit( "array"_sid ),
                Val< uint64_t >(),
                SubTerm()
            )
        );

        if( !result )
            return nullopt;

        auto&& [predicates, cgType, count, containedType] = *result;
        return ArrayType( containedType, count );
    }
}









|




|
>











|


|





|
|
|





<
|
<
<
<
|
<
<
<







|
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
51
52
53
54
#include "builtins/builtins.h"

using namespace goose;
using namespace goose::builtins;

namespace goose::builtins
{
    void SetupRuntimeArrayType( Env& e )
    {
        RegisterBuiltinFunc< Eager< Value >( Value, uint32_t ) >( e, "array"_sid,
            []( const Value& containedType, uint32_t count )
            {
                if( !GetCodegenType( containedType ) )
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( containedType.locationId(),
                        "runtime arrays can only contain runtime types." );
                    return PoisonValue();
                }

                return ToValue( ArrayType( ValueToEIR( containedType ), count ) );
            } );
    }

    const codegen::Type* GetCodegenType( const ArrayType& a )
    {
        // TODO_SSA reenable
        /*return codegen::Type::Get( llvm::ArrayType::get(
         *GetCodegenType( *EIRToValue( a.m_containedType ) ), a.m_count ) );*/
        return nullptr;
    }
} // namespace goose::builtins

namespace goose::eir
{
    Value Bridge< ArrayType >::ToValue( const ArrayType& a )
    {
        return Value( Type(),
            MkStdRTType( TSID( rt_type ), GetCodegenType( a ), TSID( array ), TERM( a.m_count ),
                a.m_containedType ) );
    }

    optional< ArrayType > Bridge< ArrayType >::FromValue( const Value& v )
    {
        auto result = Decompose( v.val(),

            Vec( Lit( "rt_type"_sid ), SubTerm(), Val< void* >(), Lit( "array"_sid ),



                Val< uint64_t >(), SubTerm() ) );




        if( !result )
            return nullopt;

        auto&& [predicates, cgType, count, containedType] = *result;
        return ArrayType( containedType, count );
    }
} // namespace goose::eir