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

Cannot address by function name #145

Open
dochne opened this issue Sep 9, 2021 · 0 comments
Open

Cannot address by function name #145

dochne opened this issue Sep 9, 2021 · 0 comments

Comments

@dochne
Copy link

dochne commented Sep 9, 2021

I'm having some trouble with trying to make a sensible interface to actually using this library, but I may just be missing something obvious (or, alternatively, have completely missed a key paradigm :P)

Looking at your example copy of your exports-function.php example, we see that although we have an exported function of "sum", it only ever gets referenced by $exports->offsetGet(0), not by Sum.

Compiling the most barebones addition rust program, I end up with something like this:

(module
  (type $t0 (func (param i32) (result i32)))
  (func $add_one (export "add_one") (type $t0) (param $p0 i32) (result i32)
    (i32.add
      (local.get $p0)
      (i32.const 1)))
  (memory $memory (export "memory") 16)
  (global $__data_end (export "__data_end") i32 (i32.const 1048576))
  (global $__heap_base (export "__heap_base") i32 (i32.const 1048576)))

The only way I can find to reference that function is like so: $addOne = (new Wasm\Extern($exports->offsetGet(1)))->asFunc();

There doesn't seem to be an getByName or similar.

I can iterate through the exports and filter it down to the exports that are only functions, but I haven't had any success at finding any method that will then translate that function to what it's name is.

Thank you!

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

1 participant