214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
co_return;
auto ref = ValueToEIR( ToValue( BuildLocalVarMutRef( *locvar ) )
.setLocationId( lvval.locationId() ) );
co_yield TypeCheck( lhs, ref, tcc );
} );
// Implicit referencing of non-variables against a non mutable ref: build a tempref
e.typeCheckingRuleSet()->addTypeCheckingRule( TCRINFOS,
ValueToEIR( ValuePattern(
ANYTERM( _ ),
refTypePattern,
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
co_return;
auto ref = ValueToEIR( ToValue( BuildLocalVarMutRef( *locvar ) )
.setLocationId( lvval.locationId() ) );
co_yield TypeCheck( lhs, ref, tcc );
} );
// Typechecking ref of ref against a ref: dereference the firs tref and attempt tp typecheck it
// against the other ref
e.typeCheckingRuleSet()->addTypeCheckingRule( TCRINFOS,
ParamPat( refTypePattern ),
ValueToEIR( ValuePattern(
ANYTERM( _ ),
refRefTypePattern,
ANYTERM( _ ) ) ),
[]( const Term& lhs, const Term& rhs, const TypeCheckingContext& tcc ) -> TCGen
{
auto ltype = ValuePatternFromEIR( lhs )->type();
auto rrefVal = *EIRToValue( rhs );
auto rrType = FromValue< ReferenceType >( *EIRToValue( rrefVal.type() ) );
if( !rrType )
co_return;
auto content = ValueToEIR( BuildComputedValue( rrType->type(),
cir::Load( rrefVal.cir(), rrType->type() ) ).setLocationId( rrefVal.locationId() ) );
co_yield TypeCheck( lhs, content, tcc );
} );
// Implicit referencing of non-variables against a non mutable ref: build a tempref
e.typeCheckingRuleSet()->addTypeCheckingRule( TCRINFOS,
ValueToEIR( ValuePattern(
ANYTERM( _ ),
refTypePattern,
|