summaryrefslogtreecommitdiff
path: root/il.fun
blob: bcf4f29358c7775c53376ed7900f649f59d478d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
functor IL(P: PARSER) = struct

  structure P = P
  structure PP = P.P

  datatype ctx = Ctx of {
    objs: P.objDef list,
    objsZI: P.objDef list,
    extSyms: P.nid list,
    globSyms: P.nid list,
    funcs: P.funcInfo list,
    strlits: int list
  }

  fun createCtx ({ ext, glob, objsZI, objs, funcs, strlits }) =
    Ctx { objs, objsZI, extSyms = ext, globSyms = glob, funcs, strlits }

  fun updateCtx (Ctx ctx) = fn z =>
  let
    fun from objs objsZI extSyms globSyms funcs strlits =
      { objs, objsZI, extSyms, globSyms, funcs, strlits }
    fun to f { objs, objsZI, extSyms, globSyms, funcs, strlits } =
      f objs objsZI extSyms globSyms funcs strlits
  in
    FRU.makeUpdate6 (from, from, to) ctx (fn (a, f) => z (a, Ctx o f))
  end

  fun register ctx (P.Objects revObjs) =
    updateCtx ctx u#objs (fn objs => List.revAppend (revObjs, objs)) %
    | register ctx (P.Definition _) = ctx

    (*
  type objDef = int * P.tkPos * ctype * cini * linkage
  type decl = P.tkPos * declClass * ctype * linkage 
  *)
end