mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Name resolution
This commit is contained in:
parent
cf586c6b5e
commit
1e11f6c1d5
@ -32,6 +32,8 @@ module LabelMap : Map.S with type key = LabelName.t = Map.Make (LabelName)
|
||||
|
||||
module LabelSet : Set.S with type elt = LabelName.t = Set.Make (LabelName)
|
||||
|
||||
module StateName : Uid.Id with type info = Uid.MarkedString.info = Uid.Make (Uid.MarkedString) ()
|
||||
|
||||
(** Inside a scope, a definition can refer either to a scope def, or a subscope def *)
|
||||
module ScopeDef = struct
|
||||
type t =
|
||||
|
@ -32,6 +32,8 @@ module LabelMap : Map.S with type key = LabelName.t
|
||||
|
||||
module LabelSet : Set.S with type elt = LabelName.t
|
||||
|
||||
module StateName : Uid.Id with type info = Uid.MarkedString.info
|
||||
|
||||
(** Inside a scope, a definition can refer either to a scope def, or a subscope def *)
|
||||
module ScopeDef : sig
|
||||
type t =
|
||||
|
@ -52,6 +52,8 @@ type var_sig = {
|
||||
var_sig_typ : typ Pos.marked;
|
||||
var_sig_is_condition : bool;
|
||||
var_sig_io : Ast.scope_decl_context_io;
|
||||
var_sig_states_idmap : Desugared.Ast.StateName.t Desugared.Ast.IdentMap.t;
|
||||
var_sig_states_list : Desugared.Ast.StateName.t list;
|
||||
}
|
||||
|
||||
type context = {
|
||||
@ -262,6 +264,15 @@ let process_data_decl (scope : Scopelang.Ast.ScopeName.t) (ctxt : context)
|
||||
let scope_ctxt =
|
||||
{ scope_ctxt with var_idmap = Desugared.Ast.IdentMap.add name uid scope_ctxt.var_idmap }
|
||||
in
|
||||
let states_idmap, states_list =
|
||||
List.fold_right
|
||||
(fun state_id (states_idmap, states_list) ->
|
||||
let state_uid = Desugared.Ast.StateName.fresh state_id in
|
||||
( Desugared.Ast.IdentMap.add (Pos.unmark state_id) state_uid states_idmap,
|
||||
state_uid :: states_list ))
|
||||
decl.scope_decl_context_item_states
|
||||
(Desugared.Ast.IdentMap.empty, [])
|
||||
in
|
||||
{
|
||||
ctxt with
|
||||
scopes = Scopelang.Ast.ScopeMap.add scope scope_ctxt ctxt.scopes;
|
||||
@ -271,6 +282,8 @@ let process_data_decl (scope : Scopelang.Ast.ScopeName.t) (ctxt : context)
|
||||
var_sig_typ = data_typ;
|
||||
var_sig_is_condition = is_cond;
|
||||
var_sig_io = decl.scope_decl_context_item_attribute;
|
||||
var_sig_states_idmap = states_idmap;
|
||||
var_sig_states_list = states_list;
|
||||
}
|
||||
ctxt.var_typs;
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ type var_sig = {
|
||||
var_sig_typ : typ Pos.marked;
|
||||
var_sig_is_condition : bool;
|
||||
var_sig_io : Ast.scope_decl_context_io;
|
||||
var_sig_states_idmap : Desugared.Ast.StateName.t Desugared.Ast.IdentMap.t;
|
||||
var_sig_states_list : Desugared.Ast.StateName.t list;
|
||||
}
|
||||
|
||||
type context = {
|
||||
|
Loading…
Reference in New Issue
Block a user