|
@@ -80,55 +80,6 @@ type enum_type =
|
|
|
| IQuoteStatus
|
|
|
| IImportMode
|
|
|
|
|
|
-type obj_type =
|
|
|
- (* make_const *)
|
|
|
- | O__Const
|
|
|
- (* Expr *)
|
|
|
- | OImportExpr
|
|
|
- | OImportExpr_path
|
|
|
- | OTypePath
|
|
|
- | OMetadataEntry
|
|
|
- | OField
|
|
|
- | OTypeParamDecl
|
|
|
- | OFunction
|
|
|
- | OFunctionArg
|
|
|
- | OExprDef_fields
|
|
|
- | OVar
|
|
|
- | OCase
|
|
|
- | OCatch
|
|
|
- | OExpr
|
|
|
- (* Type *)
|
|
|
- | OMetaAccess
|
|
|
- | OTypeParameter
|
|
|
- | OClassType
|
|
|
- | OAbstractType
|
|
|
- | OAnonType
|
|
|
- | ODefType
|
|
|
- | OEnumType
|
|
|
- | OClassField
|
|
|
- | OAbstractType_binops
|
|
|
- | OAbstractType_unops
|
|
|
- | OAbstractType_from
|
|
|
- | OAbstractType_to
|
|
|
- | OEnumField
|
|
|
- | OClassType_superClass
|
|
|
- | OClassType_interfaces
|
|
|
- | OType_args
|
|
|
- | OTVar
|
|
|
- | OTVar_extra
|
|
|
- | OTFunc
|
|
|
- | OTFunc_args
|
|
|
- | OFieldAccess_c
|
|
|
- | OTypedExprDef
|
|
|
- | OTypedExprDef_fields
|
|
|
- | OTypedExprDef_cases
|
|
|
- | OTypedExprDef_catches
|
|
|
- | OJSGenApi
|
|
|
- | OContext_getPosInfos
|
|
|
- | OCompiler_getDisplayPos
|
|
|
- | ORef
|
|
|
-(* ---- ^^^^^ please exactly match the name of the typedef or use TypeName_field if it's a anonymous *)
|
|
|
-
|
|
|
(**
|
|
|
Our access to the interpreter from the macro api
|
|
|
**)
|
|
@@ -144,7 +95,7 @@ module type InterpApi = sig
|
|
|
|
|
|
val encode_array : value list -> value
|
|
|
val encode_string : string -> value
|
|
|
- val encode_obj : obj_type -> (string * value) list -> value
|
|
|
+ val encode_obj : (string * value) list -> value
|
|
|
val encode_lazy : (unit -> value) -> value
|
|
|
|
|
|
val vfun0 : (unit -> value) -> value
|
|
@@ -221,51 +172,6 @@ let enum_name = function
|
|
|
| IImportMode -> "ImportMode"
|
|
|
| IQuoteStatus -> "QuoteStatus"
|
|
|
|
|
|
-let proto_name = function
|
|
|
- | O__Const -> assert false
|
|
|
- | OImportExpr -> "ImportExpr", None
|
|
|
- | OImportExpr_path -> "ImportExpr", Some "path"
|
|
|
- | OTypePath -> "TypePath", None
|
|
|
- | OMetadataEntry -> "MetadataEntry", None
|
|
|
- | OField -> "Field", None
|
|
|
- | OTypeParamDecl -> "TypeParamDecl", None
|
|
|
- | OFunction -> "Function", None
|
|
|
- | OFunctionArg -> "FunctionArg", None
|
|
|
- | OExprDef_fields -> "ExprDef", Some "fields"
|
|
|
- | OVar -> "Var", None
|
|
|
- | OCase -> "Case", None
|
|
|
- | OCatch -> "Catch", None
|
|
|
- | OExpr -> "Expr", None
|
|
|
- | OMetaAccess -> "MetaAccess", None
|
|
|
- | OTypeParameter -> "TypeParameter", None
|
|
|
- | OClassType -> "ClassType", None
|
|
|
- | OAbstractType -> "AbstracType", None
|
|
|
- | OAnonType -> "AnonType", None
|
|
|
- | ODefType -> "DefType", None
|
|
|
- | OEnumType -> "EnumType", None
|
|
|
- | OClassField -> "ClassField", None
|
|
|
- | OAbstractType_binops -> "AbstractType", Some "binops"
|
|
|
- | OAbstractType_unops -> "AbstractType", Some "unops"
|
|
|
- | OAbstractType_from -> "AbstractType", Some "from"
|
|
|
- | OAbstractType_to -> "AbstractType", Some "to"
|
|
|
- | OEnumField -> "EnumField", None
|
|
|
- | OClassType_superClass -> "ClassType", Some "superClass"
|
|
|
- | OClassType_interfaces -> "ClassType", Some "interfaces"
|
|
|
- | OType_args -> "Type", Some "args"
|
|
|
- | OTVar -> "TVar", None
|
|
|
- | OTVar_extra -> "TVar", Some "extra"
|
|
|
- | OTFunc -> "TFunc", None
|
|
|
- | OTFunc_args -> "TFunc", Some "args"
|
|
|
- | OFieldAccess_c -> "FieldAccess", Some "c"
|
|
|
- | OTypedExprDef -> "TypedExprDef", None
|
|
|
- | OTypedExprDef_fields -> "TypedExprDef", Some "fields"
|
|
|
- | OTypedExprDef_cases -> "TypedExprDef", Some "cases"
|
|
|
- | OTypedExprDef_catches -> "TypedExprDef", Some "catches"
|
|
|
- | OJSGenApi -> "JSGenApi", None
|
|
|
- | OContext_getPosInfos -> "Context", Some "getPosInfos"
|
|
|
- | OCompiler_getDisplayPos -> "Compiler", Some "getDisplayPos"
|
|
|
- | ORef -> "Ref", None
|
|
|
-
|
|
|
let all_enums =
|
|
|
let last = IImportMode in
|
|
|
let rec loop i =
|
|
@@ -363,8 +269,8 @@ let encode_import (path,mode) =
|
|
|
| IAll -> 2,[]
|
|
|
in
|
|
|
let mode = encode_enum IImportMode tag pl in
|
|
|
- encode_obj OImportExpr [
|
|
|
- "path", encode_array (List.map (fun (name,p) -> encode_obj OImportExpr_path [ "pos", encode_pos p; "name", encode_string name]) path);
|
|
|
+ encode_obj [
|
|
|
+ "path", encode_array (List.map (fun (name,p) -> encode_obj [ "pos", encode_pos p; "name", encode_string name]) path);
|
|
|
"mode", mode
|
|
|
]
|
|
|
|
|
@@ -377,7 +283,7 @@ let rec encode_path (t,_) =
|
|
|
"name", encode_string t.tname;
|
|
|
"params", encode_array (List.map encode_tparam t.tparams);
|
|
|
] in
|
|
|
- encode_obj OTypePath (match t.tsub with
|
|
|
+ encode_obj (match t.tsub with
|
|
|
| None -> fields
|
|
|
| Some s -> ("sub", encode_string s) :: fields)
|
|
|
|
|
@@ -400,7 +306,7 @@ and encode_access a =
|
|
|
encode_enum ~pos:(Some (pos a)) IAccess tag []
|
|
|
|
|
|
and encode_meta_entry (m,ml,p) =
|
|
|
- encode_obj OMetadataEntry [
|
|
|
+ encode_obj [
|
|
|
"name", encode_string (Meta.to_string m);
|
|
|
"params", encode_array (List.map encode_expr ml);
|
|
|
"pos", encode_pos p;
|
|
@@ -415,7 +321,7 @@ and encode_field (f:class_field) =
|
|
|
| FFun f -> 1, [encode_fun f]
|
|
|
| FProp (get,set, t, e) -> 2, [encode_placed_name get; encode_placed_name set; null encode_ctype t; null encode_expr e]
|
|
|
in
|
|
|
- encode_obj OField [
|
|
|
+ encode_obj [
|
|
|
"name",encode_placed_name f.cff_name;
|
|
|
"name_pos", encode_pos (pos f.cff_name);
|
|
|
"doc", null encode_string f.cff_doc;
|
|
@@ -447,7 +353,7 @@ and encode_ctype t =
|
|
|
encode_enum ~pos:(Some (pos t)) ICType tag pl
|
|
|
|
|
|
and encode_tparam_decl tp =
|
|
|
- encode_obj OTypeParamDecl [
|
|
|
+ encode_obj [
|
|
|
"name", encode_placed_name tp.tp_name;
|
|
|
"name_pos", encode_pos (pos tp.tp_name);
|
|
|
"params", encode_array (List.map encode_tparam_decl tp.tp_params);
|
|
@@ -458,10 +364,10 @@ and encode_tparam_decl tp =
|
|
|
]
|
|
|
|
|
|
and encode_fun f =
|
|
|
- encode_obj OFunction [
|
|
|
+ encode_obj [
|
|
|
"params", encode_array (List.map encode_tparam_decl f.f_params);
|
|
|
"args", encode_array (List.map (fun (n,opt,m,t,e) ->
|
|
|
- encode_obj OFunctionArg [
|
|
|
+ encode_obj [
|
|
|
"name", encode_placed_name n;
|
|
|
"name_pos", encode_pos (pos n);
|
|
|
"opt", vbool opt;
|
|
@@ -498,7 +404,7 @@ and encode_expr e =
|
|
|
| EParenthesis e ->
|
|
|
4, [loop e]
|
|
|
| EObjectDecl fl ->
|
|
|
- 5, [encode_array (List.map (fun ((f,p,qs),e) -> encode_obj OExprDef_fields [
|
|
|
+ 5, [encode_array (List.map (fun ((f,p,qs),e) -> encode_obj [
|
|
|
"field",encode_string f;
|
|
|
"name_pos",encode_pos p;
|
|
|
"quotes",encode_enum IQuoteStatus (match qs with NoQuotes -> 0 | DoubleQuotes -> 1) [];
|
|
@@ -514,7 +420,7 @@ and encode_expr e =
|
|
|
9, [encode_unop op; vbool (match flag with Prefix -> false | Postfix -> true); loop e]
|
|
|
| EVars vl ->
|
|
|
10, [encode_array (List.map (fun (v,final,t,eo) ->
|
|
|
- encode_obj OVar [
|
|
|
+ encode_obj [
|
|
|
"name",encode_placed_name v;
|
|
|
"name_pos",encode_pos (pos v);
|
|
|
"isFinal",vbool final;
|
|
@@ -534,7 +440,7 @@ and encode_expr e =
|
|
|
15, [loop econd;loop e;vbool (match flag with NormalWhile -> true | DoWhile -> false)]
|
|
|
| ESwitch (e,cases,eopt) ->
|
|
|
16, [loop e;encode_array (List.map (fun (ecl,eg,e,p) ->
|
|
|
- encode_obj OCase [
|
|
|
+ encode_obj [
|
|
|
"values",encode_array (List.map loop ecl);
|
|
|
"guard",null loop eg;
|
|
|
"expr",null loop e;
|
|
@@ -543,7 +449,7 @@ and encode_expr e =
|
|
|
) cases);null (fun (e,_) -> encode_null_expr e) eopt]
|
|
|
| ETry (e,catches) ->
|
|
|
17, [loop e;encode_array (List.map (fun (v,t,e,p) ->
|
|
|
- encode_obj OCatch [
|
|
|
+ encode_obj [
|
|
|
"name",encode_placed_name v;
|
|
|
"name_pos",encode_pos (pos v);
|
|
|
"type",encode_ctype t;
|
|
@@ -574,7 +480,7 @@ and encode_expr e =
|
|
|
| EMeta (m,e) ->
|
|
|
28, [encode_meta_entry m;loop e]
|
|
|
in
|
|
|
- encode_obj OExpr [
|
|
|
+ encode_obj [
|
|
|
"pos", encode_pos p;
|
|
|
"expr", encode_enum IExpr tag pl;
|
|
|
]
|
|
@@ -584,7 +490,7 @@ and encode_expr e =
|
|
|
and encode_null_expr e =
|
|
|
match e with
|
|
|
| None ->
|
|
|
- encode_obj OExpr ["pos", vnull;"expr",vnull]
|
|
|
+ encode_obj ["pos", vnull;"expr",vnull]
|
|
|
| Some e ->
|
|
|
encode_expr e
|
|
|
|
|
@@ -890,7 +796,7 @@ let vopt f v = match v with
|
|
|
|
|
|
let encode_meta m set =
|
|
|
let meta = ref m in
|
|
|
- encode_obj OMetaAccess [
|
|
|
+ encode_obj [
|
|
|
"get", vfun0 (fun() ->
|
|
|
encode_meta_content (!meta)
|
|
|
);
|
|
@@ -919,9 +825,9 @@ let encode_meta m set =
|
|
|
);
|
|
|
]
|
|
|
|
|
|
-let rec encode_mtype ot t fields =
|
|
|
+let rec encode_mtype t fields =
|
|
|
let i = t_infos t in
|
|
|
- encode_obj ot ([
|
|
|
+ encode_obj ([
|
|
|
"__t", encode_tdecl t;
|
|
|
"pack", encode_array (List.map encode_string (fst i.mt_path));
|
|
|
"name", encode_string (snd i.mt_path);
|
|
@@ -934,10 +840,10 @@ let rec encode_mtype ot t fields =
|
|
|
] @ fields)
|
|
|
|
|
|
and encode_type_params tl =
|
|
|
- encode_array (List.map (fun (n,t) -> encode_obj OTypeParameter ["name",encode_string n;"t",encode_type t]) tl)
|
|
|
+ encode_array (List.map (fun (n,t) -> encode_obj ["name",encode_string n;"t",encode_type t]) tl)
|
|
|
|
|
|
and encode_tenum e =
|
|
|
- encode_mtype OEnumType (TEnumDecl e) [
|
|
|
+ encode_mtype (TEnumDecl e) [
|
|
|
"isExtern", vbool e.e_extern;
|
|
|
"exclude", vfun0 (fun() -> e.e_extern <- true; vnull);
|
|
|
"constructs", encode_string_map encode_efield e.e_constrs;
|
|
@@ -945,20 +851,20 @@ and encode_tenum e =
|
|
|
]
|
|
|
|
|
|
and encode_tabstract a =
|
|
|
- encode_mtype OAbstractType (TAbstractDecl a) [
|
|
|
+ encode_mtype (TAbstractDecl a) [
|
|
|
"type", encode_type a.a_this;
|
|
|
"impl", (match a.a_impl with None -> vnull | Some c -> encode_clref c);
|
|
|
- "binops", encode_array (List.map (fun (op,cf) -> encode_obj OAbstractType_binops [ "op",encode_binop op; "field",encode_cfield cf]) a.a_ops);
|
|
|
- "unops", encode_array (List.map (fun (op,postfix,cf) -> encode_obj OAbstractType_unops [ "op",encode_unop op; "isPostfix",vbool (match postfix with Postfix -> true | Prefix -> false); "field",encode_cfield cf]) a.a_unops);
|
|
|
- "from", encode_array ((List.map (fun t -> encode_obj OAbstractType_from [ "t",encode_type t; "field",vnull]) a.a_from) @ (List.map (fun (t,cf) -> encode_obj OAbstractType_from [ "t",encode_type t; "field",encode_cfield cf]) a.a_from_field));
|
|
|
- "to", encode_array ((List.map (fun t -> encode_obj OAbstractType_to [ "t",encode_type t; "field",vnull]) a.a_to) @ (List.map (fun (t,cf) -> encode_obj OAbstractType_to [ "t",encode_type t; "field",encode_cfield cf]) a.a_to_field));
|
|
|
+ "binops", encode_array (List.map (fun (op,cf) -> encode_obj [ "op",encode_binop op; "field",encode_cfield cf]) a.a_ops);
|
|
|
+ "unops", encode_array (List.map (fun (op,postfix,cf) -> encode_obj [ "op",encode_unop op; "isPostfix",vbool (match postfix with Postfix -> true | Prefix -> false); "field",encode_cfield cf]) a.a_unops);
|
|
|
+ "from", encode_array ((List.map (fun t -> encode_obj [ "t",encode_type t; "field",vnull]) a.a_from) @ (List.map (fun (t,cf) -> encode_obj [ "t",encode_type t; "field",encode_cfield cf]) a.a_from_field));
|
|
|
+ "to", encode_array ((List.map (fun t -> encode_obj [ "t",encode_type t; "field",vnull]) a.a_to) @ (List.map (fun (t,cf) -> encode_obj [ "t",encode_type t; "field",encode_cfield cf]) a.a_to_field));
|
|
|
"array", encode_array (List.map encode_cfield a.a_array);
|
|
|
"resolve", (match a.a_read with None -> vnull | Some cf -> encode_cfref cf);
|
|
|
"resolveWrite", (match a.a_write with None -> vnull | Some cf -> encode_cfref cf)
|
|
|
]
|
|
|
|
|
|
and encode_efield f =
|
|
|
- encode_obj OEnumField [
|
|
|
+ encode_obj [
|
|
|
"name", encode_string f.ef_name;
|
|
|
"type", encode_type f.ef_type;
|
|
|
"pos", encode_pos f.ef_pos;
|
|
@@ -970,7 +876,7 @@ and encode_efield f =
|
|
|
]
|
|
|
|
|
|
and encode_cfield f =
|
|
|
- encode_obj OClassField [
|
|
|
+ encode_obj [
|
|
|
"name", encode_string f.cf_name;
|
|
|
"type", encode_lazy_type f.cf_type;
|
|
|
"isPublic", vbool f.cf_public;
|
|
@@ -1034,7 +940,7 @@ and encode_class_kind k =
|
|
|
|
|
|
and encode_tclass c =
|
|
|
ignore(c.cl_build());
|
|
|
- encode_mtype OClassType (TClassDecl c) [
|
|
|
+ encode_mtype (TClassDecl c) [
|
|
|
"kind", encode_class_kind c.cl_kind;
|
|
|
"isExtern", vbool c.cl_extern;
|
|
|
"exclude", vfun0 (fun() -> c.cl_extern <- true; c.cl_init <- None; vnull);
|
|
@@ -1042,9 +948,9 @@ and encode_tclass c =
|
|
|
"isFinal", vbool c.cl_final;
|
|
|
"superClass", (match c.cl_super with
|
|
|
| None -> vnull
|
|
|
- | Some (c,pl) -> encode_obj OClassType_superClass ["t",encode_clref c;"params",encode_tparams pl]
|
|
|
+ | Some (c,pl) -> encode_obj ["t",encode_clref c;"params",encode_tparams pl]
|
|
|
);
|
|
|
- "interfaces", encode_array (List.map (fun (c,pl) -> encode_obj OClassType_interfaces ["t",encode_clref c;"params",encode_tparams pl]) c.cl_implements);
|
|
|
+ "interfaces", encode_array (List.map (fun (c,pl) -> encode_obj ["t",encode_clref c;"params",encode_tparams pl]) c.cl_implements);
|
|
|
"fields", encode_ref c.cl_ordered_fields (encode_and_map_array encode_cfield) (fun() -> "class fields");
|
|
|
"statics", encode_ref c.cl_ordered_statics (encode_and_map_array encode_cfield) (fun() -> "class fields");
|
|
|
"constructor", (match c.cl_constructor with None -> vnull | Some cf -> encode_cfref cf);
|
|
@@ -1053,14 +959,14 @@ and encode_tclass c =
|
|
|
]
|
|
|
|
|
|
and encode_ttype t =
|
|
|
- encode_mtype ODefType (TTypeDecl t) [
|
|
|
+ encode_mtype (TTypeDecl t) [
|
|
|
"isExtern", vbool false;
|
|
|
"exclude", vfun0 (fun() -> vnull);
|
|
|
"type", encode_type t.t_type;
|
|
|
]
|
|
|
|
|
|
and encode_tanon a =
|
|
|
- encode_obj OAnonType [
|
|
|
+ encode_obj [
|
|
|
"fields", encode_pmap_array encode_cfield a.a_fields;
|
|
|
"status", encode_anon_status !(a.a_status);
|
|
|
]
|
|
@@ -1107,7 +1013,7 @@ and encode_type t =
|
|
|
3 , [encode_ref t encode_ttype (fun() -> s_type_path t.t_path); encode_tparams pl]
|
|
|
| TFun (pl,ret) ->
|
|
|
let pl = List.map (fun (n,o,t) ->
|
|
|
- encode_obj OType_args [
|
|
|
+ encode_obj [
|
|
|
"name",encode_string n;
|
|
|
"opt",vbool o;
|
|
|
"t",encode_type t
|
|
@@ -1189,13 +1095,13 @@ and encode_tconst c =
|
|
|
|
|
|
and encode_tvar v =
|
|
|
let f_extra (pl,e,inline) =
|
|
|
- encode_obj OTVar_extra [
|
|
|
+ encode_obj [
|
|
|
"params",encode_type_params pl;
|
|
|
"expr",encode_texpr e;
|
|
|
"isInline",vbool inline;
|
|
|
]
|
|
|
in
|
|
|
- encode_obj OTVar [
|
|
|
+ encode_obj [
|
|
|
"id", vint v.v_id;
|
|
|
"name", encode_string v.v_name;
|
|
|
"t", encode_type v.v_type;
|
|
@@ -1215,9 +1121,9 @@ and encode_module_type mt =
|
|
|
encode_enum IModuleType tag pl
|
|
|
|
|
|
and encode_tfunc func =
|
|
|
- encode_obj OTFunc [
|
|
|
+ encode_obj [
|
|
|
"args",encode_array (List.map (fun (v,c) ->
|
|
|
- encode_obj OTFunc_args [
|
|
|
+ encode_obj [
|
|
|
"v",encode_tvar v;
|
|
|
"value",match c with None -> vnull | Some c -> encode_tconst c
|
|
|
]
|
|
@@ -1228,7 +1134,7 @@ and encode_tfunc func =
|
|
|
|
|
|
and encode_field_access fa =
|
|
|
let encode_instance c tl =
|
|
|
- encode_obj OFieldAccess_c [
|
|
|
+ encode_obj [
|
|
|
"c",encode_clref c;
|
|
|
"params",encode_tparams tl
|
|
|
]
|
|
@@ -1254,7 +1160,7 @@ and encode_texpr e =
|
|
|
| TTypeExpr mt -> 5,[encode_module_type mt]
|
|
|
| TParenthesis e1 -> 6,[loop e1]
|
|
|
| TObjectDecl fl -> 7, [encode_array (List.map (fun ((f,_,_),e) ->
|
|
|
- encode_obj OTypedExprDef_fields [
|
|
|
+ encode_obj [
|
|
|
"name",encode_string f;
|
|
|
"expr",loop e;
|
|
|
]) fl)]
|
|
@@ -1270,13 +1176,13 @@ and encode_texpr e =
|
|
|
| TWhile(econd,e1,flag) -> 17,[loop econd;loop e1;vbool (flag = NormalWhile)]
|
|
|
| TSwitch(e1,cases,edef) -> 18,[
|
|
|
loop e1;
|
|
|
- encode_array (List.map (fun (el,e) -> encode_obj OTypedExprDef_cases ["values",encode_texpr_list el;"expr",loop e]) cases);
|
|
|
+ encode_array (List.map (fun (el,e) -> encode_obj ["values",encode_texpr_list el;"expr",loop e]) cases);
|
|
|
vopt encode_texpr edef
|
|
|
]
|
|
|
| TTry(e1,catches) -> 19,[
|
|
|
loop e1;
|
|
|
encode_array (List.map (fun (v,e) ->
|
|
|
- encode_obj OTypedExprDef_catches [
|
|
|
+ encode_obj [
|
|
|
"v",encode_tvar v;
|
|
|
"expr",loop e
|
|
|
]) catches
|
|
@@ -1291,7 +1197,7 @@ and encode_texpr e =
|
|
|
| TEnumIndex e1 -> 27,[loop e1]
|
|
|
| TIdent s -> 28,[encode_string s]
|
|
|
in
|
|
|
- encode_obj OTypedExprDef [
|
|
|
+ encode_obj [
|
|
|
"pos", encode_pos e.epos;
|
|
|
"expr", encode_enum ITypedExpr tag pl;
|
|
|
"t", encode_type e.etype
|
|
@@ -1543,7 +1449,7 @@ let rec make_const e =
|
|
|
| TParenthesis e | TMeta(_,e) | TCast(e,None) ->
|
|
|
make_const e
|
|
|
| TObjectDecl el ->
|
|
|
- encode_obj O__Const (List.map (fun ((f,_,_),e) -> f, make_const e) el)
|
|
|
+ encode_obj (List.map (fun ((f,_,_),e) -> f, make_const e) el)
|
|
|
| TArrayDecl al ->
|
|
|
encode_array (List.map make_const al)
|
|
|
| _ ->
|
|
@@ -1693,7 +1599,7 @@ let macro_api ccom get_api =
|
|
|
let f = prepare_callback f 1 in
|
|
|
(get_api()).set_js_generator (fun js_ctx ->
|
|
|
let com = ccom() in
|
|
|
- let api = encode_obj OJSGenApi [
|
|
|
+ let api = encode_obj [
|
|
|
"outputFile", encode_string com.file;
|
|
|
"types", encode_array (List.map (fun t -> encode_type (type_of_module_type t)) com.types);
|
|
|
"main", (match com.main with None -> vnull | Some e -> encode_texpr e);
|
|
@@ -1743,7 +1649,7 @@ let macro_api ccom get_api =
|
|
|
);
|
|
|
"get_pos_infos", vfun1 (fun p ->
|
|
|
let p = decode_pos p in
|
|
|
- encode_obj OContext_getPosInfos ["min",vint p.Globals.pmin;"max",vint p.Globals.pmax;"file",encode_string p.Globals.pfile]
|
|
|
+ encode_obj ["min",vint p.Globals.pmin;"max",vint p.Globals.pmax;"file",encode_string p.Globals.pfile]
|
|
|
);
|
|
|
"make_position", vfun3 (fun min max file ->
|
|
|
encode_pos { Globals.pmin = decode_int min; Globals.pmax = decode_int max; Globals.pfile = decode_string file }
|
|
@@ -1914,7 +1820,7 @@ let macro_api ccom get_api =
|
|
|
if p = Globals.null_pos then
|
|
|
vnull
|
|
|
else
|
|
|
- encode_obj OCompiler_getDisplayPos ["file",encode_string p.Globals.pfile;"pos",vint p.Globals.pmin]
|
|
|
+ encode_obj ["file",encode_string p.Globals.pfile;"pos",vint p.Globals.pmin]
|
|
|
);
|
|
|
"pattern_locals", vfun2 (fun e t ->
|
|
|
let loc = (get_api()).get_pattern_locals (decode_expr e) (decode_type t) in
|
|
@@ -1973,18 +1879,18 @@ let macro_api ccom get_api =
|
|
|
let p = decode_pos p in
|
|
|
let l1,c1,l2,c2 = Lexer.get_pos_coords p in
|
|
|
let make_pos line character =
|
|
|
- encode_obj O__Const [
|
|
|
+ encode_obj [
|
|
|
"line",vint line;
|
|
|
"character",vint character;
|
|
|
]
|
|
|
in
|
|
|
let pos_start = make_pos l1 c1 in
|
|
|
let pos_end = make_pos l2 c2 in
|
|
|
- let range = encode_obj O__Const [
|
|
|
+ let range = encode_obj [
|
|
|
"start",pos_start;
|
|
|
"end",pos_end;
|
|
|
] in
|
|
|
- let location = encode_obj O__Const [
|
|
|
+ let location = encode_obj [
|
|
|
"file",encode_string p.Globals.pfile;
|
|
|
"range",range
|
|
|
] in
|