Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(stdlib): Clean up runtime printing library #2180

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion stdlib/runtime/debugPrint.gr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@noPervasives
module DebugPrint

from "runtime/numberUtils" include NumberUtils as Utils
Expand All @@ -9,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 @@ -26,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.

Loading