Stabel

Check-in [8f6b7a467b]
Login
Overview
Comment:Update test_expression.js, with instructions on how to use it.
Timelines: family | ancestors | descendants | both | arrays
Files: files | file ages | folders
SHA3-256: 8f6b7a467b284997311b2d503edff637084e8c8c43b0b8a892702f028323d15d
User & Date: robin.hansen on 2021-08-28 07:34:12
Other Links: branch diff | manifest | tags
Context
2021-08-28
10:35
Fixed bugs in array built ins. check-in: 66a08ffa3d user: robin.hansen tags: arrays
07:34
Update test_expression.js, with instructions on how to use it. check-in: 8f6b7a467b user: robin.hansen tags: arrays
2021-08-27
08:26
First attempt at array-get. Has a bug. check-in: 9c25d24e88 user: robin.hansen tags: arrays
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified test_expression.js from [38206c5380] to [115b939d03].




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41



const compiler = require('./wasm_tests/compiler.wrapper');
const wabt = require('wabt')();

const memory = new WebAssembly.Memory({
    initial: 1
});

global.memView = new Uint32Array(memory.buffer, 0, 512);

async function init() {
    const wat = await compiler.toWat(`
        deftype: Box
        : { value: Int }

        deftype: BoxOfBox
        : { box: Box }

        defmulti: deep-one?
        when: BoxOfBox( box Box( value 1 ) )
          drop 1
        : drop 0

        def: main
        entry: true
        : 1 >Box >BoxOfBox deep-one?
    `);

    const wasmModule = wabt.parseWat('tmp', wat).toBinary({}).buffer;

    const imports = {
        host: {
            memory: memory
        }
    };

    const program = await WebAssembly.instantiate(wasmModule, imports);
    debugger;
    program.instance.exports.main();
}

init();
>
>
>

|








|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<








<




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25






26
27
28
29
30
31
32
33

34
35
36
37
// Execute with: node --inspect-brk ./test_expression.js
// Then open chrome and go to: chrome://inspect

const compiler = require('./wasm_tests/compiler.wrapper');
const wabtInit = require('wabt');

const memory = new WebAssembly.Memory({
    initial: 1
});

global.memView = new Uint32Array(memory.buffer, 0, 512);

async function init() {
    const wabt = await wabtInit();
    const wat = await compiler.toWat('main', `
        def: main
        : { 2 3 4 }
          0 1 -
          array-get
          drop
    `);

    const wasmModule = wabt.parseWat('tmp', wat, {
        bulk_memory: true
    }).toBinary({}).buffer;







    const imports = {
        host: {
            memory: memory
        }
    };

    const program = await WebAssembly.instantiate(wasmModule, imports);

    program.instance.exports.main();
}

init();