wasmer-python icon indicating copy to clipboard operation
wasmer-python copied to clipboard

Example of TableType FUNC_REF

Open prescod opened this issue 4 years ago • 4 comments

Thanks for proposing a new feature!

Motivation

I want to import a FUNC_REF table into my module.

Proposed solution

I would like to see an example like this in the docs and tests:

    table = Table(store, TableType(Type.FUNC_REF, minimum=0, maximum=10 ), INITIAL_VALUE)

What is INITIAL_VALUE?

prescod avatar Dec 26 '20 12:12 prescod

All the elements in the table will be set to the initial_value value. We must update the documentation accordingly, sorry for missing this!

Hywan avatar Jan 07 '21 14:01 Hywan

I think the question is what kind of Value is needed for initial_value? I've tried Value.i32 and all the others and every time it raises an exception saying that "val is not funcref".

Table(STORE, TableType(Type.FUNC_REF, 8, 8), Value.i64(8))
#                      what do we put here? ^

SNSTRUTHERS avatar Jan 18 '21 01:01 SNSTRUTHERS

I have the same problem, maybe it is self address?

class Table:
    def __init__(self, store, tabletype):
        self.initial_value = Value.i64(id(self))

or it can be ignored?

xhlove avatar Feb 23 '21 16:02 xhlove

I think the question is what kind of Value is needed for initial_value? I've tried Value.i32 and all the others and every time it raises an exception saying that "val is not funcref".

Table(STORE, TableType(Type.FUNC_REF, 8, 8), Value.i64(8))
#                      what do we put here? ^

I also have this problem,Have you reached a conclusion

bjxhx avatar May 10 '22 09:05 bjxhx