@raviqqe/stak 0.3.13 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/package.json +2 -2
- package/stak_wasm.d.ts +7 -2
- package/stak_wasm.js +23 -2
- package/stak_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Stak Scheme aims to be:
|
|
|
12
12
|
- An embeddable Scheme interpreter for Rust with very small memory footprint and reasonable performance
|
|
13
13
|
- The minimal implementation of [the R7RS-small standard][r7rs-small]
|
|
14
14
|
- A subset of [Chibi Scheme](https://github.com/ashinn/chibi-scheme), [Gauche](https://github.com/shirok/Gauche), and [Guile](https://www.gnu.org/software/guile/)
|
|
15
|
+
- A portable scripting environment that supports even no-`std` and no-`alloc` platforms
|
|
15
16
|
|
|
16
17
|
For more information and usage, visit [the full documentation](https://raviqqe.github.io/stak/install).
|
|
17
18
|
|
|
@@ -24,6 +25,7 @@ To install Stak Scheme as a library in your Rust project, run:
|
|
|
24
25
|
```sh
|
|
25
26
|
cargo add stak
|
|
26
27
|
cargo add --build stak-build
|
|
28
|
+
cargo install stak-compile
|
|
27
29
|
```
|
|
28
30
|
|
|
29
31
|
For full examples, see [the `examples` directory](https://github.com/raviqqe/stak/tree/main/examples).
|
|
@@ -130,7 +132,7 @@ const HEAP_SIZE: usize = 1 << 16;
|
|
|
130
132
|
static MODULE: UniversalModule = include_module!("fibonacci.scm");
|
|
131
133
|
|
|
132
134
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
133
|
-
let input =
|
|
135
|
+
let input = 15;
|
|
134
136
|
let mut output = vec![];
|
|
135
137
|
let mut error = vec![];
|
|
136
138
|
|
|
@@ -141,8 +143,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|
|
141
143
|
return Err(str::from_utf8(&error)?.into());
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
// Decode and
|
|
145
|
-
|
|
146
|
+
// Decode and test the output.
|
|
147
|
+
assert_eq!(isize::from_str(&str::from_utf8(&output)?)?, 610);
|
|
146
148
|
|
|
147
149
|
Ok(())
|
|
148
150
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raviqqe/stak",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"description": "Stak Scheme
|
|
5
|
-
"version": "0.3.
|
|
4
|
+
"description": "Stak Scheme in WebAssembly",
|
|
5
|
+
"version": "0.3.15",
|
|
6
6
|
"license": "SEE LICENSE IN ../LICENSE",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/stak_wasm.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
* Compiles
|
|
4
|
+
* Compiles source codes in Scheme.
|
|
5
5
|
*/
|
|
6
6
|
export function compile(source: string): Uint8Array;
|
|
7
7
|
/**
|
|
8
|
-
* Interprets bytecodes with
|
|
8
|
+
* Interprets bytecodes with standard input and returns its standard output.
|
|
9
9
|
*/
|
|
10
10
|
export function interpret(bytecodes: Uint8Array, input: Uint8Array, heap_size: number): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* Runs a Scheme script with standard input and returns its standard output.
|
|
13
|
+
*/
|
|
14
|
+
export function run(source: string, input: Uint8Array, heap_size: number): Uint8Array;
|
|
11
15
|
|
|
12
16
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
13
17
|
|
|
@@ -15,6 +19,7 @@ export interface InitOutput {
|
|
|
15
19
|
readonly memory: WebAssembly.Memory;
|
|
16
20
|
readonly compile: (a: number, b: number) => [number, number, number, number];
|
|
17
21
|
readonly interpret: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
22
|
+
readonly run: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
18
23
|
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
19
24
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
20
25
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
package/stak_wasm.js
CHANGED
|
@@ -85,7 +85,7 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
85
85
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
* Compiles
|
|
88
|
+
* Compiles source codes in Scheme.
|
|
89
89
|
* @param {string} source
|
|
90
90
|
* @returns {Uint8Array}
|
|
91
91
|
*/
|
|
@@ -108,7 +108,7 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
108
108
|
return ptr;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
* Interprets bytecodes with
|
|
111
|
+
* Interprets bytecodes with standard input and returns its standard output.
|
|
112
112
|
* @param {Uint8Array} bytecodes
|
|
113
113
|
* @param {Uint8Array} input
|
|
114
114
|
* @param {number} heap_size
|
|
@@ -128,6 +128,27 @@ export function interpret(bytecodes, input, heap_size) {
|
|
|
128
128
|
return v3;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Runs a Scheme script with standard input and returns its standard output.
|
|
133
|
+
* @param {string} source
|
|
134
|
+
* @param {Uint8Array} input
|
|
135
|
+
* @param {number} heap_size
|
|
136
|
+
* @returns {Uint8Array}
|
|
137
|
+
*/
|
|
138
|
+
export function run(source, input, heap_size) {
|
|
139
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
const len0 = WASM_VECTOR_LEN;
|
|
141
|
+
const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
142
|
+
const len1 = WASM_VECTOR_LEN;
|
|
143
|
+
const ret = wasm.run(ptr0, len0, ptr1, len1, heap_size);
|
|
144
|
+
if (ret[3]) {
|
|
145
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
146
|
+
}
|
|
147
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
148
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
149
|
+
return v3;
|
|
150
|
+
}
|
|
151
|
+
|
|
131
152
|
async function __wbg_load(module, imports) {
|
|
132
153
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
133
154
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
package/stak_wasm_bg.wasm
CHANGED
|
Binary file
|