@@ -12,6 +12,12 @@ type thread = {
1212 init : (string * value ) list ;
1313}
1414
15+ type section = {
16+ sec_name : string ;
17+ address : int ;
18+ code : string ;
19+ }
20+
1521type expect =
1622 | Sat
1723 | Unsat
@@ -20,6 +26,7 @@ type t = {
2026 arch : Litmus.Arch_id .t ;
2127 name : string ;
2228 threads : thread list ;
29+ sections : section list ;
2330 symbolic : string list ;
2431 locations : (string * value ) list ;
2532 expect : expect ;
@@ -53,6 +60,27 @@ let parse_threads toml =
5360 let table = Otoml. get_table toml in
5461 List. sort (fun a b -> compare a.tid b.tid) (List. map parse_thread table)
5562
63+ let parse_address = function
64+ | Otoml. TomlInteger i -> i
65+ | Otoml. TomlString s ->
66+ (try Z. to_int (Z. of_string s)
67+ with Invalid_argument _ ->
68+ raise (Otoml. Type_error (" invalid address: " ^ s)))
69+ | v ->
70+ raise (Otoml. Type_error
71+ (" address must be integer or hex string, got: " ^
72+ Otoml.Printer. to_string v))
73+
74+ let parse_section (name , table ) =
75+ let _ = Otoml. get_table table in
76+ let address = Otoml. find table parse_address [" address" ] in
77+ let code = Otoml. find table Otoml. get_string [" code" ] |> String. trim in
78+ { sec_name = name; address; code }
79+
80+ let parse_sections toml =
81+ let table = Otoml. get_table toml in
82+ List. map parse_section table
83+
5684let parse_expect toml =
5785 match Otoml. get_string toml with
5886 | "sat" -> Sat
@@ -85,6 +113,8 @@ let of_toml toml =
85113 arch = Otoml. find toml parse_arch [" arch" ];
86114 name = Otoml. find_or ~default: " unknown" toml Otoml. get_string [" name" ];
87115 threads = Otoml. find toml parse_threads [" thread" ];
116+ sections =
117+ Otoml. find_or ~default: [] toml parse_sections [" section" ];
88118 symbolic =
89119 Otoml. find_or ~default: [] toml (Otoml. get_array Otoml. get_string) [" symbolic" ];
90120 locations = Otoml. find_or ~default: [] toml (Otoml. get_table_values parse_value) [" locations" ];
0 commit comments