@@ -89,10 +89,15 @@ module KMIR-SPL-TOKEN
8989## Helper syntax
9090
9191``` k
92- syntax Value ::= SPLRefCell ( Value , Value ) // Reference to the buffer, value in the cell
92+ syntax AbsPlace ::= AbsPlace ( Int , Place )
93+
94+ syntax AbsPlace ::= #adjustAbsPlace ( AbsPlace , Int ) [function, total]
95+ rule #adjustAbsPlace(AbsPlace(DEPTH, PLACE), OFFSET) => AbsPlace(DEPTH +Int OFFSET, PLACE)
96+
97+ syntax Value ::= SPLRefCell ( AbsPlace , Value ) // Place of the buffer, value in the cell
9398 | SPLDataBuffer ( Value )
94- | SPLDataBorrow ( Value , Value ) // Reference to the buffer, borrowed value
95- | SPLDataBorrowMut ( Value , Value )
99+ | SPLDataBorrow ( AbsPlace , Value ) // Place of the buffer, borrowed value
100+ | SPLDataBorrowMut ( AbsPlace , Value )
96101 | SPLPubkeyRef ( Value )
97102```
98103
@@ -169,9 +174,9 @@ module KMIR-SPL-TOKEN
169174 rule #isSPLRentGetFunc("solana_sysvar::rent::<impl Sysvar for solana_rent::Rent>::get") => true
170175
171176 // Adjust references when moving across stack frames
172- rule #adjustRef(SPLRefCell(PLACE, VAL), OFFSET) => SPLRefCell(#adjustRef (PLACE, OFFSET), #adjustRef(VAL, OFFSET))
173- rule #adjustRef(SPLDataBorrow(PLACE, VAL), OFFSET) => SPLDataBorrow(#adjustRef (PLACE, OFFSET), #adjustRef(VAL, OFFSET))
174- rule #adjustRef(SPLDataBorrowMut(PLACE, VAL), OFFSET) => SPLDataBorrowMut(#adjustRef (PLACE, OFFSET), #adjustRef(VAL, OFFSET))
177+ rule #adjustRef(SPLRefCell(PLACE, VAL), OFFSET) => SPLRefCell(#adjustAbsPlace (PLACE, OFFSET), #adjustRef(VAL, OFFSET))
178+ rule #adjustRef(SPLDataBorrow(PLACE, VAL), OFFSET) => SPLDataBorrow(#adjustAbsPlace (PLACE, OFFSET), #adjustRef(VAL, OFFSET))
179+ rule #adjustRef(SPLDataBorrowMut(PLACE, VAL), OFFSET) => SPLDataBorrowMut(#adjustAbsPlace (PLACE, OFFSET), #adjustRef(VAL, OFFSET))
175180 rule #adjustRef(SPLDataBuffer(VAL), OFFSET) => SPLDataBuffer(#adjustRef(VAL, OFFSET))
176181 rule #adjustRef(SPLPubkeyRef(VAL), OFFSET) => SPLPubkeyRef(#adjustRef(VAL, OFFSET))
177182```
@@ -291,28 +296,24 @@ module KMIR-SPL-TOKEN
291296 ListItem(SPLPubkeyRef(Aggregate(variantIdx(0), ListItem(Range(?SplAccountKey:List))))) // pub key: &'a Pubkey
292297 ListItem(
293298 SPLRefCell(
294- Reference (
299+ AbsPlace (
295300 0,
296301 place(
297302 LOCAL,
298303 appendP(PROJS, projectionElemDeref projectionElemField(fieldIdx(1), #hack()) .ProjectionElems)
299- ),
300- mutabilityNot,
301- metadata(noMetadataSize, 0, noMetadataSize)
304+ )
302305 ),
303306 Integer(?SplLamports:Int, 64, false)
304307 )
305308 ) // lamports: Rc<RefCell<&'a mut u64>>
306309 ListItem( // data: Rc<RefCell<&'a mut [u8]>>
307310 SPLRefCell(
308- Reference (
311+ AbsPlace (
309312 0,
310313 place(
311314 LOCAL,
312315 appendP(PROJS, projectionElemDeref projectionElemField(fieldIdx(2), #hack()) .ProjectionElems)
313- ),
314- mutabilityNot,
315- metadata(noMetadataSize, 0, noMetadataSize)
316+ )
316317 ),
317318 SPLDataBuffer( // data: Rc<RefCell<&'a mut [u8]>>, Aggregate is for &account.data
318319 Aggregate(variantIdx(0),
@@ -365,28 +366,24 @@ module KMIR-SPL-TOKEN
365366 ListItem(SPLPubkeyRef(Aggregate(variantIdx(0), ListItem(Range(?SplMintAccountKey:List))))) // pub key: &'a Pubkey
366367 ListItem(
367368 SPLRefCell(
368- Reference (
369+ AbsPlace (
369370 0,
370371 place(
371372 LOCAL,
372373 appendP(PROJS, projectionElemDeref projectionElemField(fieldIdx(1), #hack()) .ProjectionElems)
373- ),
374- mutabilityNot,
375- metadata(noMetadataSize, 0, noMetadataSize)
374+ )
376375 ),
377376 Integer(?SplMintLamports:Int, 64, false)
378377 )
379378 )
380379 ListItem(
381380 SPLRefCell(
382- Reference (
381+ AbsPlace (
383382 0,
384383 place(
385384 LOCAL,
386385 appendP(PROJS, projectionElemDeref projectionElemField(fieldIdx(2), #hack()) .ProjectionElems)
387- ),
388- mutabilityNot,
389- metadata(noMetadataSize, 0, noMetadataSize)
386+ )
390387 ),
391388 SPLDataBuffer(
392389 Aggregate(variantIdx(0),
@@ -431,28 +428,24 @@ module KMIR-SPL-TOKEN
431428 ListItem(SPLPubkeyRef(Aggregate(variantIdx(0), ListItem(Range(?SplRentAccountKey:List))))) // pub key: &'a Pubkey
432429 ListItem(
433430 SPLRefCell(
434- Reference (
431+ AbsPlace (
435432 0,
436433 place(
437434 LOCAL,
438435 appendP(PROJS, projectionElemDeref projectionElemField(fieldIdx(1), #hack()) .ProjectionElems)
439- ),
440- mutabilityNot,
441- metadata(noMetadataSize, 0, noMetadataSize)
436+ )
442437 ),
443438 Integer(?SplRentLamports:Int, 64, false)
444439 )
445440 ) // lamports: Rc<RefCell<&'a mut u64>>
446441 ListItem( // data: Rc<RefCell<&'a mut [u8]>>
447442 SPLRefCell(
448- Reference (
443+ AbsPlace (
449444 0,
450445 place(
451446 LOCAL,
452447 appendP(PROJS, projectionElemDeref projectionElemField(fieldIdx(2), #hack()) .ProjectionElems)
453- ),
454- mutabilityNot,
455- metadata(noMetadataSize, 0, noMetadataSize)
448+ )
456449 ),
457450 SPLDataBuffer(
458451 Aggregate(variantIdx(0),
@@ -501,7 +494,7 @@ expose the wrapped payload directly.
501494 syntax KItem ::= #finishSPLRcDeref ( Evaluation , Place , MaybeBasicBlockIdx ) [seqstrict(1)]
502495 | #resolveSPLRcRef ( Value , Place , MaybeBasicBlockIdx )
503496 | #finishResolvedSPLRc ( Place , MaybeBasicBlockIdx )
504- | #writeThroughRef ( Value , Value )
497+ | #writeThroughAbsPlace ( AbsPlace , Value )
505498
506499 rule <k> #finishSPLRcDeref(Reference(OFFSET, PLACE, MUT, META), DEST, TARGET)
507500 => #resolveSPLRcRef(Reference(OFFSET, PLACE, MUT, META), DEST, TARGET)
@@ -549,15 +542,15 @@ expose the wrapped payload directly.
549542 </k>
550543
551544 // Cross-frame write helper for SPL ref cells
552- rule <k> #writeThroughRef(Reference (0, place(local(I), PROJS), _, _ ), VAL)
545+ rule <k> #writeThroughAbsPlace(AbsPlace (0, place(local(I), PROJS)), VAL)
553546 => #forceSetPlaceValue(place(local(I), PROJS), VAL)
554547 ...
555548 </k>
556549 <locals> LOCALS </locals>
557550 requires 0 <=Int I andBool I <Int size(LOCALS)
558551 andBool isTypedLocal(LOCALS[I])
559552
560- rule <k> #writeThroughRef(Reference (OFFSET, place(local(I), PROJS), _, _ ), VAL)
553+ rule <k> #writeThroughAbsPlace(AbsPlace (OFFSET, place(local(I), PROJS)), VAL)
561554 => #traverseProjection(
562555 toStack(OFFSET, local(I)),
563556 #localFromFrame({STACK[OFFSET -Int 1]}:>StackFrame, local(I), OFFSET),
@@ -602,7 +595,7 @@ expose the wrapped payload directly.
602595
603596``` k
604597 // Step 1
605- syntax Context ::= CtxSPLRefCell ( Value )
598+ syntax Context ::= CtxSPLRefCell ( AbsPlace )
606599 rule <k> #traverseProjection(
607600 DEST,
608601 SPLRefCell(PLACE, VAL),
@@ -622,7 +615,7 @@ expose the wrapped payload directly.
622615 rule #projectionsFor(CtxSPLRefCell(_) CTXS, PROJS) => #projectionsFor(CTXS, projectionElemDeref PROJS)
623616
624617 // Step 2
625- syntax Context ::= CtxSPLDataBorrow ( Value )
618+ syntax Context ::= CtxSPLDataBorrow ( AbsPlace )
626619 rule <k> #traverseProjection(
627620 DEST,
628621 SPLDataBorrow(PLACE, VAL),
@@ -641,7 +634,7 @@ expose the wrapped payload directly.
641634 rule #buildUpdate(VAL, CtxSPLDataBorrow(PLACE) CTXS) => #buildUpdate(SPLDataBorrow(PLACE, SPLDataBuffer(VAL)), CTXS)
642635 rule #projectionsFor(CtxSPLDataBorrow(_) CTXS, PROJS) => #projectionsFor(CTXS, projectionElemDeref PROJS)
643636
644- syntax Context ::= CtxSPLDataBorrowMut ( Value )
637+ syntax Context ::= CtxSPLDataBorrowMut ( AbsPlace )
645638 rule <k> #traverseProjection(
646639 DEST,
647640 SPLDataBorrowMut(PLACE, VAL),
@@ -824,14 +817,13 @@ expose the wrapped payload directly.
824817 syntax KItem ::= #mkSPLAccountPack ( Evaluation , Evaluation , Place ) [seqstrict(1,2)]
825818
826819 rule <k> #mkSPLAccountPack(ACCOUNT, SPLDataBorrowMut(PLACE, SPLDataBuffer(_)), DEST)
827- => #writeThroughRef (
820+ => #writeThroughAbsPlace (
828821 PLACE,
829822 SPLRefCell(PLACE, SPLDataBuffer(ACCOUNT))
830823 )
831824 ~> #setLocalValue(DEST, Aggregate(variantIdx(0), ListItem(Aggregate(variantIdx(0), .List))))
832825 ...
833826 </k>
834- requires isRef(PLACE)
835827```
836828
837829``` {.k .symbolic}
0 commit comments