Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Infinite) Loops, br(anch) not working #438

Open
void4 opened this issue Aug 16, 2018 · 2 comments
Open

(Infinite) Loops, br(anch) not working #438

void4 opened this issue Aug 16, 2018 · 2 comments

Comments

@void4
Copy link

void4 commented Aug 16, 2018

The following calls the imported function only once:

webassemblyjs = require("webassemblyjs");

var code = `
(module
  (import "a" "a" (func $a (param i32)))
  (func $custom (param i32)
    (block
      (loop
        (get_local 0)
        (call $a)
        (br 0)
      )
    )
  )
  (export "custom" (func $custom))
)
`
function a(v) {
    console.log(v)
}

var IO = {"a":{a}}
var instance = webassemblyjs.instantiateFromSource(code, IO);
try {
    var result = instance.exports.custom(1);
    console.log(result)
} catch (e) {
    console.log("Exception:", e)
}

This may be related to: #66

@xtuc
Copy link
Owner

xtuc commented Aug 19, 2018

Btw here's a PR #338, i'm currently working on it

@xtuc
Copy link
Owner

xtuc commented Nov 6, 2018

I just merged #449, branching and control flow should be easier now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants