Skip to content

Commit 745c7eb

Browse files
committed
Support for splice and quote
1 parent 4cca46a commit 745c7eb

12 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/document/generator.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ module Make (Syntax : SYNTAX) = struct
479479
(Link.from_path (path :> Paths.Path.t))
480480
| Poly (polyvars, t) ->
481481
O.txt ("'" ^ String.concat ~sep:" '" polyvars ^ ". ") ++ type_expr t
482+
| Quote t -> O.span (O.txt "<[ " ++ O.box_hv (type_expr t) ++ O.txt " ]>")
483+
| Splice t -> O.span (O.txt "$" ++ type_expr ~needs_parentheses:true t)
482484
| Package pkg ->
483485
enclose ~l:"(" ~r:")"
484486
(O.keyword "module" ++ O.txt " "

src/loader/cmi.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ let mark_type ty =
317317
#endif
318318
| Tlink _ -> assert false
319319
#if defined OXCAML
320+
| Tquote typ -> loop visited typ
321+
| Tsplice typ -> loop visited typ
320322
| Tof_kind _ -> ()
321323
#endif
322324
in
@@ -580,6 +582,8 @@ let rec read_type_expr env typ =
580582
#endif
581583
| Tlink _ -> assert false
582584
#if defined OXCAML
585+
| Tquote typ -> Quote (read_type_expr env typ)
586+
| Tsplice typ -> Splice (read_type_expr env typ)
583587
| Tof_kind _ -> assert false
584588
#endif
585589
in

src/loader/cmti.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ let rec read_core_type env container ctyp =
195195
read_core_type env container t
196196
#endif
197197
#if defined OXCAML
198+
| Ttyp_quote typ -> Quote (read_core_type env container typ)
199+
| Ttyp_splice typ -> Splice (read_core_type env container typ)
198200
| Ttyp_call_pos -> Constr(Env.Path.read_type env.ident_env Predef.path_lexing_position, [])
199201
| Ttyp_of_kind _ -> assert false
200202
#endif

src/model/lang.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ and TypeExpr : sig
465465
| Object of TypeExpr.Object.t
466466
| Class of Path.ClassType.t * t list
467467
| Poly of string list * t
468+
| Quote of t
469+
| Splice of t
468470
| Package of TypeExpr.Package.t
469471
end =
470472
TypeExpr

src/model_desc/lang_desc.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,8 @@ and typeexpr_t =
668668
| Class (x1, x2) ->
669669
C ("Class", ((x1 :> Paths.Path.t), x2), Pair (path, List typeexpr_t))
670670
| Poly (x1, x2) -> C ("Poly", (x1, x2), Pair (List string, typeexpr_t))
671+
| Quote x -> C ("Quote", x, typeexpr_t)
672+
| Splice x -> C ("Splice", x, typeexpr_t)
671673
| Package x -> C ("Package", x, typeexpr_package))
672674

673675
(** {3 Compilation_unit} *)

src/xref2/compile.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,8 @@ and type_expression : Env.t -> Id.LabelParent.t -> _ -> _ =
948948
Class (`Resolved p, ts')
949949
| _ -> Class (path, ts'))
950950
| Poly (strs, t) -> Poly (strs, type_expression env parent t)
951+
| Quote t -> Quote (type_expression env parent t)
952+
| Splice t -> Splice (type_expression env parent t)
951953
| Package p -> Package (type_expression_package env parent p)
952954

953955
let compile ~filename env compilation_unit =

src/xref2/component.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ and TypeExpr : sig
129129
| Object of TypeExpr.Object.t
130130
| Class of Cpath.class_type * t list
131131
| Poly of string list * t
132+
| Quote of t
133+
| Splice of t
132134
| Package of TypeExpr.Package.t
133135
end =
134136
TypeExpr
@@ -1197,6 +1199,8 @@ module Fmt = struct
11971199
| Object x -> type_object c ppf x
11981200
| Class (x, y) -> type_class c ppf (x, y)
11991201
| Poly (_ss, _t) -> Format.fprintf ppf "(poly)"
1202+
| Quote t -> Format.fprintf ppf "(quote %a)" (type_expr c) t
1203+
| Splice t -> Format.fprintf ppf "(splice %a)" (type_expr c) t
12001204
| Package x -> type_package c ppf x
12011205

12021206
and resolved_module_path :
@@ -2340,6 +2344,8 @@ module Of_Lang = struct
23402344
Class
23412345
(class_type_path ident_map p, List.map (type_expression ident_map) ts)
23422346
| Object o -> Object (type_object ident_map o)
2347+
| Quote t -> Quote (type_expression ident_map t)
2348+
| Splice t -> Splice (type_expression ident_map t)
23432349
| Package p -> Package (type_package ident_map p)
23442350

23452351
and module_decl ident_map m =

src/xref2/component.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ and TypeExpr : sig
124124
| Object of TypeExpr.Object.t
125125
| Class of Cpath.class_type * t list
126126
| Poly of string list * t
127+
| Quote of t
128+
| Splice of t
127129
| Package of TypeExpr.Package.t
128130
end
129131

src/xref2/expand_tools.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ let rec type_expr map t =
6666
| Class (path, ts) -> Class (path, List.map (type_expr map) ts)
6767
| Poly (s, t) -> Poly (s, type_expr map t)
6868
| Package p -> Package (package map p)
69+
| Quote t -> Quote (type_expr map t)
70+
| Splice t -> Splice (type_expr map t)
6971

7072
and polymorphic_variant map pv =
7173
let open Lang.TypeExpr.Polymorphic_variant in

src/xref2/lang_of.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,8 @@ and type_expr map (parent : Identifier.LabelParent.t) (t : Component.TypeExpr.t)
10381038
| Class (p, ts) ->
10391039
Class (Path.class_type map p, List.map (type_expr map parent) ts)
10401040
| Poly (strs, t) -> Poly (strs, type_expr map parent t)
1041+
| Quote t -> Quote (type_expr map parent t)
1042+
| Splice t -> Splice (type_expr map parent t)
10411043
| Package p -> Package (type_expr_package map parent p)
10421044
with e ->
10431045
let bt = Printexc.get_backtrace () in

0 commit comments

Comments
 (0)