## reconstruct.pkg
## (C) 2001 Lucent Technologies, Bell Labs
## author: Matthias Blume (blume@research.bell-labs.com)
# Compiled by:
#
src/app/makelib/portable-graph/portable-graph-stuff.libstipulate
package p= portable_graph; # portable_graph is from
src/app/makelib/portable-graph/portable-graph.pkgherein
package reconstruct_portable : api {
Lib;
Dictionary;
Symbol;
Syms;
Misc;
Graph = p::Graph;
Context = pgops::Context (Lib, Dictionary, Symbol, Syms, Graph, Misc);
reconstruct: ((Context -> List( Lib ) -> Graph), Int) -> Graph;
}
{
Lib = p::Varname;
Dictionary = p::Varname;
Symbol = p::Varname;
Syms = p::Varname;
Misc = (Int, List( p::Def ));
Graph = p::Graph;
Context = pgops::Context (Lib, Dictionary, Symbol, Syms, Graph, Misc);
fun reconstruct (gt, nlibs)
=
{ fun varname i
=
"v" + int::to_string i;
fun bind (r, (i, d))
=
{ v = varname i;
i' = i + 1;
d' = p::DEF { lhs => v, rhs => r } ! d;
((i', d'), v);
};
fun sgn m s
=
bind (p::SYM (p::SGN, s), m);
fun packagex m s
=
bind (p::SYM (p::PACKAGE, s), m);
fun generic_x m s
=
bind (p::SYM (p::GENERIC, s), m);
fun syms m sl
=
bind (p::SYMS sl, m);
fun imp m (l, ss)
=
bind (p::IMPORT { lib => l, syms => ss }, m);
fun com m (s, e, ss, n)
=
bind (p::COMPILE { src => (s, n), env => e, syms => ss }, m);
fun fil m (e, ss)
=
bind (p::FILTER { env => e, syms => ss }, m);
fun mer m el
=
bind (p::MERGE el, m);
imports = list::from_fn (nlibs, varname);
fun expression (i, d) e
=
p::GRAPH { imports, defs => reverse d, export => e };
gt { ops => { sgn,
packagex,
generic_x,
expression,
syms,
imp,
com,
fil,
mer
},
misc => (nlibs, [])
}
imports;
};
};
end;