Skip to content

Commit

Permalink
fix table ref type
Browse files Browse the repository at this point in the history
  • Loading branch information
bbyalcinkaya committed Jan 18, 2024
1 parent b6cf5bf commit b03c138
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 4 additions & 5 deletions pykwasm/src/pykwasm/wasm2kast.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ def func(f: Function):

def table(t: Table):
ls = limits(t.type.limits)
if isinstance(t.type.elem_type, addresses.FunctionAddress):
typ = a.funcref
else:
typ = a.externref
typ = ref_type(t.type.elem_type)
return a.table(ls, typ)


Expand All @@ -123,7 +120,9 @@ def glob(g: Global):
def ref_type(t: RefType):
if t is addresses.FunctionAddress:
return a.funcref
return a.externref
if t is addresses.ExternAddress:
return a.externref
raise ValueError(f'Invalid RefType: {t}')


def elem_mode(m: ElemMode) -> KInner:
Expand Down
9 changes: 8 additions & 1 deletion pykwasm/src/tests/integration/binary/tables.wat
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
(module
(table 1 funcref))
(table (import "spectest" "table") 0 funcref)
(table 0 funcref)
(table 1 funcref)
(table 1 100 funcref)
(table 0 externref)
(table 1 externref)
(table 1 100 externref)
)

0 comments on commit b03c138

Please sign in to comment.