Skip to content

Commit

Permalink
chore(stdlib): Clean up runtime printing library (#2180)
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake authored Oct 30, 2024
1 parent 11b1fc2 commit 7e4ba22
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 122 deletions.
29 changes: 0 additions & 29 deletions stdlib/runtime/bigint.gr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ from "runtime/unsafe/wasmf32" include WasmF32
from "runtime/unsafe/wasmf64" include WasmF64
from "runtime/exception" include Exception
from "runtime/dataStructures" include DataStructures as DS
from "runtime/utils/printing" include Printing as RPrint

// things we need which are missing due to --no-pervasives:
primitive (!) = "@not"
Expand Down Expand Up @@ -131,34 +130,6 @@ let init = (limbs: WasmI32) => {
ptr
}

// For debugging
@unsafe
provide let debugDumpNumber = (num: WasmI32) => {
use WasmI32.{ (*), (+), (-), (&), (>>>), (<) }
//let num = WasmI32.fromGrain(num)
RPrint.printString("-=-=-=-== debug dump ==-=-=-=-")
RPrint.printString("Ref Count:")
RPrint.printNumber(WasmI64.extendI32U(WasmI32.load(num - 8n, 0n)))
RPrint.printString("Heap Tag:")
RPrint.printNumber(WasmI64.extendI32U(WasmI32.load(num, 0n)))
RPrint.printString("Boxed Num Tag:")
RPrint.printNumber(WasmI64.extendI32U(WasmI32.load(num, 4n)))
RPrint.printString("Num Limbs:")
let limbs = WasmI32.load(num, 8n)
RPrint.printNumber(WasmI64.extendI32U(limbs))
RPrint.printString("Flags:")
RPrint.printNumber(WasmI64.extendI32U(0xffffn & WasmI32.load(num, 12n)))
RPrint.printString("<reserved>:")
RPrint.printNumber(
WasmI64.extendI32U((0xffff0000n & WasmI32.load(num, 12n)) >>> 16n)
)
RPrint.printString("Limbs:")
for (let mut i = 0n; i < limbs; i += 1n) {
// if a nonzero limb is found, then we're at the min
RPrint.printNumber(WasmI64.load(num, (i + 2n) * 8n))
}
}

@unsafe
provide let getSize = ptr => {
WasmI32.load(ptr, 8n)
Expand Down
6 changes: 0 additions & 6 deletions stdlib/runtime/bigint.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ title: Bigint

Functions and constants included in the Bigint module.

### Bigint.**debugDumpNumber**

```grain
debugDumpNumber : (num: WasmI32) => Void
```

### Bigint.**getSize**

```grain
Expand Down
4 changes: 3 additions & 1 deletion stdlib/runtime/debugPrint.gr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ from "runtime/unsafe/memory" include Memory
foreign wasm fd_write:
(WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "wasi_snapshot_preview1"

primitive ignore = "@ignore"

@unsafe
provide let print = (s: String) => {
let ptr = WasmI32.fromGrain(s)
Expand All @@ -27,7 +29,7 @@ provide let print = (s: String) => {
WasmI32.store(iov, 1n, 12n)
fd_write(1n, iov, 2n, written)
Memory.free(buf)
void
ignore(s)
}

@unsafe
Expand Down
60 changes: 0 additions & 60 deletions stdlib/runtime/utils/printing.gr

This file was deleted.

26 changes: 0 additions & 26 deletions stdlib/runtime/utils/printing.md

This file was deleted.

0 comments on commit 7e4ba22

Please sign in to comment.