Advertisement
Guest User

Ocaml

a guest
Sep 22nd, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.97 KB | None | 0 0
  1. | Async (_, p, id, par)  ->
  2.       (
  3.        let nr = !nr_ref in
  4.         nr_ref := nr + 1;
  5.         match Env.lookup_task id topl with
  6.         | TaskDef (id, al, sl) ->
  7.           let idp = path ^ "_" ^ id ^ if nr > 0 then string_of_int nr else "" in
  8.           let sl = Str.split (Str.regexp ",") al in
  9.           let arg a = Str.split (Str.regexp "[ \t]+") a in
  10.           let argl = List.map arg sl in
  11.           let arga ar = match ar with
  12.           | a :: b :: [] -> " arg_" ^ idp ^ "." ^ b
  13.           | _ -> failwith("Error parsing argument (" ^ al ^ ") of task " ^ id)
  14.           in
  15.           let args = mycon "," (List.map arga argl) in
  16.           "ARG_" ^ id ^ " arg_" ^ idp ^ "; // instance for argument" ^ nl ^
  17.           "void entry_" ^ idp ^ "(int RTFM_id) {" ^ nl ^
  18.           tab ^ idp ^ pass_par args ^ "; // (inlined) call to the async function" ^ nl ^
  19.           "}"
  20.         | _                  -> raise (RtfmError("Lookup failed in Env.lookup_task id topl"))
  21.       )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement