|
@@ -194,6 +194,7 @@ and expr_def =
|
|
|
| EDisplayNew of type_path
|
|
|
| ETernary of expr * expr * expr
|
|
|
| ECheckType of expr * complex_type
|
|
|
+ | EMeta of metadata_entry * expr
|
|
|
|
|
|
and expr = expr_def * pos
|
|
|
|
|
@@ -205,7 +206,8 @@ and type_param = {
|
|
|
|
|
|
and documentation = string option
|
|
|
|
|
|
-and metadata = (string * expr list * pos) list
|
|
|
+and metadata_entry = (string * expr list * pos)
|
|
|
+and metadata = metadata_entry list
|
|
|
|
|
|
and access =
|
|
|
| APublic
|
|
@@ -535,6 +537,7 @@ let map_expr loop (e,p) =
|
|
|
| EDisplayNew t -> EDisplayNew (tpath t)
|
|
|
| ETernary (e1,e2,e3) -> ETernary (loop e1,loop e2,loop e3)
|
|
|
| ECheckType (e,t) -> ECheckType (loop e, ctype t)
|
|
|
+ | EMeta (m,e) -> EMeta(m, loop e)
|
|
|
) in
|
|
|
(e,p)
|
|
|
|
|
@@ -622,64 +625,64 @@ let reify in_macro =
|
|
|
match t with
|
|
|
| CTPath { tpackage = []; tparams = []; tsub = None; tname = n } when n.[0] = '$' ->
|
|
|
to_string n p
|
|
|
- | CTPath t -> ct "TPath" [to_tpath t p]
|
|
|
- | CTFunction (args,ret) -> ct "TFunction" [to_array to_ctype args p; to_ctype ret p]
|
|
|
- | CTAnonymous fields -> ct "TAnonymous" [to_array to_cfield fields p]
|
|
|
- | CTParent t -> ct "TParent" [to_ctype t p]
|
|
|
- | CTExtend (t,fields) -> ct "TExtend" [to_tpath t p; to_array to_cfield fields p]
|
|
|
- | CTOptional t -> ct "TOptional" [to_ctype t p]
|
|
|
- and to_fun f p =
|
|
|
- let farg (n,o,t,e) p =
|
|
|
- let fields = [
|
|
|
- "name", to_string n p;
|
|
|
- "opt", to_bool o p;
|
|
|
- "type", to_opt to_ctype t p;
|
|
|
- ] in
|
|
|
- to_obj (match e with None -> fields | Some e -> fields @ ["value",to_expr e p]) p
|
|
|
- in
|
|
|
- let rec fparam t p =
|
|
|
- let fields = [
|
|
|
- "name", to_string t.tp_name p;
|
|
|
- "constraints", to_array to_ctype t.tp_constraints p;
|
|
|
- "params", to_array fparam t.tp_params p;
|
|
|
- ] in
|
|
|
- to_obj fields p
|
|
|
- in
|
|
|
- let fields = [
|
|
|
- ("args",to_array farg f.f_args p);
|
|
|
- ("ret",to_opt to_ctype f.f_type p);
|
|
|
- ("expr",to_opt to_expr f.f_expr p);
|
|
|
- ("params",to_array fparam f.f_params p);
|
|
|
- ] in
|
|
|
- to_obj fields p
|
|
|
- and to_cfield f p =
|
|
|
- let p = f.cff_pos in
|
|
|
- let to_access a p =
|
|
|
- let n = (match a with
|
|
|
+ | CTPath t -> ct "TPath" [to_tpath t p]
|
|
|
+ | CTFunction (args,ret) -> ct "TFunction" [to_array to_ctype args p; to_ctype ret p]
|
|
|
+ | CTAnonymous fields -> ct "TAnonymous" [to_array to_cfield fields p]
|
|
|
+ | CTParent t -> ct "TParent" [to_ctype t p]
|
|
|
+ | CTExtend (t,fields) -> ct "TExtend" [to_tpath t p; to_array to_cfield fields p]
|
|
|
+ | CTOptional t -> ct "TOptional" [to_ctype t p]
|
|
|
+ and to_fun f p =
|
|
|
+ let farg (n,o,t,e) p =
|
|
|
+ let fields = [
|
|
|
+ "name", to_string n p;
|
|
|
+ "opt", to_bool o p;
|
|
|
+ "type", to_opt to_ctype t p;
|
|
|
+ ] in
|
|
|
+ to_obj (match e with None -> fields | Some e -> fields @ ["value",to_expr e p]) p
|
|
|
+ in
|
|
|
+ let rec fparam t p =
|
|
|
+ let fields = [
|
|
|
+ "name", to_string t.tp_name p;
|
|
|
+ "constraints", to_array to_ctype t.tp_constraints p;
|
|
|
+ "params", to_array fparam t.tp_params p;
|
|
|
+ ] in
|
|
|
+ to_obj fields p
|
|
|
+ in
|
|
|
+ let fields = [
|
|
|
+ ("args",to_array farg f.f_args p);
|
|
|
+ ("ret",to_opt to_ctype f.f_type p);
|
|
|
+ ("expr",to_opt to_expr f.f_expr p);
|
|
|
+ ("params",to_array fparam f.f_params p);
|
|
|
+ ] in
|
|
|
+ to_obj fields p
|
|
|
+ and to_cfield f p =
|
|
|
+ let p = f.cff_pos in
|
|
|
+ let to_access a p =
|
|
|
+ let n = (match a with
|
|
|
| APublic -> "APublic"
|
|
|
| APrivate -> "APrivate"
|
|
|
| AStatic -> "AStatic"
|
|
|
| AOverride -> "AOverride"
|
|
|
| ADynamic -> "ADynamic"
|
|
|
| AInline -> "AInline"
|
|
|
- ) in
|
|
|
- mk_enum "Access" n [] p
|
|
|
- in
|
|
|
- let to_kind k =
|
|
|
- let n, vl = (match k with
|
|
|
+ ) in
|
|
|
+ mk_enum "Access" n [] p
|
|
|
+ in
|
|
|
+ let to_kind k =
|
|
|
+ let n, vl = (match k with
|
|
|
| FVar (ct,e) -> "FVar", [to_opt to_ctype ct p;to_opt to_expr e p]
|
|
|
| FFun f -> "FFun", [to_fun f p]
|
|
|
- | FProp (get,set,t,e) -> "FProp", [to_string get p; to_string set p; to_opt to_ctype t p; to_opt to_expr e p]
|
|
|
- ) in
|
|
|
- mk_enum "FieldType" n vl p
|
|
|
- in
|
|
|
- let fields = [
|
|
|
- Some ("name", to_string f.cff_name p);
|
|
|
- (match f.cff_doc with None -> None | Some s -> Some ("doc", to_string s p));
|
|
|
- (match f.cff_access with [] -> None | l -> Some ("access", to_array to_access l p));
|
|
|
- Some ("kind", to_kind f.cff_kind);
|
|
|
- Some ("pos", to_pos f.cff_pos);
|
|
|
- (match f.cff_meta with [] -> None | l -> Some ("meta", to_meta f.cff_meta p));
|
|
|
+ | FProp (get,set,t,e) -> "FProp", [to_string get p; to_string set p; to_opt to_ctype t p; to_opt to_expr e p]
|
|
|
+ ) in
|
|
|
+ mk_enum "FieldType" n vl p
|
|
|
+ in
|
|
|
+ let fields = [
|
|
|
+ Some ("name", to_string f.cff_name p);
|
|
|
+ (match f.cff_doc with None -> None | Some s -> Some ("doc", to_string s p));
|
|
|
+ (match f.cff_access with [] -> None | l -> Some ("access", to_array to_access l p));
|
|
|
+ Some ("kind", to_kind f.cff_kind);
|
|
|
+ Some ("pos", to_pos f.cff_pos);
|
|
|
+ (match f.cff_meta with [] -> None | l -> Some ("meta", to_meta f.cff_meta p));
|
|
|
] in
|
|
|
let fields = List.rev (List.fold_left (fun acc v -> match v with None -> acc | Some e -> e :: acc) [] fields) in
|
|
|
to_obj fields p
|
|
@@ -795,5 +798,7 @@ let reify in_macro =
|
|
|
expr "ETernary" [loop e1;loop e2;loop e3]
|
|
|
| ECheckType (e1,ct) ->
|
|
|
expr "ECheckType" [loop e1; to_ctype ct p]
|
|
|
+ | EMeta ((m,ml,p),e1) ->
|
|
|
+ expr "EMeta" [to_obj [("name",to_string m p);("params",to_expr_array ml p);("pos",to_pos p)] p;loop e1]
|
|
|
in
|
|
|
(fun e -> to_expr e (snd e)), to_ctype
|