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

proper error on unknown identifiers when rewriting text2binary #512

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/bin/owi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ let exit_code =
| `Unclosed_string -> 76
| `Unbounded_quantification -> 77
| `Invalid_model _msg -> 78
| `Unknown_export _id -> 79
end
end
| Error e -> (
Expand Down
21 changes: 21 additions & 0 deletions src/text_to_binary/assigned.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,24 @@ let of_grouped (modul : Grouped.t) : t Result.t =
; start = modul.start
; annots = modul.annots
}

let find (named : 'a Named.t) err : _ -> binary indice Result.t = function
| Raw _i as indice -> Ok indice
| Text name -> (
match String_map.find_opt name named.named with
| None -> Error err
| Some i -> Ok (Raw i) )

let find_func modul id = find modul.func (`Unknown_func id) id

let find_global modul id = find modul.global (`Unknown_global id) id

let find_memory modul id = find modul.mem (`Unknown_memory id) id

let find_table modul id = find modul.table (`Unknown_table id) id

let find_data modul id = find modul.data (`Unknown_data id) id

let find_elem modul id = find modul.elem (`Unknown_elem id) id

let find_type modul id = find modul.typ (`Unknown_type id) id
14 changes: 14 additions & 0 deletions src/text_to_binary/assigned.mli
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ type t =
}

val of_grouped : Grouped.t -> t Result.t

val find_func : t -> text indice -> binary indice Result.t

val find_global : t -> text indice -> binary indice Result.t

val find_memory : t -> text indice -> binary indice Result.t

val find_data : t -> text indice -> binary indice Result.t

val find_table : t -> text indice -> binary indice Result.t

val find_elem : t -> text indice -> binary indice Result.t

val find_type : t -> text indice -> binary indice Result.t
Loading
Loading