- ) kernels
- ) xs in
-
- let strs = strs @ [ common ] @ List.concat fs in
- strs in
-
- (* A map from kernel versions to follower functions.
- *
- * For each struct, we have a list of kernel versions which contain
- * that struct. Some kernels are missing a particular struct, so
- * that is turned into a ParseError exception.
- *)
- let strs =
- let nr_kernels =
- List.fold_left max 0
- (List.map (fun (_, (kernels, _, _, _)) -> List.length kernels) xs) in
- let nr_structs = List.length xs in
- let array = Array.make_matrix nr_kernels (nr_structs+1) (Missing "") in
- List.iteri (
- fun si (struct_name, _) ->
- for i = 0 to nr_kernels - 1 do
- array.(i).(si+1) <- Missing struct_name
- done
- ) xs;
- List.iteri (
- fun si (struct_name, (kernels, _, _, _)) ->
- List.iter (
- fun ({ PP.kernel_version = version; kv_i = kv_i }, _) ->
- array.(kv_i).(0) <- KernelVersion version;
- array.(kv_i).(si+1) <-
- Follower (sprintf "%s_kv%d_follower" struct_name kv_i)
- ) kernels
- ) xs;
-
- let array = Array.map (
- fun row ->
- match Array.to_list row with
- | [] | (Missing _|Follower _) :: _ -> assert false
- | KernelVersion kernel_version :: followers -> kernel_version, followers
- ) array in
-
- let map = List.fold_left (
- fun map (kernel_version, followers) ->
- let followers = List.map (
- function
- | Follower fname ->
- <:expr< $lid:fname$ >>
-
- (* no follower for this kernel/struct combination *)
- | Missing struct_name ->