summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-08-25 00:21:06 +0800
committerGitHub <noreply@github.com>2020-08-24 18:21:06 +0200
commite8968e6bf4b3883c7d660034ae46c4584dadc119 (patch)
tree6b95ae8911cf59ffabb5cb51161d0fb2b22e670c
parentc1d543e10a85347c1c219202b10ab2e5cccf942c (diff)
BREAKING(std/wasi): rename Module to Context (#7110)
This commit renames Module and ModuleOptions to context to avoid stutter confusion, e.g avoid having documentation that says things like instantiate the snapshot's module's module.
-rw-r--r--std/wasi/README.md8
-rw-r--r--std/wasi/snapshot_preview1.ts6
-rw-r--r--std/wasi/snapshot_preview1_test.ts8
3 files changed, 11 insertions, 11 deletions
diff --git a/std/wasi/README.md b/std/wasi/README.md
index 4cbcbbca3..580e7ddd0 100644
--- a/std/wasi/README.md
+++ b/std/wasi/README.md
@@ -55,9 +55,9 @@ This module provides an implementation of the WebAssembly System Interface
## Usage
```typescript
-import WASI from "https://deno.land/std/wasi/snapshot_preview1.ts";
+import Context from "https://deno.land/std/wasi/snapshot_preview1.ts";
-const wasi = new WASI({
+const context = new Context({
args: Deno.args,
env: Deno.env,
});
@@ -65,10 +65,10 @@ const wasi = new WASI({
const binary = await Deno.readFile("path/to/your/module.wasm");
const module = await WebAssembly.compile(binary);
const instance = await WebAssembly.instantiate(module, {
- wasi_snapshot_preview1: wasi.exports,
+ wasi_snapshot_preview1: context.exports,
});
-wasi.memory = instance.exports.memory;
+context.memory = context.exports.memory;
if (module.exports._start) {
instance.exports._start();
diff --git a/std/wasi/snapshot_preview1.ts b/std/wasi/snapshot_preview1.ts
index 0e32e3a2b..ab9da73ec 100644
--- a/std/wasi/snapshot_preview1.ts
+++ b/std/wasi/snapshot_preview1.ts
@@ -277,14 +277,14 @@ function errno(err: Error) {
}
}
-export interface ModuleOptions {
+export interface ContextOptions {
args?: string[];
env?: { [key: string]: string | undefined };
preopens?: { [key: string]: string };
memory?: WebAssembly.Memory;
}
-export default class Module {
+export default class Context {
args: string[];
env: { [key: string]: string | undefined };
memory: WebAssembly.Memory;
@@ -294,7 +294,7 @@ export default class Module {
exports: Record<string, Function>;
- constructor(options: ModuleOptions) {
+ constructor(options: ContextOptions) {
this.args = options.args ? options.args : [];
this.env = options.env ? options.env : {};
this.memory = options.memory!;
diff --git a/std/wasi/snapshot_preview1_test.ts b/std/wasi/snapshot_preview1_test.ts
index 748ba7772..dce37d220 100644
--- a/std/wasi/snapshot_preview1_test.ts
+++ b/std/wasi/snapshot_preview1_test.ts
@@ -2,24 +2,24 @@
import { assert, assertEquals } from "../testing/asserts.ts";
import * as path from "../path/mod.ts";
-import WASI from "./snapshot_preview1.ts";
+import Context from "./snapshot_preview1.ts";
if (import.meta.main) {
const options = JSON.parse(Deno.args[0]);
const binary = await Deno.readFile(Deno.args[1]);
const module = await WebAssembly.compile(binary);
- const wasi = new WASI({
+ const context = new Context({
env: options.env,
args: options.args,
preopens: options.preopens,
});
const instance = new WebAssembly.Instance(module, {
- wasi_snapshot_preview1: wasi.exports,
+ wasi_snapshot_preview1: context.exports,
});
- wasi.memory = instance.exports.memory;
+ context.memory = instance.exports.memory;
instance.exports._start();
} else {