@@ -74,10 +74,11 @@ Constant operands are simply decoded according to their type.
74
74
``` k
75
75
rule <k> operandConstant(constOperand(_, _, mirConst(KIND, TY, _)))
76
76
=>
77
- typedValue(#decodeConstant(KIND, {TYPEMAP[TY]}:>TypeInfo), TY, mutabilityNot)
77
+ typedValue(#decodeConstant(KIND, {TYPEMAP[TY]}:>TypeInfo, MEM ), TY, mutabilityNot)
78
78
...
79
79
</k>
80
80
<types> TYPEMAP </types>
81
+ <memory> MEM </memory>
81
82
requires TY in_keys(TYPEMAP)
82
83
andBool isTypeInfo(TYPEMAP[TY])
83
84
[preserves-definedness] // valid Map lookup checked
@@ -851,19 +852,19 @@ bit width, signedness, and possibly truncating or 2s-complementing the value.
851
852
The ` Value ` sort above operates at a higher level than the bytes representation found in the MIR syntax for constant values. The bytes have to be interpreted according to the given ` TypeInfo ` to produce the higher-level value. This is currently only defined for ` PrimitiveType ` s (primitive types in MIR).
852
853
853
854
``` k
854
- syntax Value ::= #decodeConstant ( ConstantKind, TypeInfo ) [function]
855
+ syntax Value ::= #decodeConstant ( ConstantKind, TypeInfo, Map ) [function]
855
856
856
857
//////////////////////////////////////////////////////////////////////////////////////
857
858
// decoding the correct amount of bytes depending on base type size
858
859
859
860
// Boolean: should be one byte with value one or zero
860
- rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), typeInfoPrimitiveType(primTypeBool)) => BoolVal(false)
861
+ rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), typeInfoPrimitiveType(primTypeBool), _MEM ) => BoolVal(false)
861
862
requires 0 ==Int Bytes2Int(BYTES, LE, Unsigned) andBool lengthBytes(BYTES) ==Int 1
862
- rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), typeInfoPrimitiveType(primTypeBool)) => BoolVal(true)
863
+ rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), typeInfoPrimitiveType(primTypeBool), _MEM ) => BoolVal(true)
863
864
requires 1 ==Int Bytes2Int(BYTES, LE, Unsigned) andBool lengthBytes(BYTES) ==Int 1
864
865
865
866
// Integer: handled in separate module for numeric operations
866
- rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), TYPEINFO)
867
+ rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), TYPEINFO, _MEM )
867
868
=>
868
869
#decodeInteger(BYTES, #intTypeOf(TYPEINFO))
869
870
requires #isIntType(TYPEINFO)
@@ -872,16 +873,23 @@ The `Value` sort above operates at a higher level than the bytes representation
872
873
873
874
////////////////////////////////////////////////////////////////////////////////////////////////
874
875
// FIXME Char type
875
- // rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _)), typeInfoPrimitiveType(primTypeChar))
876
+ // rule #decodeConstant(constantKindAllocated(allocation(BYTES, _, _, _), _MEM ), typeInfoPrimitiveType(primTypeChar))
876
877
// =>
877
878
// Str(...)
878
879
/////////////////////////////////////////////////////////////////////////////////////////////////
879
880
881
+ rule #decodeConstant(constantKindAllocated(allocation(_BYTES, provenanceMap(
882
+ provenanceMapEntry(_SIZE, allocId(ID:Int)) .ProvenanceMapEntries
883
+ ), _ALIGN, _MUT)), typeInfoRefType(_TY), MEMORY)
884
+ =>
885
+ RefAlloc(ID)
886
+ requires ID in_keys(MEMORY)
887
+ [preserves-definedness] // AllocId in Memory is checked, TY in Types checked previously
880
888
881
889
/////////////////////////////////////////////////////////////////////////////////////////////////
882
890
// TODO Float decoding: not supported natively in K
883
891
884
- rule #decodeConstant(_, _) => Any [owise]
892
+ rule #decodeConstant(_, _, _ ) => Any [owise]
885
893
```
886
894
887
895
## Primitive operations on numeric data
0 commit comments