diff --git a/examples/rustc.html b/examples/rustc.html
index e760820..902e2ec 100644
--- a/examples/rustc.html
+++ b/examples/rustc.html
@@ -47,15 +47,11 @@
super();
this.term = term;
}
- fd_write(view8/*: Uint8Array*/, iovs/*: [wasi.Iovec]*/)/*: {ret: number, nwritten: number}*/ {
+ fd_write(data/*: Uint8Array*/)/*: {ret: number, nwritten: number}*/ {
let nwritten = 0;
- for (let iovec of iovs) {
- console.log(iovec.buf_len, iovec.buf_len, view8.slice(iovec.buf, iovec.buf + iovec.buf_len));
- let buffer = view8.slice(iovec.buf, iovec.buf + iovec.buf_len);
- this.term.writeUtf8(buffer);
- nwritten += iovec.buf_len;
- }
- return { ret: 0, nwritten };
+ console.log(data);
+ this.term.writeUtf8(data);
+ return { ret: 0, nwritten: data.byteLength };
}
}
@@ -75,16 +71,16 @@
new XtermStdio(term),
new XtermStdio(term),
new XtermStdio(term),
- new PreopenDirectory("/tmp", {}),
- new PreopenDirectory("/sysroot", {
- "lib": new Directory({
- "rustlib": new Directory({
- "wasm32-wasi": new Directory({
- "lib": new Directory({}),
- }),
- "x86_64-unknown-linux-gnu": new Directory({
- "lib": new Directory(await (async function () {
- let dir = {};
+ new PreopenDirectory("/tmp", []),
+ new PreopenDirectory("/sysroot", [
+ ["lib", new Directory([
+ ["rustlib", new Directory([
+ ["wasm32-wasi", new Directory([
+ ["lib", new Directory([])],
+ ])],
+ ["x86_64-unknown-linux-gnu", new Directory([
+ ["lib", new Directory(await (async function () {
+ let dir = new Map();
for (let file of [
"libaddr2line-3368a2ecf632bfc6.rlib",
"libadler-16845f650eeea12c.rlib",
@@ -115,17 +111,17 @@
"libunicode_width-d55ce9c674fbd422.rlib",
"libunwind-8ca3e01a84805f9e.rlib"
]) {
- dir[file] = await load_external_file("/examples/wasm-rustc/lib/rustlib/x86_64-unknown-linux-gnu/lib/" + file);
+ dir.set(file, await load_external_file("/examples/wasm-rustc/lib/rustlib/x86_64-unknown-linux-gnu/lib/" + file));
}
return dir;
- })()),
- }),
- }),
- }),
- }),
- new PreopenDirectory("/", {
- "hello.rs": new File(new TextEncoder("utf-8").encode(`fn main() { println!("Hello World!"); }`)),
- }),
+ })())],
+ ])],
+ ])],
+ ])],
+ ]),
+ new PreopenDirectory("/", [
+ ["hello.rs", new File(new TextEncoder("utf-8").encode(`fn main() { println!("Hello World!"); }`))],
+ ]),
];
let w = new WASI(args, env, fds, { debug: true });
@@ -135,14 +131,14 @@
});
term.writeln("\x1B[93mExecuting\x1B[0m");
console.log(inst.exports);
- try { w.start(inst); } catch(e) { term.writeln("Exception: " + e.message); term.writeln("backtrace:"); term.writeln(e.stack); throw e; }
+ try { w.start(inst); } catch(e) { term.writeln("Exception: " + e.message); /*term.writeln("backtrace:"); term.writeln(e.stack);*/ }
term.writeln("\x1B[92mDone\x1B[0m");
console.log(fds);
console.log(fds[5].dir);
- console.log(fds[5].dir.contents["hello.hello.2490b9cce2492134-cgu.0.rcgu.o"].data);
- document.querySelector("#downloads").innerHTML += "
Download object";
- document.querySelector("#downloads").innerHTML += "
Download allocator shim";
+ console.log(fds[5].dir.contents.get("hello.hello.2490b9cce2492134-cgu.0.rcgu.o").data);
+ document.querySelector("#downloads").innerHTML += "
Download object";
+ document.querySelector("#downloads").innerHTML += "
Download allocator shim";
})();