X-Git-Url: http://git.annexia.org/?p=whenjobs.git;a=blobdiff_plain;f=lib%2Fwhenfile.ml;h=b109e667938f35bd9b7d23b065d8938f051ba497;hp=5f205fbcedad3ce9850c352f53ca04276fb05054;hb=438813bcf327729f9dafc1a56c6cede550435e2e;hpb=76e68068f22a67c788f14a7c9404db7f7514da49 diff --git a/lib/whenfile.ml b/lib/whenfile.ml index 5f205fb..b109e66 100644 --- a/lib/whenfile.ml +++ b/lib/whenfile.ml @@ -20,19 +20,20 @@ open Whenexpr open Printf -(* The list of jobs in this file. *) -let jobs = ref [] +(* The state updated during parsing of the file. *) +let state = ref Whenstate.empty -let init () = jobs := [] +let init s = state := s let add_when_job _loc name e sh = let e = expr_of_ast _loc e in - let job = make_when_job _loc name e sh in - jobs := job :: !jobs + let job = { job_loc = _loc; job_name = name; + job_cond = When_job e; job_script = sh } in + state := Whenstate.add_job !state job let add_every_job _loc name e sh = - let job = make_every_job _loc name e sh in - jobs := job :: !jobs + let job = { job_loc = _loc; job_name = name; + job_cond = Every_job e; job_script = sh } in + state := Whenstate.add_job !state job -let get_jobs () = - List.rev !jobs +let get_state () = !state