Skip to content

Add support for ref.i31 for inline wasm strings #3

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/dwarfsm_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ type instr =
| Ref_func of funcidx
| Ref_is_null
| Ref_null of heaptype
| Ref_i31
| Return
| Struct_get of typeidx * fieldidx
| Struct_new of typeidx
Expand Down Expand Up @@ -2114,6 +2115,8 @@ include struct

method visit_Ref_is_null : _ -> instr = fun env -> Ref_is_null

method visit_Ref_i31 : _ -> instr = fun env -> Ref_i31

method visit_Ref_null : _ -> heaptype -> instr =
fun env ->
fun _visitors_c0 ->
Expand Down Expand Up @@ -2460,6 +2463,7 @@ include struct
| Ref_func _visitors_c0 -> self#visit_Ref_func env _visitors_c0
| Ref_is_null -> self#visit_Ref_is_null env
| Ref_null _visitors_c0 -> self#visit_Ref_null env _visitors_c0
| Ref_i31 -> self#visit_Ref_i31 env
| Return -> self#visit_Return env
| Struct_get (_visitors_c0, _visitors_c1) ->
self#visit_Struct_get env _visitors_c0 _visitors_c1
Expand Down Expand Up @@ -3237,6 +3241,9 @@ include struct
equal_heaptype _a__301_ _b__302_
| Ref_null _, _ -> false
| _, Ref_null _ -> false
| Ref_i31, Ref_i31 -> true
| Ref_i31, _ -> false
| _, Ref_i31 -> false
| Return, Return -> true
| Return, _ -> false
| _, Return -> false
Expand Down
1 change: 1 addition & 0 deletions src/dwarfsm_encode_wasm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ struct
| Ref_func x -> byte 0xd2 ^^ funcidx x
| Ref_is_null -> byte 0xd1
| Ref_null t -> byte 0xd0 ^^ heaptype t
| Ref_i31 -> byte 0xfb1c
| Return -> byte 0x0f
| Struct_get (x, y) -> byte 0xfb ^^ int_uleb128 2 ^^ structandfieldidx x y
| Struct_new x -> byte 0xfb ^^ int_uleb128 0 ^^ typeidx x
Expand Down
1 change: 1 addition & 0 deletions src/dwarfsm_parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ let rec plaininstr : W.t list -> instr * W.t list = function
| (Atom "ref.func" : W.t) :: (w : W.t) :: v -> (Ref_func (funcidx w), v)
| (Atom "ref.is_null" : W.t) :: v -> (Ref_is_null, v)
| (Atom "ref.null" : W.t) :: (w : W.t) :: v -> (Ref_null (heaptype w), v)
| (Atom "ref.i31" : W.t) :: v -> (Ref_i31, v)
| (Atom "return" : W.t) :: v -> (Return, v)
| (Atom "struct.get" : W.t) :: (w : W.t) :: (w2 : W.t) :: v ->
(Struct_get (typeidx w, fieldidx w2), v)
Expand Down