Skip to content

Commit 0ad37db

Browse files
committed
cleanup
1 parent 92eea24 commit 0ad37db

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

src/builtin.elpi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,8 @@ bindings (node L V D R _) X X1 :-
12831283

12841284
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12851285

1286+
% Fast maps only work ground terms but do not perform occur check
1287+
12861288
kind std.fmap type -> type -> type.
12871289
type std.fmap std.fmap.private.map K V -> (func K, K -> cmp) -> std.fmap K V.
12881290

@@ -1531,6 +1533,8 @@ elements (node L E R _) Acc X :-
15311533

15321534
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15331535

1536+
% Fast sets only work ground terms but do not perform occur check
1537+
15341538
kind std.fset type -> type.
15351539
type std.fset std.fset.private.set E -> (func E, E -> cmp) -> std.fset E.
15361540

src/compiler/compiler.ml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,12 @@ module CustomFunctorCompilation = struct
749749

750750
let scope_singlequote ~loc state x =
751751
match State.get singlequote state with
752-
| None -> ScopedTerm.(App(ScopedTerm.mk_global_const x ~loc,[]))
753-
| Some (language,f) -> ScopedTerm.unlock @@ ScopedTerm.of_simple_term_loc @@ f ~language state loc (F.show x)
752+
| None -> ScopedTerm.mkGlobalApp ~loc x []
753+
| Some (language,f) -> ScopedTerm.(unlock @@ of_simple_term_loc @@ f ~language state loc (F.show x))
754754
let scope_backtick ~loc state x =
755755
match State.get backtick state with
756-
| None -> ScopedTerm.(App(ScopedTerm.mk_global_const x ~loc,[]))
757-
| Some (language,f) -> ScopedTerm.unlock @@ ScopedTerm.of_simple_term_loc @@ f ~language state loc (F.show x)
756+
| None -> ScopedTerm.mkGlobalApp ~loc x []
757+
| Some (language,f) -> ScopedTerm.(unlock @@ of_simple_term_loc @@ f ~language state loc (F.show x))
758758
end
759759

760760
let namespace_separatorc = '.'
@@ -876,7 +876,7 @@ end = struct
876876
let { macros } = get_mtm state in
877877
match F.Map.find_opt c macros with
878878
| None -> error ~loc (Format.asprintf "@[<hv>Unknown macro %a.@ Known macros: %a@]" F.pp c (pplist F.pp ", ") (F.Map.bindings macros|>List.map fst))
879-
| Some (t, _) -> ScopedTerm.beta (ScopedTerm.clone_loc ~loc t) args
879+
| Some (t, _) -> ScopedTerm.(beta (clone_loc ~loc t) args)
880880

881881
(* would be better when symbols are resolved, in particular andf, nil and cons *)
882882

@@ -887,13 +887,13 @@ end = struct
887887
| Const c when is_discard c -> ScopedTerm.Discard
888888
| Const c when is_macro_name c ->
889889
scope_term_macro ~loc ~state c []
890-
| Const c when F.Set.mem c ctx -> ScopedTerm.(App(ScopedTerm.mk_bound_const ~lang:elpi_language c ~loc,[]))
890+
| Const c when F.Set.mem c ctx -> ScopedTerm.mkBoundApp ~lang:elpi_language ~loc c []
891891
| Const c ->
892-
if is_uvar_name c then ScopedTerm.UVar(ScopedTerm.mk_uvar c ~loc,[])
892+
if is_uvar_name c then ScopedTerm.mkUVar ~loc c []
893893
else if CustomFunctorCompilation.is_singlequote c then CustomFunctorCompilation.scope_singlequote ~loc state c
894894
else if CustomFunctorCompilation.is_backtick c then CustomFunctorCompilation.scope_backtick ~loc state c
895-
else if is_global c then ScopedTerm.(App(mk_global_const ~escape_ns:true (of_global c) ~loc,[]))
896-
else ScopedTerm.(App(mk_global_const ~loc c,[]))
895+
else if is_global c then ScopedTerm.mkGlobalApp ~escape_ns:true ~loc (of_global c) []
896+
else ScopedTerm.mkGlobalApp ~loc c []
897897
| App ({ it = App (f,l1) },l2) -> scope_term ~state ctx ~loc (App(f, l1 @ l2))
898898
| App ({ it = Parens f },l) -> scope_term ~state ctx ~loc (App(f, l))
899899
| App({ it = Const c }, [x]) when F.equal c F.spillf ->
@@ -914,10 +914,10 @@ end = struct
914914
scope_term_macro ~loc ~state c xs
915915
else
916916
let bound = F.Set.mem c ctx in
917-
if bound then ScopedTerm.App(ScopedTerm.mk_bound_const ~lang:elpi_language c ~loc:cloc, xs)
918-
else if is_uvar_name c then ScopedTerm.UVar(ScopedTerm.mk_uvar c ~loc:cloc,xs)
919-
else if is_global c then ScopedTerm.App(ScopedTerm.mk_global_const ~escape_ns:true (of_global c) ~loc:cloc,xs)
920-
else ScopedTerm.App(ScopedTerm.mk_global_const c ~loc:cloc, xs)
917+
if bound then ScopedTerm.mkBoundApp ~lang:elpi_language ~loc:cloc c xs
918+
else if is_uvar_name c then ScopedTerm.mkUVar ~loc:cloc c xs
919+
else if is_global c then ScopedTerm.mkGlobalApp ~escape_ns:true ~loc:cloc (of_global c) xs
920+
else ScopedTerm.mkGlobalApp ~loc:cloc c xs
921921
| Cast (t,ty) ->
922922
let t = scope_loc_term ~state ctx t in
923923
let ty = scope_loc_tye F.Set.empty (RecoverStructure.structure_type_expression ty.Ast.TypeExpression.tloc Ast.Structured.Relation valid_functional ty) in

src/compiler/compiler_data.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ module ScopedTerm = struct
916916

917917
let mk_w_ty_loc ?(ty = MutableOnce.make F.dummyname) ~scope name ~loc : 'a w_ty_loc =
918918
{ scope; name; ty; loc }
919-
let mk_global_const ?escape_ns ~loc name : const = mk_w_ty_loc ~scope:(Scope.mkGlobal ?escape_ns ()) name ~loc
919+
let mk_global_const ?ty ?escape_ns ~loc name : const = mk_w_ty_loc ?ty ~scope:(Scope.mkGlobal ?escape_ns ()) name ~loc
920920
let mk_bound_const ?ty ~lang name ~loc = mk_w_ty_loc ?ty ~scope:(Scope.Bound lang) name ~loc
921921
let mk_uvar ?ty name ~loc = mk_w_ty_loc ?ty ~scope:() name ~loc
922922
let mk_binder ?ty ~lang name ~loc = mk_w_ty_loc ?ty ~scope:lang ~loc name
@@ -944,6 +944,10 @@ module ScopedTerm = struct
944944
and t = { it : t_; loc : Loc.t; ty : TypeAssignment.t MutableOnce.t }
945945
[@@ deriving show]
946946

947+
let mkGlobalApp ?ty ?escape_ns ~loc f xs = App(mk_global_const ?ty ?escape_ns ~loc f,xs)
948+
let mkBoundApp ?ty ~lang ~loc f xs = App(mk_bound_const ?ty ~lang ~loc f,xs)
949+
let mkUVar ?ty ~loc f xs = UVar(mk_uvar ?ty ~loc f, xs)
950+
947951
let type_of { ty } : TypeAssignment.ty = assert(MutableOnce.is_set ty); TypeAssignment.deref ty
948952

949953
open Format

0 commit comments

Comments
 (0)