Skip to content

Commit

Permalink
Fix wasm build
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed May 21, 2024
1 parent 18f0482 commit 5536fbf
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions format.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type column struct {
fill rune
}

// TODO: much of this can be removed/replaced if we replace this with
// https://github.com/arp242/acidtab, which is basically a much nicer version of
// all of this.

type Format struct {
format string // Format string: %(..)
as printAs // How to print (list, table, json)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/mattn/go-runewidth v0.0.15
zgo.at/termtext v1.4.0
zgo.at/zli v0.0.0-20240517053106-e77926aab499
zgo.at/zli v0.0.0-20240521052840-819d150b8974
zgo.at/zstd v0.0.0-20240521013615-10baa641d7d0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
zgo.at/termtext v1.4.0 h1:r7fzyT5jsdRw9Z0uCQh+A+TWhWk+pC5HDJd1o8EH8NI=
zgo.at/termtext v1.4.0/go.mod h1:CBx+HpG2ijB3W0Bd4CK8UtzcsXw+EmvvlhQUyQpZO+E=
zgo.at/zli v0.0.0-20240517053106-e77926aab499 h1:Qe5yOdq++DJ2JfbYR/7+8GbmAnVrYw6PGCH7OiPFTXU=
zgo.at/zli v0.0.0-20240517053106-e77926aab499/go.mod h1:qhnApe1+0zc1rz3S9lbauLTBZstPJMCw9jlH9ly28q8=
zgo.at/zli v0.0.0-20240521052840-819d150b8974 h1:YDS8AQffen7PNH8wlpEvqimOIfuYaPZP9UM6E0hkb1k=
zgo.at/zli v0.0.0-20240521052840-819d150b8974/go.mod h1:qhnApe1+0zc1rz3S9lbauLTBZstPJMCw9jlH9ly28q8=
zgo.at/zstd v0.0.0-20240521013615-10baa641d7d0 h1:s4v5EAzMGV4ly1t240XidEY1Cq0OuyZSZL57Kbz/Big=
zgo.at/zstd v0.0.0-20240521013615-10baa641d7d0/go.mod h1:o/Q8+EtSahHnfkbB3t8wXE0FnoDTmJ0sBDlzezv9XeM=
3 changes: 1 addition & 2 deletions uni.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ func main() {
asF = flag.String("list", "a", "as")
jsonF = flag.Bool(false, "json", "j")
)
err := flag.Parse()
zli.F(err)
zli.F(flag.Parse())

if versionF.Set() {
fmt.Println(version)
Expand Down
1 change: 1 addition & 0 deletions wasm/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
Expand Down
15 changes: 11 additions & 4 deletions wasm/wasm_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
outputBuf += decoder.decode(buf);
const nl = outputBuf.lastIndexOf("\n");
if (nl != -1) {
console.log(outputBuf.substr(0, nl));
outputBuf = outputBuf.substr(nl + 1);
console.log(outputBuf.substring(0, nl));
outputBuf = outputBuf.substring(nl + 1);
}
return buf.length;
},
Expand Down Expand Up @@ -113,6 +113,10 @@
this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
}

const setInt32 = (addr, v) => {
this.mem.setUint32(addr + 0, v, true);
}

const getInt64 = (addr) => {
const low = this.mem.getUint32(addr + 0, true);
const high = this.mem.getInt32(addr + 4, true);
Expand Down Expand Up @@ -206,7 +210,10 @@

const timeOrigin = Date.now() - performance.now();
this.importObject = {
go: {
_gotest: {
add: (a, b) => a + b,
},
gojs: {
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
Expand Down Expand Up @@ -269,7 +276,7 @@
this._resume();
}
},
getInt64(sp + 8) + 1, // setTimeout has been seen to fire up to 1 millisecond early
getInt64(sp + 8),
));
this.mem.setInt32(sp + 16, id, true);
},
Expand Down

0 comments on commit 5536fbf

Please sign in to comment.