-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathppx_eliom_utils.ml
More file actions
693 lines (594 loc) · 21 KB
/
Copy pathppx_eliom_utils.ml
File metadata and controls
693 lines (594 loc) · 21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
open Parsetree
open Ast_helper
module AM = Ast_mapper
module AC = Ast_convenience
(** Various misc functions *)
let flatmap f l = List.flatten @@ List.map f l
let get_extension = function
| {pexp_desc= Pexp_extension ({txt},_)} -> txt
| _ -> invalid_arg "Eliom ppx: Should be an extension."
let in_context cref c f x =
let old = !cref in
cref := c ;
let res = f x in
cref := old ;
res
let (%) f g x = f (g x)
let exp_add_attrs attr e =
{e with pexp_attributes = attr}
let eid {Location. txt ; loc } =
Exp.ident ~loc { loc ; txt = Longident.Lident txt }
let format_args = function
| [] -> AC.unit ()
| [e] -> e
| l -> Exp.tuple l
let pat_args = function
| [] -> AC.punit ()
| [p] -> p
| l -> Pat.tuple l
let override_file_name = ref None
(* We use a strong hash (MD5) of the file name.
We only keep the first 36 bit, which should be well enough: with
256 files, the likelihood of a collision is about one in two
millions.
These bits are encoded using an OCaml-compatible variant of Base
64, as the hash is used to generate OCaml identifiers. *)
let file_hash loc =
let file_name =
match !override_file_name with
| Some file_name ->
file_name
| None ->
loc.Location.loc_start.pos_fname
in
let s = Digest.string file_name in
let e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'" in
let o = Bytes.create 6 in
let g p = Char.code s.[p] in
for i = 0 to 5 do
let p = i * 6 / 8 in
let d = 10 - (i * 6) mod 8 in
Bytes.set o i e.[(g p lsl 8 + g (p + 1)) lsr d land 63]
done;
Bytes.to_string o
let id_file_hash loc =
let prefix = "__eliom__compilation_unit_id__" in
{Location. loc ; txt = prefix ^ file_hash loc}
(** [let __eliom__compilation_unit_id__HASH = "HASH"]
We hoist the file hash at the beginning of each eliom file.
This makes the generated javascript code smaller.
*)
let module_hash_declaration loc =
let id = Pat.var ~loc @@ id_file_hash loc in
Str.value ~loc Nonrecursive [Vb.mk ~loc id @@ AC.str @@ file_hash loc]
(** The first position in a file, if it exists.
We avoid {!Location.input_name}, as it's unreliable when reading multiple files.
*)
let file_position str = match str with
| { pstr_loc } :: _ -> Location.in_file @@ pstr_loc.loc_start.pos_fname
| [] -> Location.none
let lexing_position ~loc l =
[%expr
{ Lexing.pos_fname = [%e AC.str l.Lexing.pos_fname];
Lexing.pos_lnum = [%e AC.int @@ l.Lexing.pos_lnum];
Lexing.pos_bol = [%e AC.int @@ l.Lexing.pos_bol];
Lexing.pos_cnum = [%e AC.int @@ l.Lexing.pos_cnum]; }
] [@metaloc loc]
let position loc =
let start = loc.Location.loc_start in
let stop = loc.Location.loc_start in
Exp.tuple ~loc [ lexing_position ~loc start ; lexing_position ~loc stop ]
let is_annotation txt l =
List.exists (fun s -> txt = s || txt = "eliom."^s) l
(** Identifiers generation. *)
module Name = struct
let escaped_ident_fmt : _ format6 =
"_eliom_escaped_ident_%Ld"
let fragment_ident_fmt : _ format6 =
"_eliom_fragment_%s"
let injected_ident_fmt : _ format6 =
"_eliom_injected_ident_%6s%d"
(* Identifiers for the closure representing a fragment. *)
let fragment_num_count = ref 0
let fragment_num _loc =
incr fragment_num_count;
Printf.sprintf "%s%d" (file_hash _loc) !fragment_num_count
let fragment_ident id =
Printf.sprintf fragment_ident_fmt id
(* Globaly unique ident for escaped expression *)
(* It's used for type inference and as argument name for the
closure representing the surrounding fragment. *)
(* Inside a fragment, same ident share the global ident. *)
let escaped_idents = ref []
let reset_escaped_ident () = escaped_idents := []
let escaped_expr, escaped_ident =
let r = ref 0L in
let make () =
r := Int64.(add one) !r ;
Printf.sprintf escaped_ident_fmt !r
in
let for_expr loc = Location.mkloc (make ()) loc in
let for_id loc id =
let txt =
try List.assoc id !escaped_idents
with Not_found ->
let gen_id = make () in
escaped_idents := (id, gen_id) :: !escaped_idents;
gen_id
in {Location. txt ; loc }
in for_expr, for_id
let injected_expr, injected_ident, reset_injected_ident =
let injected_idents = ref [] in
let r = ref 0 in
let gen_ident loc =
let hash = file_hash loc in
incr r;
let s = Printf.sprintf injected_ident_fmt hash !r in
{Location. txt = s ; loc }
in
let gen_injected_ident loc (s:string) =
try List.assoc s !injected_idents
with Not_found ->
let gen_id = gen_ident loc in
injected_idents := (s, gen_id) :: !injected_idents;
gen_id
and reset () = injected_idents := [] in
gen_ident, gen_injected_ident, reset
end
(* WARNING: if you change this, also change inferred_type_prefix in
tools/eliomc.ml and ocamlbuild/ocamlbuild_eliom.ml *)
let inferred_type_prefix = "eliom_inferred_type_"
module Mli = struct
let type_file = ref None
let get_type_file () = match !type_file with
| None -> Filename.chop_extension !Location.input_name ^ ".type_mli"
| Some f -> f
let exists () = match !type_file with Some _ -> true | _ -> false
let suppress_underscore =
let rename =
let c = ref 0 in
fun s -> incr c; Printf.sprintf "an_%s_%d" s !c
and has_pfix =
let len = String.length inferred_type_prefix in
fun s ->
String.length s >= len &&
String.sub s 0 len = inferred_type_prefix
in
let typ mapper ty = match ty.ptyp_desc with
(* | Ptyp_constr (_, Ast.TyAny _, ty) *)
(* | Ptyp_constr (_, ty, Ast.TyAny _) -> ty *)
| Ptyp_var var when has_pfix var ->
mapper.AM.typ mapper
{ty with
ptyp_desc = Ptyp_var (rename var)
}
| _ -> AM.default_mapper.typ mapper ty in
let m = { AM.default_mapper with typ } in
m.AM.typ m
let is_injected_ident id =
try Scanf.sscanf id Name.injected_ident_fmt (fun _ _ -> true)
with Scanf.Scan_failure _ -> false
let is_escaped_ident id =
try Scanf.sscanf id Name.escaped_ident_fmt (fun _ -> true)
with Scanf.Scan_failure _ -> false
let is_fragment_ident id =
try Scanf.sscanf id Name.fragment_ident_fmt (fun _ -> true)
with Scanf.Scan_failure _ -> false
let get_injected_ident_info id =
Scanf.sscanf id Name.injected_ident_fmt (fun u n -> (u, n))
let get_fragment_type = function
| [%type: [%t? typ] Eliom_client_value.fragment ]
| [%type: [%t? typ] Eliom_client_value.t ] ->
Some typ
| _ -> None
let get_binding sig_item = match sig_item.psig_desc with
| Psig_value {
pval_name = {txt} ;
pval_type = [%type: [%t? typ] option ref ] } ->
if is_injected_ident txt || is_escaped_ident txt then
Some (txt, suppress_underscore typ)
else if is_fragment_ident txt then
match get_fragment_type typ with
| Some typ -> Some (txt, suppress_underscore typ)
| None -> None
else
None
| _ -> None
let load_file file =
try
let items =
Pparse.parse_interface ~tool_name:"eliom" Format.err_formatter file
in
let h = Hashtbl.create 17 in
let f item = match get_binding item with
| Some (s, typ) -> Hashtbl.add h s typ
| None -> ()
in
List.iter f items ;
h
with
| Sys_error s ->
Location.raise_errorf
~loc:(Location.in_file file)
"Eliom: Error while loading types: %s" s
let inferred_sig = lazy (load_file (get_type_file ()))
let find err {Location. txt ; loc } =
try Hashtbl.find (Lazy.force inferred_sig) txt with
| Not_found ->
Typ.extension ~loc @@ AM.extension_of_error @@ Location.errorf ~loc
"Error: Inferred type of %s not found. You need to regenerate %s."
err (get_type_file ())
let find_escaped_ident = find "escaped ident"
let find_injected_ident = find "injected ident"
let find_fragment = find "client value"
end
(** Context convenience module. *)
module Context = struct
type server = [ `Server | `Shared ]
type client = [ `Client | `Shared ]
let of_string = function
| "server" | "server.start"
| "eliom.server" | "eliom.server.start" -> `Server
| "shared" | "shared.start"
| "eliom.shared" | "eliom.shared.start" -> `Shared
| "client" | "client.start"
| "eliom.client" | "eliom.client.start" -> `Client
| _ -> invalid_arg "Eliom ppx: Not a context"
type escape_inject = [
| `Escaped_value of server
| `Injection of client
]
type t = [
| `Server (* [%%server ... ] *)
| `Client (* [%%client ... ] *)
| `Shared (* [%%shared ... ] *)
| `Fragment of server (* [%client ... ] *)
| `Escaped_value of server (* [%shared ~%( ... ) ] *)
| `Injection of client (* [%%client ~%( ... ) ] *)
]
end
let rec match_args = function
| [ ] -> ()
| "-orig-file-name" :: file_name :: args ->
override_file_name := Some file_name;
match_args args
| "-type" :: type_file :: args ->
Mli.type_file := Some type_file;
match_args args
| "-notype" :: args ->
Mli.type_file := None;
match_args args
| args -> Location.raise_errorf ~loc:Location.(in_file !input_name)
"Wrong arguments:@ %s" (String.concat " " args)
(** Signature of specific code of a preprocessor. *)
module type Pass = sig
(** How to handle "client", "shared" and "server" sections for top level structure items. *)
val shared_str: bool -> structure_item -> structure_item list
val server_str: bool -> structure_item -> structure_item list
val client_str: structure_item -> structure_item list
(** How to handle "client", "shared" and "server" sections for top level signature items. *)
val shared_sig: signature_item -> signature_item list
val client_sig: signature_item -> signature_item list
val server_sig: signature_item -> signature_item list
(** How to handle "[%client ...]" and "[%shared ...]" expr. *)
val fragment:
?typ:core_type -> context:Context.server ->
num:string -> id:string Location.loc ->
expression -> expression
(** How to handle escaped "~%ident" inside a fragment. *)
val escape_inject:
?ident:string -> context:Context.escape_inject ->
id:string Location.loc ->
expression -> expression
val prelude : loc -> structure
val postlude : loc -> structure
end
(** These functions try to guess if a given expression will lead to a fragment evaluation
This is not possible in general, this criteria is only syntactic
If the expression cannot have fragments, we don't need to use sections.
Consequently, this function should *never* return false positive.
*)
module Cannot_have_fragment = struct
let opt_forall p = function
| None -> true
| Some x -> p x
let vb_forall p l =
let p x = p x.pvb_expr in
List.for_all p l
let rec longident = function
| Longident.Lident _ -> true
| Longident.Ldot (x,_) -> longident x
| Longident.Lapply (_,_) -> false
let rec expression e = match e.pexp_desc with
| Pexp_ident _
| Pexp_constant _
| Pexp_function _
| Pexp_lazy _
| Pexp_fun _
-> true
| Pexp_newtype (_,e)
| Pexp_assert e
| Pexp_field (e,_)
| Pexp_constraint (e,_)
| Pexp_coerce (e,_,_)
| Pexp_poly (e,_)
| Pexp_try (e,_) -> expression e
| Pexp_ifthenelse (b,e1,e2) ->
expression b && expression e1 && opt_forall expression e2
| Pexp_sequence (e1,e2)
| Pexp_setfield (e1,_,e2) -> expression e1 && expression e2
| Pexp_array l
| Pexp_tuple l -> List.for_all expression l
| Pexp_record (l,e) ->
let p x = expression @@ snd x in
opt_forall expression e && List.for_all p l
| Pexp_construct (_,e)
| Pexp_variant (_,e) -> opt_forall expression e
| Pexp_let (_,l,e) -> vb_forall expression l && expression e
| Pexp_open (_,x,e) -> longident x.txt && expression e
| Pexp_letmodule (_,me,e) -> module_expr me && expression e
(* We could be more precise on those constructs *)
| Pexp_object _
| Pexp_while _
| Pexp_for _
| Pexp_match _
| Pexp_pack _
-> false
(* We can't say more using syntactic information. *)
| Pexp_extension _
| Pexp_send _
| Pexp_new _
| Pexp_setinstvar _
| Pexp_override _
| Pexp_apply _
| _
-> false
and module_expr x = match x.pmod_desc with
| Pmod_ident l -> longident l.txt
| Pmod_functor _ -> true
| Pmod_unpack e -> expression e
| Pmod_constraint (e,_) -> module_expr e
| Pmod_structure l -> List.for_all structure_item l
| Pmod_apply _
| _
-> false
and module_binding m = module_expr m.pmb_expr
and structure_item x = match x.pstr_desc with
| Pstr_type _
| Pstr_typext _
| Pstr_exception _
| Pstr_modtype _
| Pstr_class _
| Pstr_class_type _
-> true
| Pstr_eval (e,_) -> expression e
| Pstr_value (_,vb) -> vb_forall expression vb
| Pstr_primitive _ -> true
| Pstr_module mb -> module_binding mb
| Pstr_recmodule mbl -> List.for_all module_binding mbl
| Pstr_open x -> longident x.popen_lid.txt
| Pstr_include x -> module_expr x.pincl_mod
| _ -> false
end
(**
Replace shared expression by the equivalent pair.
[ [%share
let x = ... %s ... in
[%client ... %x ... ]
] ]
≡
[ let x = ... s ... in
[%client ... %x ... ]
,
[%client
let x = ... %s ... in
... x ...
]
]
*)
module Shared = struct
let server_expr mapper expr =
match expr with
| [%expr [%client [%e? _ ]]] -> expr
| [%expr ~% [%e? injection_expr ]] -> injection_expr
| _ -> AM.default_mapper.expr mapper expr
let server = {AM.default_mapper with expr = server_expr}
let client_expr context mapper expr =
match expr with
| [%expr [%client [%e? fragment_expr ]]] ->
in_context context `Fragment
(mapper.AM.expr mapper) fragment_expr
| [%expr ~% [%e? injection_expr ]] ->
begin match !context with
| `Top -> expr
| `Fragment -> injection_expr
end
| _ -> AM.default_mapper.expr mapper expr
let client = {AM.default_mapper with expr = client_expr (ref `Top)}
let expr loc expr =
let server_expr = server.AM.expr server expr in
let client_expr = client.AM.expr client expr in
[%expr
Eliom_shared.Value.create
[%e server_expr]
[%client [%e client_expr]]
] [@metaloc loc]
end
module Make (Pass : Pass) = struct
let eliom_expr (context : Context.t ref) mapper expr =
let loc = expr.pexp_loc in
let attr = expr.pexp_attributes in
match expr, !context with
| {pexp_desc = Pexp_extension ({txt},_)},
`Client
when is_annotation txt ["client"; "shared"] ->
let side = get_extension expr in
Exp.extension @@ AM.extension_of_error @@ Location.errorf ~loc
"The syntax [%%%s ...] is not allowed inside client code."
side
| {pexp_desc = Pexp_extension ({txt},_)}
, (`Fragment _ | `Escaped_value _ | `Injection _)
when is_annotation txt ["client"; "shared"] ->
let side = get_extension expr in
Exp.extension @@ AM.extension_of_error @@ Location.errorf ~loc
"The syntax [%%%s ...] can not be nested."
side
(* [%shared ... ] *)
| {pexp_desc = Pexp_extension ({txt},PStr [{pstr_desc = Pstr_eval (side_val,attr')}])},
(`Server | `Shared)
when is_annotation txt ["shared"] ->
let e = Shared.expr loc side_val in
mapper.AM.expr mapper @@ exp_add_attrs (attr@attr') e
(* [%client ... ] *)
| {pexp_desc = Pexp_extension ({txt},PStr [{pstr_desc = Pstr_eval (side_val,attr)}])},
(`Server | `Shared as c)
when is_annotation txt ["client"] ->
Name.reset_escaped_ident () ;
let side_val, typ = match side_val with
| [%expr ([%e? cval]:[%t? typ]) ] -> (cval, Some typ)
| _ -> (side_val, None)
in
let num = Name.fragment_num side_val.pexp_loc in
let id = Location.mkloc (Name.fragment_ident num) side_val.pexp_loc in
in_context context (`Fragment c)
(Pass.fragment ?typ ~context:c ~num ~id % mapper.AM.expr mapper)
(exp_add_attrs attr side_val)
(* ~%( ... ) ] *)
| [%expr ~% [%e? inj ]], _ ->
let ident = match inj.pexp_desc with
| Pexp_ident i -> Some (String.concat "_" @@ Longident.flatten i.txt)
| _ -> None
in
begin match !context with
| `Client | `Shared as c ->
let id = match ident with
| Some id -> Name.injected_ident loc id
| None -> Name.injected_expr loc
in
let new_context = `Injection c in
in_context context new_context
(Pass.escape_inject ?ident ~context:new_context ~id %
mapper.AM.expr mapper)
inj
| `Fragment c ->
let id = match ident with
| None -> Name.escaped_expr loc
| Some id -> Name.escaped_ident loc id
in
let new_context = `Escaped_value c in
in_context context new_context
(Pass.escape_inject ?ident ~context:new_context ~id %
mapper.AM.expr mapper)
inj
| `Server ->
Location.raise_errorf ~loc
"The syntax ~%% ... is not allowed inside server code."
| `Escaped_value _ | `Injection _ ->
Location.raise_errorf ~loc
"The syntax ~%% ... can not be nested."
end
| _ -> AM.default_mapper.expr mapper expr
let structure_item mapper str =
let loc = str.pstr_loc in
match str.pstr_desc with
| Pstr_extension (({txt=("server"|"shared"|"client")}, _), _) ->
Location.raise_errorf ~loc
"Sections are only allowed at toplevel."
| _ -> AM.default_mapper.structure_item mapper str
let signature_item mapper sig_ =
let loc = sig_.psig_loc in
match sig_.psig_desc with
| Psig_extension (({txt=("server"|"shared"|"client")}, _), _) ->
Location.raise_errorf ~loc "Sections are only allowed at toplevel."
| _ -> AM.default_mapper.signature_item mapper sig_
let eliom_mapper context =
let context = ref (context :> Context.t) in
{ Ast_mapper.default_mapper
with
Ast_mapper.
expr = eliom_expr context ;
(* Reject sections not at toplevel. *)
structure_item ;
signature_item ;
}
(** Toplevel translation *)
(** Switch the current context when encountering [%%server] (resp. shared, client)
annotations. Call the eliom mapper and [Pass.server_str] (resp ..) on each
structure item.
*)
let dispatch_str context _mapper stri =
(* We must do this before any transformation on the structure. *)
let no_fragment = Cannot_have_fragment.structure_item stri in
let f = match context with
| `Server -> Pass.server_str no_fragment
| `Shared -> Pass.shared_str no_fragment
| `Client -> Pass.client_str
in
let m = eliom_mapper context in
f @@ m.AM.structure_item m stri
let dispatch_sig context _mapper sigi =
let f = match context with
| `Server -> Pass.server_sig
| `Shared -> Pass.shared_sig
| `Client -> Pass.client_sig
in
let m = eliom_mapper context in
f @@ m.AM.signature_item m sigi
let toplevel_structure context mapper structs =
let f pstr =
let loc = pstr.pstr_loc
and maybe_reset_injected_idents = function
| `Client | `Shared ->
Name.reset_injected_ident ();
| _ ->
()
in
match pstr.pstr_desc with
| Pstr_extension (({txt}, PStr strs), _)
when is_annotation txt ["shared.start";
"client.start";
"server.start"] ->
if strs <> [] then
[ Str.extension ~loc @@ AM.extension_of_error @@ Location.errorf ~loc
"The %%%%%s extension doesn't accept arguments." txt ]
else (
maybe_reset_injected_idents !context ;
context := Context.of_string txt ;
[]
)
| Pstr_extension (({txt}, PStr strs), _)
when is_annotation txt ["shared"; "client" ;"server"] ->
let c = Context.of_string txt in
let l = flatmap (dispatch_str c mapper) strs in
maybe_reset_injected_idents c ; l
| _ ->
dispatch_str !context mapper pstr
in
let loc = {(file_position structs) with loc_ghost = true} in
module_hash_declaration loc ::
Pass.prelude loc @
flatmap f structs @
Pass.postlude loc
let toplevel_signature context mapper sigs =
let f psig =
let loc = psig.psig_loc in
match psig.psig_desc with
| Psig_extension (({txt}, PStr strs), _)
when is_annotation txt ["shared.start"; "client.start" ;"server.start"] ->
if strs <> [] then
[ Sig.extension ~loc @@ AM.extension_of_error @@ Location.errorf ~loc
"The %%%%%s extension doesn't accept arguments." txt ]
else ( context := Context.of_string txt ; [] )
| _ ->
dispatch_sig !context mapper psig
in
flatmap f sigs
let mapper args =
let () = match_args args in
let c = ref `Server in
{AM.default_mapper
with
structure = toplevel_structure c ;
signature = toplevel_signature c ;
}
end