@@ -11,7 +11,7 @@ import std.bitmanip : read;
11
11
import std.exception : enforce;
12
12
import std.range : front, popFront, popFrontExactly;
13
13
import std.system : Endian;
14
- import std.typecons : Tuple , tuple;
14
+ import std.typecons : Nullable, nullable, Tuple , tuple;
15
15
16
16
// /
17
17
struct Module
@@ -102,7 +102,7 @@ Tuple!(SectionCode, uint) decodeSectionHeader(ref const(ubyte)[] input)
102
102
const (Memory) decodeMemorySection (ref const (ubyte )[] input)
103
103
{
104
104
input.leb128! uint ();
105
- const limits = decodeLimits(input );
105
+ const limits = input. decodeLimits();
106
106
return Memory (limits: limits);
107
107
}
108
108
@@ -111,7 +111,7 @@ Limits decodeLimits(ref const(ubyte)[] input)
111
111
{
112
112
const flags = input.leb128! uint ();
113
113
const min = input.leb128! uint ();
114
- const max = flags == 0 ? uint .max : input.leb128! uint ();
114
+ const max = flags == 0 ? Nullable ! uint .init : nullable( input.leb128! uint () );
115
115
return Limits (min: min, max: max);
116
116
}
117
117
@@ -577,8 +577,8 @@ unittest
577
577
import std.process ;
578
578
import std.typecons ;
579
579
const tests = [
580
- tuple(" (module (memory 1))" , Limits(min: 1 , max: uint .max )),
581
- tuple(" (module (memory 1 2))" , Limits(min: 1 , max: 2 ))
580
+ tuple(" (module (memory 1))" , Limits(min: 1 , max: Nullable ! uint .init )),
581
+ tuple(" (module (memory 1 2))" , Limits(min: 1 , max: nullable( 2u ) ))
582
582
];
583
583
foreach (test; tests)
584
584
{
@@ -632,7 +632,7 @@ unittest
632
632
const (ubyte )[] wasm = cast (ubyte []) p.output;
633
633
const actual = decodeModule(wasm);
634
634
const Module expected = {
635
- memorySection: [Memory(limits: Limits(min: 1 , max: uint .max ))],
635
+ memorySection: [Memory(limits: Limits(min: 1 , max: Nullable ! uint .init ))],
636
636
dataSection: test[1 ]
637
637
};
638
638
assert (actual == expected);
0 commit comments