@typeberry/jam 0.1.2-b7cae5d → 0.1.2-dd9b0e2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12987,8 +12987,8 @@ function print(level, levelAndName, strings, data) {
12987
12987
  return;
12988
12988
  }
12989
12989
  const lvlText = Level[level].padEnd(5);
12990
- const val = strings.map((v, idx) => `${v}${data[idx]}`);
12991
- const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
12990
+ const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
12991
+ const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
12992
12992
  if (level === Level.WARN) {
12993
12993
  console.warn(msg);
12994
12994
  }
@@ -15478,6 +15478,17 @@ class page_range_PageRange {
15478
15478
  }
15479
15479
  return new page_range_PageRange(start, length);
15480
15480
  }
15481
+ /** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
15482
+ isWrapped() {
15483
+ return this.start >= this.end && !this.isEmpty();
15484
+ }
15485
+ /** Checks if given page number is within the range */
15486
+ isInRange(page) {
15487
+ if (this.isWrapped()) {
15488
+ return page >= this.start || page < this.end;
15489
+ }
15490
+ return page >= this.start && page < this.end;
15491
+ }
15481
15492
  /** Checks if a range is empty (`length === 0`) */
15482
15493
  isEmpty() {
15483
15494
  return this.length === 0;
@@ -15857,10 +15868,11 @@ class memory_builder_MemoryBuilder {
15857
15868
  startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
15858
15869
  `;
15859
15870
  this.ensureNotFinalized();
15860
- const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
15861
- const pages = PageRange.fromMemoryRange(range);
15862
- for (const pageNumber of pages) {
15863
- if (this.initialMemory.has(pageNumber)) {
15871
+ const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
15872
+ const heapPagesRange = PageRange.fromMemoryRange(heapRange);
15873
+ const initializedPageNumbers = Array.from(this.initialMemory.keys());
15874
+ for (const pageNumber of initializedPageNumbers) {
15875
+ if (heapPagesRange.isInRange(pageNumber)) {
15864
15876
  throw new IncorrectSbrkIndex();
15865
15877
  }
15866
15878
  }