Goose  Diff

Differences From Artifact [a49b5642e1]:

  • File bs/builtins/types/reference/typecheck.cpp — part of check-in [26c691ecb9] at 2021-01-02 18:24:23 on branch trunk — Yet one more reference/address refactor: each calculation step (getting temp addr, getting var addr, selecting a member) is now a separate cir instruction. We need this level of generalization to be able to obtain addresses from anywhere, including variables and function parameters. (user: achavasse size: 7728)

To Artifact [763e25b9ac]:

  • File bs/builtins/types/reference/typecheck.cpp — part of check-in [4cc7a833f8] at 2021-01-03 15:44:11 on branch trunk — cir: load, store and select store their base addresses directly as cir instructiions, rather than wrapped into eir values, which is useless there. (user: achavasse size: 7797)

95
96
97
98
99
100
101


102
103
104
105
106
107
108
109
110
111
112
113
114
                ANYTERM( _ ),
                refTypePattern,
                ANYTERM( _ ) ) ),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                auto refval = *ValueFromEIR( rhs );


                auto refType = FromValue< ReferenceType >( *ValueFromEIR( refval.type() ) );
                if( !refType )
                    co_return;

                auto content = ValueToEIR( BuildComputedValue( refType->type(),
                    cir::Load( refval, refType->type() ) )
                    .setLocationId( refval.locationId() ) );

                // TypeCheck the param with the ref's content
                co_yield TypeCheck( lhs, content, tcc );
            } );

        // LocalVar type checking against a param (implicit referencing):







>
>





|







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
                ANYTERM( _ ),
                refTypePattern,
                ANYTERM( _ ) ) ),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                auto refval = *ValueFromEIR( rhs );
                G_VAL_ASSERT( refval, !refval.isConstant() );

                auto refType = FromValue< ReferenceType >( *ValueFromEIR( refval.type() ) );
                if( !refType )
                    co_return;

                auto content = ValueToEIR( BuildComputedValue( refType->type(),
                    cir::Load( refval.cir(), refType->type() ) )
                    .setLocationId( refval.locationId() ) );

                // TypeCheck the param with the ref's content
                co_yield TypeCheck( lhs, content, tcc );
            } );

        // LocalVar type checking against a param (implicit referencing):