• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / py-slang / 24284794110

11 Apr 2026 02:43PM UTC coverage: 69.576% (+2.7%) from 66.866%
24284794110

push

github

web-flow
Add SVML engine (#139)

* add svml interpreter

* add sinter backend

* fix Svml sinter run

* fix formatting

* fix review comments

* modify CI to --all

* fix lint

* remove newline

* fix coveralls type declaration search

* Tighten test suite

* style: format

* add tsconfig.test.json

* add parallel build for all

* refine test suite

* fix sinter

* appendum to sinter

* style:format

* full test suite, similar to stdlib.ts

* remove dead memoization machinery from SVML interpreter

isMemoized was always false and memoCache never populated.
Removes SVMLClosure.isMemoized/memoCache, CallFrame.memoArgs/memoClosure,
and all cache check/store logic in call/return paths.

1399 of 2343 branches covered (59.71%)

Branch coverage included in aggregate %.

1278 of 1550 new or added lines in 14 files covered. (82.45%)

4 existing lines in 4 files now uncovered.

4396 of 5986 relevant lines covered (73.44%)

5263.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.27
/src/utils/buffer.ts
1
declare global {
2
  interface ArrayBufferConstructor {
3
    transfer(source: ArrayBuffer, length: number): ArrayBuffer;
4
  }
5
}
6

7
if (!ArrayBuffer.transfer) {
1✔
8
  ArrayBuffer.transfer = (source, length) => {
1✔
9
    if (!(source instanceof ArrayBuffer))
20!
NEW
10
      throw new TypeError("Source must be an instance of ArrayBuffer");
×
11
    if (length <= source.byteLength) return source.slice(0, length);
20!
12
    const sourceView = new Uint8Array(source);
20✔
13
    const destView = new Uint8Array(new ArrayBuffer(length));
20✔
14
    destView.set(sourceView);
20✔
15
    return destView.buffer;
20✔
16
  };
17
}
18

19
/**
20
 * A little-endian byte buffer class.
21
 */
22
export default class Buffer {
1✔
23
  private _capacity: number;
24
  public cursor: number;
25
  private _written: number;
26
  private _buffer: ArrayBuffer;
27
  private _view: DataView;
28

29
  constructor() {
30
    this._capacity = 32;
44✔
31
    this.cursor = 0;
44✔
32
    this._written = 0;
44✔
33
    this._buffer = new ArrayBuffer(this._capacity);
44✔
34
    this._view = new DataView(this._buffer);
44✔
35
  }
36

37
  private maybeExpand(n: number) {
38
    if (this.cursor + n <= this._capacity) {
567✔
39
      return;
547✔
40
    }
41

42
    while (this.cursor + n > this._capacity) {
20✔
43
      this._capacity *= 2;
24✔
44
    }
45
    this._buffer = ArrayBuffer.transfer(this._buffer, this._capacity);
20✔
46
    this._view = new DataView(this._buffer);
20✔
47
  }
48

49
  private updateWritten() {
50
    this._written = Math.max(this._written, this.cursor);
567✔
51
  }
52

53
  get(signed: boolean, s: 8 | 16 | 32): number {
NEW
54
    const r = this._view[`get${signed ? "I" : "Ui"}nt${s}`](this.cursor, true);
×
NEW
55
    this.cursor += s / 8;
×
NEW
56
    return r;
×
57
  }
58

59
  getI(s: 8 | 16 | 32): number {
NEW
60
    return this.get(true, s);
×
61
  }
62

63
  getU(s: 8 | 16 | 32): number {
NEW
64
    return this.get(false, s);
×
65
  }
66

67
  getF(s: 32 | 64): number {
NEW
68
    const r = this._view[`getFloat${s}`](this.cursor, true);
×
NEW
69
    this.cursor += s / 8;
×
NEW
70
    return r;
×
71
  }
72

73
  put(n: number, signed: boolean, s: 8 | 16 | 32) {
74
    this.maybeExpand(s / 8);
537✔
75
    this._view[`set${signed ? "I" : "Ui"}nt${s}`](this.cursor, n, true);
537✔
76
    this.cursor += s / 8;
537✔
77
    this.updateWritten();
537✔
78
  }
79

80
  putI(s: 8 | 16 | 32, n: number) {
81
    this.put(n, true, s);
53✔
82
  }
83

84
  putU(s: 8 | 16 | 32, n: number) {
85
    this.put(n, false, s);
484✔
86
  }
87

88
  putF(s: 32 | 64, n: number) {
89
    this.maybeExpand(s / 8);
1✔
90
    this._view[`setFloat${s}`](this.cursor, n, true);
1✔
91
    this.cursor += s / 8;
1✔
92
    this.updateWritten();
1✔
93
  }
94

95
  putA(a: Uint8Array) {
96
    this.maybeExpand(a.byteLength);
29✔
97
    new Uint8Array(this._buffer, this.cursor, a.byteLength).set(a);
29✔
98
    this.cursor += a.byteLength;
29✔
99
    this.updateWritten();
29✔
100
  }
101

102
  align(n: number) {
103
    const rem = this.cursor % n;
58✔
104
    if (rem === 0) {
58✔
105
      return;
52✔
106
    }
107
    this.cursor += n - rem;
6✔
108
  }
109

110
  asArray(): Uint8Array {
111
    return new Uint8Array(this._buffer.slice(0, this._written));
67✔
112
  }
113

114
  get written(): number {
NEW
115
    return this._written;
×
116
  }
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc