add morphisms to Msb-ContinuationBit Sequences

This commit is contained in:
Michael Sippel 2025-02-20 05:22:28 +01:00
parent b88251b9c4
commit 4a5977ec8e
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 44 additions and 8 deletions

View file

@ -3,22 +3,57 @@ morph_array_as_valterm_to_lenpfx (Terminator:x86.UInt8)
--> <Seq~<LengthPrefix x86.UInt64> x86.UInt8>
```
length_prefix_uint8_array_clear(dst);
while( *src != Terminator ) {
length_prefix_uint8_array_push(dst, *src);
src++;
}
while( *src != Terminator )
length_prefix_uint8_array_push(dst, *src++);
return 0;
```
morph_array_as_lenpfx_to_valterm (Terminator:x86.UInt8)
<Seq~<LengthPrefix x86.UInt64> x86.UInt8>
--> <Seq~<ValueTerminated Terminator> x86.UInt8>
```
for( uint64_t i = 0; i < src->len; ++i ) {
*dst ++ = src->items[i];
}
for( uint64_t i = 0; i < src->len; ++i )
*dst++ = src->items[i];
*dst = Terminator;
return 0;
```
morph_array_as_lenpfx_to_continuation_bit_8 ()
<Seq~<LengthPrefix x86.UInt64> x86.UInt8>
--> <Seq~MsbCont x86.UInt8>
```
for( uint64_t i = 0; i < src->len; ++i ) {
if( src->items[i] & (1<<7) ) {
fprintf(stderr, "error: value to high for MsbContinuation\n");
return -1;
}
dst[i] = src->items[i];
if( i+1 < src->len )
dst[i] |= (1<<7);
}
return 0;
```
morph_array_as_lenpfx_to_continuation_bit_16 ()
<Seq~<LengthPrefix x86.UInt64> x86.UInt16>
--> <Seq~MsbCont x86.UInt16>
```
for( uint64_t i = 0; i < src->len; ++i ) {
if( src->items[i] & (1<<15) ) {
fprintf(stderr, "error: value to high for MsbContinuation\n");
return -1;
}
dst[i] = src->items[i];
if( i+1 < src->len )
dst[i] |= (1<<15);
}
return 0;
```

View file

@ -358,7 +358,8 @@ fn parser(
fn main() {
let mut type_dict = Arc::new(RwLock::new(BimapTypeDict::new()));
let mut morphism_base = laddertypes::MorphismBase::<LdmcMorphism>::new(vec![
type_dict.parse("Seq~<ValueTerminated '\\0'>").expect(""),
//type_dict.parse("Seq~MsbCont").expect(""),
//type_dict.parse("Seq~<ValueTerminated '\\0'>").expect(""),
type_dict.parse("Seq~<LengthPrefix x86.UInt64>").expect("")
]);