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 1 commit
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
32 changes: 16 additions & 16 deletions stdlib/runtime/bigint.gr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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
from "runtime/debugPrint" include DebugPrint as RPrint

// things we need which are missing due to --no-pervasives:
primitive (!) = "@not"
Expand Down Expand Up @@ -136,26 +136,26 @@ let init = (limbs: WasmI32) => {
provide let debugDumpNumber = (num: WasmI32) => {
spotandjake marked this conversation as resolved.
Show resolved Hide resolved
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:")
RPrint.print("-=-=-=-== debug dump ==-=-=-=-")
RPrint.print("Ref Count:")
RPrint.printI64(WasmI64.extendI32U(WasmI32.load(num - 8n, 0n)))
RPrint.print("Heap Tag:")
RPrint.printI64(WasmI64.extendI32U(WasmI32.load(num, 0n)))
RPrint.print("Boxed Num Tag:")
RPrint.printI64(WasmI64.extendI32U(WasmI32.load(num, 4n)))
RPrint.print("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(
RPrint.printI64(WasmI64.extendI32U(limbs))
RPrint.print("Flags:")
RPrint.printI64(WasmI64.extendI32U(0xffffn & WasmI32.load(num, 12n)))
RPrint.print("<reserved>:")
RPrint.printI64(
WasmI64.extendI32U((0xffff0000n & WasmI32.load(num, 12n)) >>> 16n)
)
RPrint.printString("Limbs:")
RPrint.print("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))
RPrint.printI64(WasmI64.load(num, (i + 2n) * 8n))
}
}

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