Skip to content

Commit

Permalink
Revert "Move global_metadata to common context"
Browse files Browse the repository at this point in the history
This reverts commit 319e074.
  • Loading branch information
kLabz committed Oct 4, 2023
1 parent d9884b5 commit ec91ada
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/context/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ type context = {
mutable user_metas : (string, Meta.user_meta) Hashtbl.t;
mutable get_macros : unit -> context option;
(* typing state *)
mutable global_metadata : (string list * metadata_entry * (bool * bool * bool)) list;
shared : shared_context;
display_information : display_information;
file_lookup_cache : (string,string option) lookup;
Expand Down Expand Up @@ -830,7 +829,6 @@ let create compilation_step cs version args =
file = "";
types = [];
callbacks = new compiler_callbacks;
global_metadata = [];
modules = [];
module_lut = new hashtbl_lookup;
module_nonexistent_lut = new hashtbl_lookup;
Expand Down
1 change: 1 addition & 0 deletions src/context/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type typer_globals = {
mutable macros : ((unit -> unit) * typer) option;
mutable std : module_def;
type_patches : (path, (string * bool, type_patch) Hashtbl.t * type_patch) Hashtbl.t;
mutable global_metadata : (string list * metadata_entry * (bool * bool * bool)) list;
mutable module_check_policies : (string list * module_check_policy list * bool) list;
mutable global_using : (tclass * pos) list;
(* Indicates that Typer.create() finished building this instance *)
Expand Down
16 changes: 2 additions & 14 deletions src/typing/macroContext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ let typing_timer ctx need_type f =
raise e

let make_macro_com_api com p =
let parse_metadata s p =
try
match ParserEntry.parse_string Grammar.parse_meta com.defines s null_pos raise_typing_error false with
| ParseSuccess(meta,_,_) -> meta
| ParseError(_,_,_) -> raise_typing_error "Malformed metadata string" p
with _ ->
raise_typing_error "Malformed metadata string" p
in
{
MacroApi.pos = p;
get_com = (fun () -> com);
Expand Down Expand Up @@ -286,11 +278,7 @@ let make_macro_com_api com p =
Interp.exc_string "unsupported"
);
add_global_metadata = (fun s1 s2 config p ->
let meta = parse_metadata s2 p in
List.iter (fun (m,el,_) ->
let m = (m,el,p) in
com.global_metadata <- (ExtString.String.nsplit s1 ".",m,config) :: com.global_metadata;
) meta;
Interp.exc_string "unsupported"
);
add_module_check_policy = (fun sl il b i ->
Interp.exc_string "unsupported"
Expand Down Expand Up @@ -549,7 +537,7 @@ let make_macro_api ctx p =
let meta = parse_metadata s2 p in
List.iter (fun (m,el,_) ->
let m = (m,el,p) in
ctx.com.global_metadata <- (ExtString.String.nsplit s1 ".",m,config) :: ctx.com.global_metadata;
ctx.g.global_metadata <- (ExtString.String.nsplit s1 ".",m,config) :: ctx.g.global_metadata;
) meta;
);
MacroApi.add_module_check_policy = (fun sl il b i ->
Expand Down
2 changes: 1 addition & 1 deletion src/typing/typeloadCheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ let check_global_metadata ctx meta f_add mpath tpath so =
List.iter (fun (sl2,m,(recursive,to_types,to_fields)) ->
let add = ((field_mode && to_fields) || (not field_mode && to_types)) && (match_path recursive sl1 sl2) in
if add then f_add m
) ctx.com.global_metadata;
) ctx.g.global_metadata;
if ctx.is_display_file then delay ctx PCheckConstraint (fun () -> DisplayEmitter.check_display_metadata ctx meta)

let check_module_types ctx m p t =
Expand Down
1 change: 1 addition & 0 deletions src/typing/typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,7 @@ let create com =
core_api = None;
macros = None;
type_patches = Hashtbl.create 0;
global_metadata = [];
module_check_policies = [];
delayed = [];
debug_delayed = [];
Expand Down

0 comments on commit ec91ada

Please sign in to comment.