From fd13bdc59c3946bb2f7180c64363456d2208d426 Mon Sep 17 00:00:00 2001 From: Torben Ewert Date: Sun, 31 May 2026 12:35:03 +0200 Subject: [PATCH] chore: remove leftover state of use statements --- lib/pinc_backend/Interpreter.ml | 14 +++----------- lib/pinc_backend/State.ml | 18 ++++-------------- lib/pinc_backend/Types.ml | 19 ++++--------------- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/lib/pinc_backend/Interpreter.ml b/lib/pinc_backend/Interpreter.ml index ad67658..660b490 100644 --- a/lib/pinc_backend/Interpreter.ml +++ b/lib/pinc_backend/Interpreter.ml @@ -63,12 +63,11 @@ let rec get_uppercase_identifier_typ ~state ident = | None -> let s = eval_expression - ~state:{ state with environment = { state.environment with scope = [] } } + ~state:{ state with environment = { scope = [] } } declaration_body in let bindings = s |> State.get_bindings in - let includes = s |> State.get_used_values in - let library = Type_Library.make ~bindings ~includes in + let library = Type_Library.make ~bindings in add_library ~library ~ident; (state, Some (Definition_Library library))) @@ -158,14 +157,7 @@ and eval_expression ~state expression = | Ast.FunctionCall { function_definition; arguments } -> eval_function_call ~state ~arguments function_definition | Ast.UppercaseIdentifierExpression id -> - let state, typ = - state - |> State.get_used_values - |> StringMap.find_opt id - |> Option.fold - ~some:(fun l -> (state, Some (Definition_Library l))) - ~none:(get_uppercase_identifier_typ ~state id) - in + let state, typ = get_uppercase_identifier_typ ~state id in let output = { value_desc = DefinitionInfo (id, typ, `NotNegated); diff --git a/lib/pinc_backend/State.ml b/lib/pinc_backend/State.ml index 272c2b3..ef25458 100644 --- a/lib/pinc_backend/State.ml +++ b/lib/pinc_backend/State.ml @@ -14,7 +14,7 @@ let make { declarations; output = { value_desc = Null; value_loc = Pinc_Diagnostics.Location.none }; - environment = { scope = []; use_scope = StringMap.empty }; + environment = { scope = [] }; tag_data_provider; root_tag_data_provider; tag_meta_provider; @@ -28,10 +28,7 @@ let make ;; let add_scope t = - { - t with - environment = { t.environment with scope = StringMap.empty :: t.environment.scope }; - } + { t with environment = { scope = StringMap.empty :: t.environment.scope } } ;; let remove_scope t = @@ -41,7 +38,7 @@ let remove_scope t = | [ hd ] -> [ hd ] | _hd :: tl -> tl in - { t with environment = { t.environment with scope = new_scope } } + { t with environment = { scope = new_scope } } ;; let add_value_to_scope ~ident ~value ~is_optional ~is_mutable t = @@ -51,13 +48,7 @@ let add_value_to_scope ~ident ~value ~is_optional ~is_mutable t = | scope :: rest -> StringMap.add ident { is_mutable; is_optional; value } scope :: rest in - let environment = { t.environment with scope = update_scope t } in - { t with environment } -;; - -let add_value_to_use_scope ~ident ~value t = - let use_scope = StringMap.add ident value t.environment.use_scope in - let environment = { t.environment with use_scope } in + let environment = { scope = update_scope t } in { t with environment } ;; @@ -121,7 +112,6 @@ let get_value_from_scope ~ident t = let get_output t = t.output let add_output ~output t = { t with output } let get_bindings t = t.environment.scope |> List.hd -let get_used_values t = t.environment.use_scope let add_tag_meta ~meta key t = match meta with diff --git a/lib/pinc_backend/Types.ml b/lib/pinc_backend/Types.ml index 47e22a9..2b3c6d4 100644 --- a/lib/pinc_backend/Types.ml +++ b/lib/pinc_backend/Types.ml @@ -54,10 +54,7 @@ and Type_State : sig mode : [ `Portal_Collection | `Portal_Render ]; } - and environment = { - mutable scope : binding StringMap.t list; - mutable use_scope : Type_Library.t StringMap.t; - } + and environment = { mutable scope : binding StringMap.t list } and binding = { is_mutable : bool; @@ -70,22 +67,15 @@ end = and Type_Library : sig type t - val make : bindings:Type_State.binding StringMap.t -> includes:t StringMap.t -> t + val make : bindings:Type_State.binding StringMap.t -> t val get_bindings : t -> Type_State.binding StringMap.t val get_binding : string -> t -> Type_State.binding option - val get_includes : t -> t StringMap.t - val get_include : string -> t -> t option end = struct - type t = { - bindings : Type_State.binding StringMap.t; - includes : t StringMap.t; - } + type t = { bindings : Type_State.binding StringMap.t } - let make ~bindings ~includes = { bindings; includes } + let make ~bindings = { bindings } let get_bindings t = t.bindings let get_binding id t = t.bindings |> StringMap.find_opt id - let get_includes t = t.includes - let get_include id t = t.includes |> StringMap.find_opt id end and Type_Store : sig @@ -117,7 +107,6 @@ and Type_Tag : sig | `TemplatePlaceholder | `Errors of string list ] - [@@deriving show] type kind = | Tag_String -- 2.51.2