Goose  Diff

Differences From Artifact [a622140cb1]:

  • File bs/builtins/types/reference/typecheck.cpp — part of check-in [1793989d05] at 2024-02-09 18:05:28 on branch trunk — Lowering: completely reworked all lowering to happen in the same two unified extension points upstream of all three CIR consumers (user: zlodo size: 10791)

To Artifact [f0fb550ead]:

  • File bs/builtins/types/reference/typecheck.cpp — part of check-in [57d4d0c79e] at 2024-09-13 21:05:40 on branch cir-ssa-refactor — Drop in the most apocalyptic changes: new CIR instruction structure, new sequence builder, new compile time address representation, do almost just the bare minimum to compile again. A few simple things are still working somehow (user: achavasse size: 10805)

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
                    )
                );

                assert( result );
                auto&& [arg, rhs] = *result;

                auto val = *EIRToValue( arg );
                ReferenceType rt( val.type(), TempAccessSpecifer() );

                auto rhsVal = *EIRToValue( rhs );

                auto cfg = GetCFG( tcc.context() );
                if( !cfg )
                    return nullopt;

                // TODO create an ext point for this
                auto loc = rhsVal.locationId();
                auto tempIndex = util::GenerateNewUID();
                return ValueToEIR( BuildComputedValue( ValueToEIR( ToValue( rt ) ), rhsVal,
                    TempAddr( tempIndex, loc ) ).setLocationId( loc ) );
            } );

            // Override the weight because we don't want
            // this solution to count more than directly using
            // the value without wrapping it into a tempref
            SetWeight( wrapped, GetWeight( rhs ) - 1 );
            co_yield { move( wrapped ), tcc };







|











|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
                    )
                );

                assert( result );
                auto&& [arg, rhs] = *result;

                auto val = *EIRToValue( arg );
                ReferenceType rt( val.type(), TempAccessSpecifier() );

                auto rhsVal = *EIRToValue( rhs );

                auto cfg = GetCFG( tcc.context() );
                if( !cfg )
                    return nullopt;

                // TODO create an ext point for this
                auto loc = rhsVal.locationId();
                auto tempIndex = util::GenerateNewUID();
                return ValueToEIR( BuildComputedValue( ValueToEIR( ToValue( rt ) ), rhsVal,
                    DataPathOf( tempIndex, loc ) ).setLocationId( loc ) );
            } );

            // Override the weight because we don't want
            // this solution to count more than directly using
            // the value without wrapping it into a tempref
            SetWeight( wrapped, GetWeight( rhs ) - 1 );
            co_yield { move( wrapped ), tcc };
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
        auto refTypePattern = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ANYTERM( _ ), ANYTERM( _ ) ) ) );

        auto refRefTypePattern = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ANYTERM( _ ), refTypePattern ) ) );

        auto refTypePatternConstant = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ConstAccessSpecifer(), ANYTERM( _ ) ) ) );

        auto refTypePatternMutable = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), MutAccessSpecifer(), ANYTERM( _ ) ) ) );

        auto refTypePatternTemporary = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), TempAccessSpecifer(), ANYTERM( _ ) ) ) );

        auto localVarPattern = GetValueType< LocalVar >( ANYTERM( _ ) );

        // Reference type checking rule.
        e.typeCheckingRuleSet()->addTypeCheckingRule(

            ParamPat( refTypePattern ),







|


|


|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
        auto refTypePattern = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ANYTERM( _ ), ANYTERM( _ ) ) ) );

        auto refRefTypePattern = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ANYTERM( _ ), refTypePattern ) ) );

        auto refTypePatternConstant = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ConstAccessSpecifier(), ANYTERM( _ ) ) ) );

        auto refTypePatternMutable = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), MutAccessSpecifier(), ANYTERM( _ ) ) ) );

        auto refTypePatternTemporary = ValueToEIR(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), TempAccessSpecifier(), ANYTERM( _ ) ) ) );

        auto localVarPattern = GetValueType< LocalVar >( ANYTERM( _ ) );

        // Reference type checking rule.
        e.typeCheckingRuleSet()->addTypeCheckingRule(

            ParamPat( refTypePattern ),
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
                    }
                }
            }
        );

        // mut -> const reference type checking rule.
        e.typeCheckingRuleSet()->addTypeCheckingRule(
            ConstAccessSpecifer(),
            MutAccessSpecifer(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );

        // mut -> const reference unification rule.
        e.typeCheckingRuleSet()->addUnificationRule(
            ConstAccessSpecifer(),
            MutAccessSpecifer(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );

        // temp -> const reference type checking rule.
        e.typeCheckingRuleSet()->addTypeCheckingRule(
            ConstAccessSpecifer(),
            TempAccessSpecifer(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );

        // temp -> const reference unification rule.
        e.typeCheckingRuleSet()->addUnificationRule(
            ConstAccessSpecifer(),
            TempAccessSpecifer(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );








|
|









|
|









|
|









|
|







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
                    }
                }
            }
        );

        // mut -> const reference type checking rule.
        e.typeCheckingRuleSet()->addTypeCheckingRule(
            ConstAccessSpecifier(),
            MutAccessSpecifier(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );

        // mut -> const reference unification rule.
        e.typeCheckingRuleSet()->addUnificationRule(
            ConstAccessSpecifier(),
            MutAccessSpecifier(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );

        // temp -> const reference type checking rule.
        e.typeCheckingRuleSet()->addTypeCheckingRule(
            ConstAccessSpecifier(),
            TempAccessSpecifier(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );

        // temp -> const reference unification rule.
        e.typeCheckingRuleSet()->addUnificationRule(
            ConstAccessSpecifier(),
            TempAccessSpecifier(),

            []( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
            {
                co_yield { lhs, tcc };
            }
        );