Revision d4c98bae
Added by Arnaud Dieumegard over 6 years ago
src/backends/VHDL/vhdl_ast_deriving.ml | ||
---|---|---|
6156 | 6156 |
{ |
6157 | 6157 |
name: vhdl_name_t [@default NoName]; |
6158 | 6158 |
shared_defs: vhdl_definition_t list [@default []]; |
6159 |
shared_decls: vhdl_declaration_t list [@default []]} |
|
6159 |
shared_decls: vhdl_declaration_t list [@default []]; |
|
6160 |
shared_uses: vhdl_load_t list [@default []]}[@@deriving |
|
6161 |
((show { with_path = false }), |
|
6162 |
(yojson { strict = false }))] |
|
6160 | 6163 |
|
6161 | 6164 |
let rec pp_vhdl_package_t : |
6162 | 6165 |
Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit = |
6163 |
let __2 () = pp_vhdl_declaration_t |
|
6164 |
|
|
6166 |
let __3 () = pp_vhdl_load_t |
|
6167 |
|
|
6168 |
and __2 () = pp_vhdl_declaration_t |
|
6169 |
|
|
6165 | 6170 |
and __1 () = pp_vhdl_definition_t |
6166 | 6171 |
|
6167 | 6172 |
and __0 () = pp_vhdl_name_t |
... | ... | |
6190 | 6195 |
if sep then Format.fprintf fmt ""; |
6191 | 6196 |
((__2 ()) fmt) x; |
6192 | 6197 |
Format.fprintf fmt ";"; |
6193 |
true) false x))) x.shared_decls;) |
|
6198 |
true) false x))) x.shared_decls; |
|
6199 |
((fun x -> |
|
6200 |
ignore |
|
6201 |
(List.fold_left |
|
6202 |
(fun sep -> |
|
6203 |
fun x -> |
|
6204 |
Format.fprintf fmt "@;"; |
|
6205 |
if sep then Format.fprintf fmt ""; |
|
6206 |
((__3 ()) fmt) x; |
|
6207 |
Format.fprintf fmt ";"; |
|
6208 |
true) false x))) x.shared_uses;) |
|
6194 | 6209 |
[@ocaml.warning "-A"]) |
6195 | 6210 |
|
6196 | 6211 |
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string = |
... | ... | |
6200 | 6215 |
((let open! Ppx_deriving_yojson_runtime in |
6201 | 6216 |
fun x -> |
6202 | 6217 |
let fields = [] in |
6218 |
let fields = |
|
6219 |
if x.shared_uses = [] |
|
6220 |
then fields |
|
6221 |
else |
|
6222 |
("shared_uses", |
|
6223 |
(((fun x -> |
|
6224 |
`List (List.map (fun x -> vhdl_load_t_to_yojson x) x))) |
|
6225 |
x.shared_uses)) |
|
6226 |
:: fields |
|
6227 |
in |
|
6203 | 6228 |
let fields = |
6204 | 6229 |
if x.shared_decls = [] |
6205 | 6230 |
then fields |
... | ... | |
6237 | 6262 |
((let open! Ppx_deriving_yojson_runtime in |
6238 | 6263 |
function |
6239 | 6264 |
| `Assoc xs -> |
6240 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
|
6265 |
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
|
6241 | 6266 |
match xs with |
6242 | 6267 |
| ("name",x)::xs -> |
6243 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
|
6268 |
loop xs |
|
6269 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3) |
|
6244 | 6270 |
| ("shared_defs",x)::xs -> |
6245 | 6271 |
loop xs |
6246 | 6272 |
(arg0, |
... | ... | |
6250 | 6276 |
[] xs |
6251 | 6277 |
| _ -> |
6252 | 6278 |
Result.Error "Vhdl_ast.vhdl_package_t.shared_defs") |
6253 |
x), arg2) |
|
6279 |
x), arg2, arg3)
|
|
6254 | 6280 |
| ("shared_decls",x)::xs -> |
6255 | 6281 |
loop xs |
6256 | 6282 |
(arg0, arg1, |
... | ... | |
6260 | 6286 |
[] xs |
6261 | 6287 |
| _ -> |
6262 | 6288 |
Result.Error "Vhdl_ast.vhdl_package_t.shared_decls") |
6289 |
x), arg3) |
|
6290 |
| ("shared_uses",x)::xs -> |
|
6291 |
loop xs |
|
6292 |
(arg0, arg1, arg2, |
|
6293 |
((function |
|
6294 |
| `List xs -> |
|
6295 |
map_bind (fun x -> vhdl_load_t_of_yojson x) [] xs |
|
6296 |
| _ -> |
|
6297 |
Result.Error "Vhdl_ast.vhdl_package_t.shared_uses") |
|
6263 | 6298 |
x)) |
6264 | 6299 |
| [] -> |
6265 |
arg2 >>= |
|
6266 |
((fun arg2 -> |
|
6267 |
arg1 >>= |
|
6268 |
(fun arg1 -> |
|
6269 |
arg0 >>= |
|
6270 |
(fun arg0 -> |
|
6271 |
Result.Ok |
|
6272 |
{ |
|
6273 |
name = arg0; |
|
6274 |
shared_defs = arg1; |
|
6275 |
shared_decls = arg2 |
|
6276 |
})))) |
|
6300 |
arg3 >>= |
|
6301 |
((fun arg3 -> |
|
6302 |
arg2 >>= |
|
6303 |
(fun arg2 -> |
|
6304 |
arg1 >>= |
|
6305 |
(fun arg1 -> |
|
6306 |
arg0 >>= |
|
6307 |
(fun arg0 -> |
|
6308 |
Result.Ok |
|
6309 |
{ |
|
6310 |
name = arg0; |
|
6311 |
shared_defs = arg1; |
|
6312 |
shared_decls = arg2; |
|
6313 |
shared_uses = arg3 |
|
6314 |
}))))) |
|
6277 | 6315 |
| _::xs -> loop xs _state in |
6278 |
loop xs ((Result.Ok NoName), (Result.Ok []), (Result.Ok [])) |
|
6316 |
loop xs |
|
6317 |
((Result.Ok NoName), (Result.Ok []), (Result.Ok []), |
|
6318 |
(Result.Ok [])) |
|
6279 | 6319 |
| _ -> Result.Error "Vhdl_ast.vhdl_package_t") |
6280 | 6320 |
[@ocaml.warning "-A"]) |
6281 | 6321 |
|
Also available in: Unified diff
Use clauses in package definition