Skip to content

Commit

Permalink
end of code
Browse files Browse the repository at this point in the history
CURRENT TESTS PASSED
  • Loading branch information
pannous committed Sep 12, 2024
1 parent 469baee commit f444179
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Frameworks/wasm-c-api
*/wapm
.idea/
.idea/*
.idea/**
.idea/**/*
node_modules/
tmp/
coverage/
Expand Down
19 changes: 13 additions & 6 deletions docs/wasp.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ function format(object) {

function error(msg) {
if (typeof results !== 'undefined')
results.value = "⚠️ ERROR: " + msg + "\n";
if (msg instanceof WebAssembly.CompileError)
results.value += "\n⚠️ ERROR: " + msg + "\n";
if (msg instanceof WebAssembly.CompileError) {
results.value += "\n⚠️ COMPILE ERROR:\n";
results.value += msg.stack + "\n";
; // ignore as it indicates that wasp has invalid syntax
else if (msg instanceof Error)
} else if (msg instanceof Error) {
results.value += msg.stack + "\n";
throw msg
}
else
throw new Error("⚠️ ERROR: " + msg)
}
Expand All @@ -64,10 +68,13 @@ let nop = x => 0 // careful, some wasi shim needs 0!

const fd_write = function (fd, c_io_vector, iovs_count, nwritten) {
while (iovs_count-- > 0) {
let text = string(c_io_vector);
if (fd === 0)
console.error(string(c_io_vector) || "\n");
else
console.log(string(c_io_vector) || "\n");
error(text || "\n");
else {
results.value += text || "\n";
console.log(text || "\n");
}
c_io_vector += 8
}
return -1; // todo
Expand Down
Loading

0 comments on commit f444179

Please sign in to comment.