Open modules during scoping
We need to open Modules during scoping so that we can resolve consts given without a module name.
This commit is contained in:
parent
c99e29ef74
commit
3f0005dba1
2 changed files with 6 additions and 4 deletions
|
@ -1118,7 +1118,6 @@ let typing_const_dec cd =
|
|||
let program
|
||||
({ p_opened = opened; p_types = p_type_list;
|
||||
p_nodes = p_node_list; p_consts = p_consts_list } as p) =
|
||||
List.iter open_module opened;
|
||||
let typed_cd_list = List.map typing_const_dec p_consts_list in
|
||||
List.iter deftype p_type_list;
|
||||
let typed_node_list = List.map node p_node_list in
|
||||
|
|
|
@ -9,6 +9,7 @@ open Idents
|
|||
open Format
|
||||
open Printf
|
||||
open Static
|
||||
open Modules
|
||||
|
||||
module Error =
|
||||
struct
|
||||
|
@ -109,7 +110,10 @@ let rec static_exp_of_exp const_env e =
|
|||
if NamesEnv.mem n const_env then
|
||||
Svar (Name n)
|
||||
else
|
||||
raise Not_static
|
||||
(try
|
||||
let { qualid = q } = find_const (Name n) in
|
||||
Svar (Modname q)
|
||||
with Not_found -> raise Not_static)
|
||||
| Econst se -> se.se_desc
|
||||
| Eapp({ a_op = Earray_fill; a_params = [n] }, [e]) ->
|
||||
Sarray_power (static_exp_of_exp const_env e,
|
||||
|
@ -156,8 +160,6 @@ and translate_desc loc const_env env = function
|
|||
| Evar x ->
|
||||
if Rename.mem x env then (* defined var *)
|
||||
Heptagon.Evar (Rename.name loc env x)
|
||||
else if NamesEnv.mem x const_env then (* defined as const var *)
|
||||
Heptagon.Econst (mk_static_exp (Svar (Modules.longname x)))
|
||||
else (* undefined var *)
|
||||
Error.message loc (Error.Evar x)
|
||||
| Elast x -> Heptagon.Elast (Rename.name loc env x)
|
||||
|
@ -316,6 +318,7 @@ let translate_const_dec const_env cd =
|
|||
Heptagon.c_loc = cd.c_loc; }, build_cd const_env cd
|
||||
|
||||
let translate_program p =
|
||||
List.iter open_module p.p_opened;
|
||||
let p_consts, const_env =
|
||||
Misc.mapfold translate_const_dec NamesEnv.empty p.p_consts in
|
||||
{ Heptagon.p_modname = p.p_modname;
|
||||
|
|
Loading…
Reference in a new issue