staload Fix = "ats_fixity.sats"
staload Sym = "ats_symbol.sats"
staload SymEnv = "ats_symenv.sats"
staload "ats_dynexp1.sats"
staload "ats_staexp1.sats"
staload "ats_trans1_env.sats"
staload "ats_reference.sats"
staload _ = "ats_reference.dats"
staload _ = "ats_map_lin.dats"
staload _ = "ats_symenv.dats"
typedef sym_t = $Sym.symbol_t
typedef symenv_t (itm:t@ype) = $SymEnv.symenv_t itm
fn prerr_interror () = prerr "INTERNAL ERROR (ats_trans1_env)"
typedef e1xpenv = symenv_t (e1xp)
val the_e1xpenv = $SymEnv.symenv_make {e1xp} ()
implement
the_e1xpenv_add (opr, e1xp) = let
val ans = $SymEnv.symenv_remove_fst (the_e1xpenv, opr)
val () = begin
case+ ans of ~Some_vt _ => () | ~None_vt () => ()
end in
$SymEnv.symenv_insert_fst (the_e1xpenv, opr, e1xp)
end
implement
the_e1xpenv_find (id) = let
val ans = $SymEnv.symenv_search_all (the_e1xpenv, id)
in
case+ ans of
| Some_vt _ => (fold@ ans; ans)
| ~None_vt () => begin
$SymEnv.symenv_pervasive_search (the_e1xpenv, id)
end end
implement
the_e1xpenv_pervasive_add_topenv () = let
val m = $SymEnv.symenv_top_get (the_e1xpenv)
in
$SymEnv.symenv_pervasive_add (the_e1xpenv, m)
end
typedef fxtyenv = symenv_t (fxty_t)
val the_fxtyenv = $SymEnv.symenv_make {fxty_t} ()
implement
the_fxtyenv_add (opr, fxty) = let
val ans = $SymEnv.symenv_remove_fst (the_fxtyenv, opr)
val () =
case+ ans of ~Some_vt _ => () | ~None_vt () => ()
in
$SymEnv.symenv_insert_fst (the_fxtyenv, opr, fxty)
end
implement
the_fxtyenv_find (opr) = let
val ans = $SymEnv.symenv_search_all (the_fxtyenv, opr)
in
case+ ans of
| Some_vt _ => (fold@ ans; ans)
| ~None_vt () => begin
$SymEnv.symenv_pervasive_search (the_fxtyenv, opr)
end end
implement
the_fxtyenv_pervasive_add_topenv () = let
val m = $SymEnv.symenv_top_get (the_fxtyenv)
in
$SymEnv.symenv_pervasive_add (the_fxtyenv, m)
end
implement
atsopt_fxtyenv_print () = let
val r_m = $SymEnv.symenv_reftop_get the_fxtyenv
val kis = $SymEnv.symmap_reflist_get (r_m)
typedef ki = @(sym_t, fxty_t)
fun loop {n:nat} .<n>.
(kis: list_vt (ki, n)): void = begin case+ kis of
| ~list_vt_cons (ki, kis) => let
val (k, i) = ki; val () = begin
$Sym.print_symbol_code k; print " = "; $Fix.print_fxty i;
print_newline ()
end in
loop (kis)
end | ~list_vt_nil () => ()
end
in
loop kis
end
local
assume trans1_level_token = unit_v
val the_trans1_level : ref int = ref_make_elt<int> 0
in
implement trans1_level_get () = !the_trans1_level
implement
trans1_level_dec (pf | ) = let
prval unit_v () = pf in
!the_trans1_level := !the_trans1_level - 1
end
implement
trans1_level_inc () = let
val () = !the_trans1_level := !the_trans1_level + 1 in
(unit_v () | ())
end
end
implement
trans1_env_pop () = begin
$SymEnv.symenv_pop (the_e1xpenv);
$SymEnv.symenv_pop (the_fxtyenv);
end
implement
trans1_env_push () = begin
$SymEnv.symenv_push (the_e1xpenv);
$SymEnv.symenv_push (the_fxtyenv)
end
implement
trans1_env_localjoin () = begin
$SymEnv.symenv_localjoin (the_e1xpenv);
$SymEnv.symenv_localjoin (the_fxtyenv)
end
implement
trans1_env_save () = begin
$SymEnv.symenv_save (the_e1xpenv);
$SymEnv.symenv_save (the_fxtyenv)
end
implement
trans1_env_restore () = begin
$SymEnv.symenv_restore (the_e1xpenv);
$SymEnv.symenv_restore (the_fxtyenv)
end
staload HT = "ats_hashtbl.sats"
staload _ = "ats_hashtbl.dats"
local
typedef itm = @(int, d1eclst)
val SIZE_HINT = 7
val theHashTable = begin
$HT.hashtbl_str_make_hint (SIZE_HINT): $HT.hashtbl_t (string, itm)
end
in
implement
staload_file_insert (fullname, flag, d1cs) = let
val ans = $HT.hashtbl_insert (theHashTable, fullname, @(flag,d1cs))
in
case+ ans of
| ~Some_vt (d1c) => begin
prerr_interror ();
prerr ": [staload_file_insert] failed."; prerr_newline ();
exit {void} (1)
end | ~None_vt () => ()
end
implement
staload_file_search (fullname) =
$HT.hashtbl_search (theHashTable, fullname)
end