Fixed typing of const def

Like values, the typed version should be put in
the environment.
This commit is contained in:
Cédric Pasteur 2011-04-28 09:28:07 +02:00
parent ba1ff2c06d
commit bed729b448
3 changed files with 12 additions and 1 deletions

View file

@ -36,7 +36,7 @@ let print_full_qualname ff qn = _print_qualname ~full:true ff qn
let print_shortname ff {name = n} = print_name ff n
let rec print_static_exp ff se = match se.se_desc with
let rec print_static_exp_desc ff sed = match sed with
| Sint i -> fprintf ff "%d" i
| Sbool b -> fprintf ff "%b" b
| Sfloat f -> fprintf ff "%f" f
@ -60,6 +60,13 @@ let rec print_static_exp ff se = match se.se_desc with
print_record (print_couple print_qualname
print_static_exp """ = """) ff f_se_list
and print_static_exp ff se =
if !Compiler_options.full_type_info then
fprintf ff "(%a : %a)"
print_static_exp_desc se.se_desc print_type se.se_ty
else
fprintf ff "%a" print_static_exp_desc se.se_desc
and print_static_exp_tuple ff l =
fprintf ff "@[<2>%a@]" (print_list_r print_static_exp "("","")") l

View file

@ -166,6 +166,8 @@ let replace_value f v =
g_env.values <- QualEnv.add f v g_env.values
let replace_type f v =
g_env.types <- QualEnv.add f v g_env.types
let replace_const f v =
g_env.consts <- QualEnv.add f v g_env.consts
(** { 3 Find functions look in the global environement, nothing more } *)

View file

@ -1094,6 +1094,8 @@ let node ({ n_name = f; n_input = i_list; n_output = o_list;
let typing_const_dec cd =
let ty = check_type QualEnv.empty cd.c_type in
let se = expect_static_exp QualEnv.empty ty cd.c_value in
let const_def = { Signature.c_type = ty; Signature.c_value = se } in
Modules.replace_const cd.c_name const_def;
{ cd with c_value = se; c_type = ty }
let typing_typedec td =