mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-10 19:33:11 +00:00
Rename a bunch of functions to avoid a bunch of ambiguities.
Estimated hours taken: 0.2 Branches: main compiler/xml_documentation.m: Rename a bunch of functions to avoid a bunch of ambiguities.
This commit is contained in:
@@ -91,10 +91,8 @@ xml_documentation(ModuleInfo, !IO) :-
|
||||
SrcResult = ok(SrcStream),
|
||||
build_comments(SrcStream, comments(map.init), Comments, !IO),
|
||||
|
||||
%
|
||||
% XXX We should find the ":- module " declaration
|
||||
% and get the comment from there.
|
||||
%
|
||||
% XXX We should find the ":- module " declaration
|
||||
% and get the comment from there.
|
||||
ModuleComment = get_comment_forwards(Comments, 1),
|
||||
|
||||
io.open_output(FileName, OpenResult, !IO),
|
||||
@@ -132,7 +130,7 @@ build_comments(S, comments(!.C), comments(!:C), !IO) :-
|
||||
LineResult = eof
|
||||
;
|
||||
LineResult = error(E),
|
||||
% XXX we should recover more gracefully from this error.
|
||||
% XXX we should recover more gracefully from this error.
|
||||
unexpected($module, $pred, io.error_message(E))
|
||||
).
|
||||
|
||||
@@ -327,11 +325,11 @@ get_comment_backwards(Comments, Line) = Comment :-
|
||||
list(xml)::in, list(xml)::out) is det.
|
||||
|
||||
import_documentation(InterfaceImportedModules, ImportedModule, !Xmls) :-
|
||||
XmlName = name(ImportedModule),
|
||||
XmlName = name_to_xml(ImportedModule),
|
||||
( ImportedModule `set.member` InterfaceImportedModules ->
|
||||
XmlVisibility = visibility(status_exported)
|
||||
XmlVisibility = visibility_to_xml(status_exported)
|
||||
;
|
||||
XmlVisibility = visibility(status_local)
|
||||
XmlVisibility = visibility_to_xml(status_local)
|
||||
),
|
||||
Xml = elem("import", [], [XmlName, XmlVisibility]),
|
||||
!:Xmls = [Xml | !.Xmls].
|
||||
@@ -354,14 +352,16 @@ type_documentation(C, type_ctor(TypeName, TypeArity), TypeDefn, !Xmls) :-
|
||||
get_type_defn_context(TypeDefn, Context),
|
||||
get_type_defn_tparams(TypeDefn, TParams),
|
||||
|
||||
XmlName = name(TypeName),
|
||||
XmlTypeParams = xml_list("type_params", type_param(TVarset), TParams),
|
||||
XmlVisibility = visibility(ImportStatus),
|
||||
XmlName = name_to_xml(TypeName),
|
||||
XmlTypeParams = xml_list("type_params", type_param_to_xml(TVarset),
|
||||
TParams),
|
||||
XmlVisibility = visibility_to_xml(ImportStatus),
|
||||
|
||||
Tag = type_xml_tag(TypeBody),
|
||||
Id = attr("id", sym_name_and_arity_to_id("type", TypeName, TypeArity)),
|
||||
Children = [XmlName, XmlTypeParams, XmlVisibility,
|
||||
prog_context(Context) | type_body(C, TVarset, TypeBody)],
|
||||
prog_context_to_xml(Context) |
|
||||
type_body_to_xml(C, TVarset, TypeBody)],
|
||||
Xml0 = elem(Tag, [Id], Children),
|
||||
Xml = maybe_add_comment(C, Context, Xml0),
|
||||
|
||||
@@ -378,83 +378,90 @@ type_xml_tag(hlds_foreign_type(_)) = "foreign_type".
|
||||
type_xml_tag(hlds_solver_type(_, _)) = "solver_type".
|
||||
type_xml_tag(hlds_abstract_type(_)) = "abstract_type".
|
||||
|
||||
:- func type_param(tvarset, type_param) = xml.
|
||||
:- func type_param_to_xml(tvarset, type_param) = xml.
|
||||
|
||||
type_param(TVarset, TVar) = Xml :-
|
||||
type_param_to_xml(TVarset, TVar) = Xml :-
|
||||
TVarName = varset.lookup_name(TVarset, TVar),
|
||||
Xml = tagged_string("type_variable", TVarName).
|
||||
|
||||
:- func type_body(comments, tvarset, hlds_type_body) = list(xml).
|
||||
|
||||
type_body(C, TVarset, hlds_du_type(Ctors, _, _, _, _, _, _, _, _)) =
|
||||
[xml_list("constructors", constructor(C, TVarset), Ctors)].
|
||||
type_body(_, TVarset, hlds_eqv_type(Type)) =
|
||||
[elem("equivalent_type", [], [mer_type(TVarset, Type)])].
|
||||
:- func type_body_to_xml(comments, tvarset, hlds_type_body) = list(xml).
|
||||
|
||||
type_body_to_xml(C, TVarset, hlds_du_type(Ctors, _, _, _, _, _, _, _, _)) =
|
||||
[xml_list("constructors", constructor_to_xml(C, TVarset), Ctors)].
|
||||
type_body_to_xml(_, TVarset, hlds_eqv_type(Type)) =
|
||||
[elem("equivalent_type", [], [mer_type_to_xml(TVarset, Type)])].
|
||||
% XXX TODO
|
||||
type_body(_, _, hlds_foreign_type(_)) = [nyi("hlds_foreign_type")].
|
||||
type_body(_, _, hlds_solver_type(_, _)) = [nyi("hlds_solver_type")].
|
||||
type_body(_, _, hlds_abstract_type(_)) = [nyi("hlds_abstract_type")].
|
||||
type_body_to_xml(_, _, hlds_foreign_type(_)) = [nyi("hlds_foreign_type")].
|
||||
type_body_to_xml(_, _, hlds_solver_type(_, _)) = [nyi("hlds_solver_type")].
|
||||
type_body_to_xml(_, _, hlds_abstract_type(_)) = [nyi("hlds_abstract_type")].
|
||||
|
||||
:- func constructor(comments, tvarset, constructor) = xml.
|
||||
:- func constructor_to_xml(comments, tvarset, constructor) = xml.
|
||||
|
||||
constructor(C, TVarset,
|
||||
constructor_to_xml(C, TVarset,
|
||||
ctor(Exists, Constraints, Name, Args, Context)) = Xml :-
|
||||
Id = attr("id", sym_name_and_arity_to_id("ctor", Name, length(Args))),
|
||||
XmlName = name(Name),
|
||||
XmlContext = prog_context(Context),
|
||||
XmlArgs = xml_list("ctor_args", constructor_arg(C, TVarset), Args),
|
||||
XmlExistVars = xml_list("ctor_exist_vars", type_param(TVarset), Exists),
|
||||
XmlName = name_to_xml(Name),
|
||||
XmlContext = prog_context_to_xml(Context),
|
||||
XmlArgs = xml_list("ctor_args", constructor_arg_to_xml(C, TVarset), Args),
|
||||
XmlExistVars = xml_list("ctor_exist_vars", type_param_to_xml(TVarset),
|
||||
Exists),
|
||||
XmlConstraints =
|
||||
xml_list("ctor_constraints", prog_constraint(TVarset), Constraints),
|
||||
xml_list("ctor_constraints", prog_constraint_to_xml(TVarset),
|
||||
Constraints),
|
||||
Xml0 = elem("constructor", [Id],
|
||||
[XmlName, XmlContext, XmlArgs, XmlExistVars, XmlConstraints]),
|
||||
Xml = maybe_add_comment(C, Context, Xml0).
|
||||
|
||||
:- func constructor_arg(comments, tvarset, constructor_arg) = xml.
|
||||
:- func constructor_arg_to_xml(comments, tvarset, constructor_arg) = xml.
|
||||
|
||||
constructor_arg(C, TVarset, CtorArg) = Xml :-
|
||||
constructor_arg_to_xml(C, TVarset, CtorArg) = Xml :-
|
||||
CtorArg = ctor_arg(MaybeFieldName, Type, _Width, Context),
|
||||
XmlType = elem("arg_type", [], [mer_type(TVarset, Type)]),
|
||||
XmlContext = prog_context(Context),
|
||||
XmlType = elem("arg_type", [], [mer_type_to_xml(TVarset, Type)]),
|
||||
XmlContext = prog_context_to_xml(Context),
|
||||
(
|
||||
MaybeFieldName = yes(FieldName),
|
||||
Id = attr("id", sym_name_to_id("field", FieldName)),
|
||||
XmlMaybeFieldName = [elem("field", [Id], [name(FieldName)])]
|
||||
XmlMaybeFieldName = [elem("field", [Id], [name_to_xml(FieldName)])]
|
||||
;
|
||||
MaybeFieldName = no,
|
||||
XmlMaybeFieldName = []
|
||||
),
|
||||
|
||||
Xml0 = elem("ctor_arg", [], [XmlType, XmlContext | XmlMaybeFieldName]),
|
||||
Xml = maybe_add_comment(C, Context, Xml0).
|
||||
|
||||
:- func mer_type(tvarset, mer_type) = xml.
|
||||
:- func mer_type_to_xml(tvarset, mer_type) = xml.
|
||||
|
||||
mer_type(TVarset, type_variable(TVar, _)) = type_param(TVarset, TVar).
|
||||
mer_type(TVarset, defined_type(TypeName, Args, _)) = Xml :-
|
||||
Ref = attr("ref", sym_name_and_arity_to_id("type", TypeName, length(Args))),
|
||||
XmlName = name(TypeName),
|
||||
XmlArgs = xml_list("type_args", mer_type(TVarset), Args),
|
||||
mer_type_to_xml(TVarset, type_variable(TVar, _)) =
|
||||
type_param_to_xml(TVarset, TVar).
|
||||
mer_type_to_xml(TVarset, defined_type(TypeName, Args, _)) = Xml :-
|
||||
Ref = attr("ref",
|
||||
sym_name_and_arity_to_id("type", TypeName, length(Args))),
|
||||
XmlName = name_to_xml(TypeName),
|
||||
XmlArgs = xml_list("type_args", mer_type_to_xml(TVarset), Args),
|
||||
Xml = elem("type", [Ref], [XmlName, XmlArgs]).
|
||||
mer_type(_, builtin_type(builtin_type_int)) = elem("int", [], []).
|
||||
mer_type(_, builtin_type(builtin_type_float)) = elem("float", [], []).
|
||||
mer_type(_, builtin_type(builtin_type_string)) = elem("string", [], []).
|
||||
mer_type(_, builtin_type(builtin_type_char)) = elem("character", [], []).
|
||||
mer_type(TVarset, higher_order_type(Types, MaybeResult, _, _)) = Xml :-
|
||||
XmlTypes = xml_list("higher_order_type_args", mer_type(TVarset), Types),
|
||||
( MaybeResult = yes(ResultType),
|
||||
XmlReturn = elem("return_type", [], [mer_type(TVarset, ResultType)]),
|
||||
mer_type_to_xml(_, builtin_type(builtin_type_int)) = elem("int", [], []).
|
||||
mer_type_to_xml(_, builtin_type(builtin_type_float)) = elem("float", [], []).
|
||||
mer_type_to_xml(_, builtin_type(builtin_type_string)) = elem("string", [], []).
|
||||
mer_type_to_xml(_, builtin_type(builtin_type_char)) =
|
||||
elem("character", [], []).
|
||||
mer_type_to_xml(TVarset, higher_order_type(Types, MaybeResult, _, _)) = Xml :-
|
||||
XmlTypes = xml_list("higher_order_type_args", mer_type_to_xml(TVarset),
|
||||
Types),
|
||||
(
|
||||
MaybeResult = yes(ResultType),
|
||||
XmlReturn = elem("return_type", [],
|
||||
[mer_type_to_xml(TVarset, ResultType)]),
|
||||
XmlChildren = [XmlTypes, XmlReturn]
|
||||
; MaybeResult = no,
|
||||
;
|
||||
MaybeResult = no,
|
||||
XmlChildren = [XmlTypes]
|
||||
),
|
||||
Xml = elem("higher_order_type", [], XmlChildren).
|
||||
mer_type(TVarset, tuple_type(Types, _)) = Xml :-
|
||||
XmlArgs = xml_list("tuple_types", mer_type(TVarset), Types),
|
||||
mer_type_to_xml(TVarset, tuple_type(Types, _)) = Xml :-
|
||||
XmlArgs = xml_list("tuple_types", mer_type_to_xml(TVarset), Types),
|
||||
Xml = elem("tuple", [], [XmlArgs]).
|
||||
mer_type(_, apply_n_type(_, _, _)) = nyi("apply_n_type").
|
||||
mer_type(_, kinded_type(_, _)) = nyi("kinded_type").
|
||||
mer_type_to_xml(_, apply_n_type(_, _, _)) = nyi("apply_n_type").
|
||||
mer_type_to_xml(_, kinded_type(_, _)) = nyi("kinded_type").
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
%-----------------------------------------------------------------------------%
|
||||
@@ -503,12 +510,13 @@ predicate_documentation(C, PredInfo) = Xml :-
|
||||
),
|
||||
Id = sym_name_and_arity_to_id(Tag, PredName, Arity),
|
||||
|
||||
XmlName = name(PredName),
|
||||
XmlContext = prog_context(Context),
|
||||
XmlTypes = xml_list("pred_types", mer_type(TVarset), Types),
|
||||
XmlExistVars = xml_list("pred_exist_vars", type_param(TVarset), Exists),
|
||||
XmlConstraints = prog_constraints(TVarset, Constraints),
|
||||
XmlVisibility = visibility(ImportStatus),
|
||||
XmlName = name_to_xml(PredName),
|
||||
XmlContext = prog_context_to_xml(Context),
|
||||
XmlTypes = xml_list("pred_types", mer_type_to_xml(TVarset), Types),
|
||||
XmlExistVars = xml_list("pred_exist_vars", type_param_to_xml(TVarset),
|
||||
Exists),
|
||||
XmlConstraints = prog_constraints_to_xml(TVarset, Constraints),
|
||||
XmlVisibility = visibility_to_xml(ImportStatus),
|
||||
|
||||
pred_info_get_procedures(PredInfo, ProcTable),
|
||||
map.foldl(pred_mode_documentation(C), ProcTable, [], XmlProcs),
|
||||
@@ -537,12 +545,13 @@ keep_last_n(N, L0) =
|
||||
func_error("keep_last_n")
|
||||
).
|
||||
|
||||
:- func prog_constraints(tvarset, prog_constraints) = xml.
|
||||
|
||||
prog_constraints(TVarset, constraints(Univs, Exists)) = Xml :-
|
||||
XmlUnivs = xml_list("pred_universal", prog_constraint(TVarset), Univs),
|
||||
XmlExists = xml_list("pred_exist", prog_constraint(TVarset), Exists),
|
||||
:- func prog_constraints_to_xml(tvarset, prog_constraints) = xml.
|
||||
|
||||
prog_constraints_to_xml(TVarset, constraints(Univs, Exists)) = Xml :-
|
||||
XmlUnivs = xml_list("pred_universal",
|
||||
prog_constraint_to_xml(TVarset), Univs),
|
||||
XmlExists = xml_list("pred_exist",
|
||||
prog_constraint_to_xml(TVarset), Exists),
|
||||
Xml = elem("pred_constraints", [], [XmlUnivs, XmlExists]).
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
@@ -552,35 +561,35 @@ prog_constraints(TVarset, constraints(Univs, Exists)) = Xml :-
|
||||
list(xml)::in, list(xml)::out) is det.
|
||||
|
||||
pred_mode_documentation(_C, _ProcId, ProcInfo, !Xml) :-
|
||||
% XXX do we ever need to remove arguments here?
|
||||
% XXX do we ever need to remove arguments here?
|
||||
proc_info_get_inst_varset(ProcInfo, IVarSet),
|
||||
proc_info_declared_argmodes(ProcInfo, Modes),
|
||||
proc_info_interface_determinism(ProcInfo, Determinism),
|
||||
|
||||
XmlModes = xml_list("modes", mer_mode(IVarSet), Modes),
|
||||
XmlDet = determinism(Determinism),
|
||||
XmlModes = xml_list("modes", mer_mode_to_xml(IVarSet), Modes),
|
||||
XmlDet = determinism_to_xml(Determinism),
|
||||
Xml = elem("pred_mode", [], [XmlModes, XmlDet]),
|
||||
|
||||
!:Xml = [Xml | !.Xml].
|
||||
|
||||
:- func mer_mode(inst_varset, mer_mode) = xml.
|
||||
:- func mer_mode_to_xml(inst_varset, mer_mode) = xml.
|
||||
|
||||
mer_mode(InstVarSet, Mode) = Xml :-
|
||||
mer_mode_to_xml(InstVarSet, Mode) = Xml :-
|
||||
(
|
||||
Mode = (A -> B),
|
||||
XmlFrom = xml_list("from", mer_inst(InstVarSet), [A]),
|
||||
XmlTo = xml_list("to", mer_inst(InstVarSet), [B]),
|
||||
XmlFrom = xml_list("from", mer_inst_to_xml(InstVarSet), [A]),
|
||||
XmlTo = xml_list("to", mer_inst_to_xml(InstVarSet), [B]),
|
||||
Xml = elem("inst_to_inst", [], [XmlFrom, XmlTo])
|
||||
;
|
||||
Mode = user_defined_mode(Name, Args),
|
||||
Ref = attr("ref", sym_name_and_arity_to_id("mode", Name, length(Args))),
|
||||
XmlArgs = xml_list("mode_args", mer_inst(InstVarSet), Args),
|
||||
Xml = elem("user_defined_mode", [Ref], [name(Name), XmlArgs])
|
||||
XmlArgs = xml_list("mode_args", mer_inst_to_xml(InstVarSet), Args),
|
||||
Xml = elem("user_defined_mode", [Ref], [name_to_xml(Name), XmlArgs])
|
||||
).
|
||||
|
||||
:- func mer_inst(inst_varset, mer_inst) = xml.
|
||||
:- func mer_inst_to_xml(inst_varset, mer_inst) = xml.
|
||||
|
||||
mer_inst(InstVarSet, Inst) = Xml :-
|
||||
mer_inst_to_xml(InstVarSet, Inst) = Xml :-
|
||||
(
|
||||
Inst = free,
|
||||
Xml = elem("free", [], [])
|
||||
@@ -589,15 +598,16 @@ mer_inst(InstVarSet, Inst) = Xml :-
|
||||
Xml = elem("free", [], [])
|
||||
;
|
||||
Inst = bound(U, _, BoundInsts),
|
||||
XmlUniq = uniqueness(U),
|
||||
XmlInsts = xml_list("bound_insts", bound_inst(InstVarSet), BoundInsts),
|
||||
XmlUniq = uniqueness_to_xml(U),
|
||||
XmlInsts = xml_list("bound_insts", bound_inst_to_xml(InstVarSet),
|
||||
BoundInsts),
|
||||
Xml = elem("bound", [], [XmlUniq, XmlInsts])
|
||||
;
|
||||
Inst = ground(U, _),
|
||||
Xml = elem("ground", [], [uniqueness(U)])
|
||||
Xml = elem("ground", [], [uniqueness_to_xml(U)])
|
||||
;
|
||||
Inst = any(U, _),
|
||||
Xml = elem("any", [], [uniqueness(U)])
|
||||
Xml = elem("any", [], [uniqueness_to_xml(U)])
|
||||
;
|
||||
Inst = not_reached,
|
||||
Xml = elem("not_reached", [], [])
|
||||
@@ -608,82 +618,88 @@ mer_inst(InstVarSet, Inst) = Xml :-
|
||||
;
|
||||
Inst = constrained_inst_vars(_, SubInst),
|
||||
% XXX We do we ignore the constraint?
|
||||
Xml = mer_inst(InstVarSet, SubInst)
|
||||
Xml = mer_inst_to_xml(InstVarSet, SubInst)
|
||||
;
|
||||
Inst = defined_inst(Name),
|
||||
XmlName = inst_name(InstVarSet, Name),
|
||||
XmlName = inst_name_to_xml(InstVarSet, Name),
|
||||
Xml = elem("defined_inst", [], [XmlName])
|
||||
;
|
||||
Inst = abstract_inst(SymName, ArgInsts),
|
||||
Xml = mer_inst(InstVarSet, defined_inst(user_inst(SymName, ArgInsts)))
|
||||
Xml = mer_inst_to_xml(InstVarSet,
|
||||
defined_inst(user_inst(SymName, ArgInsts)))
|
||||
).
|
||||
|
||||
:- func inst_name(inst_varset, inst_name) = xml.
|
||||
:- func inst_name_to_xml(inst_varset, inst_name) = xml.
|
||||
|
||||
inst_name(InstVarSet, user_inst(Name, Insts)) = Xml :-
|
||||
inst_name_to_xml(InstVarSet, user_inst(Name, Insts)) = Xml :-
|
||||
Ref = attr("ref", sym_name_and_arity_to_id("inst", Name, length(Insts))),
|
||||
XmlName = name(Name),
|
||||
XmlInsts = xml_list("inst_args", mer_inst(InstVarSet), Insts),
|
||||
XmlName = name_to_xml(Name),
|
||||
XmlInsts = xml_list("inst_args", mer_inst_to_xml(InstVarSet), Insts),
|
||||
Xml = elem("user_inst", [Ref], [XmlName, XmlInsts]).
|
||||
inst_name(_, merge_inst(_, _)) = nyi("merge_inst").
|
||||
inst_name(_, unify_inst(_, _, _, _)) = nyi("unify_inst").
|
||||
inst_name(_, ground_inst(_, _, _, _)) = nyi("ground_inst").
|
||||
inst_name(_, any_inst(_, _, _, _)) = nyi("any_inst").
|
||||
inst_name(_, shared_inst(_)) = nyi("shared_inst").
|
||||
inst_name(_, mostly_uniq_inst(_)) = nyi("mostly_uniq_inst").
|
||||
inst_name(_, typed_ground(_, _)) = nyi("typed_ground").
|
||||
inst_name(_, typed_inst(_, _)) = nyi("typed_inst").
|
||||
inst_name_to_xml(_, merge_inst(_, _)) = nyi("merge_inst").
|
||||
inst_name_to_xml(_, unify_inst(_, _, _, _)) = nyi("unify_inst").
|
||||
inst_name_to_xml(_, ground_inst(_, _, _, _)) = nyi("ground_inst").
|
||||
inst_name_to_xml(_, any_inst(_, _, _, _)) = nyi("any_inst").
|
||||
inst_name_to_xml(_, shared_inst(_)) = nyi("shared_inst").
|
||||
inst_name_to_xml(_, mostly_uniq_inst(_)) = nyi("mostly_uniq_inst").
|
||||
inst_name_to_xml(_, typed_ground(_, _)) = nyi("typed_ground").
|
||||
inst_name_to_xml(_, typed_inst(_, _)) = nyi("typed_inst").
|
||||
|
||||
:- func uniqueness(uniqueness) = xml.
|
||||
:- func uniqueness_to_xml(uniqueness) = xml.
|
||||
|
||||
uniqueness(U) = tagged_string("uniqueness", string(U)).
|
||||
uniqueness_to_xml(U) = tagged_string("uniqueness", string(U)).
|
||||
|
||||
:- func bound_inst(inst_varset, bound_inst) = xml.
|
||||
:- func bound_inst_to_xml(inst_varset, bound_inst) = xml.
|
||||
|
||||
bound_inst(InstVarSet, bound_functor(ConsId, Insts)) = Xml :-
|
||||
XmlCons = cons_id(ConsId),
|
||||
XmlInsts = xml_list("insts", mer_inst(InstVarSet), Insts),
|
||||
bound_inst_to_xml(InstVarSet, bound_functor(ConsId, Insts)) = Xml :-
|
||||
XmlCons = cons_id_to_xml(ConsId),
|
||||
XmlInsts = xml_list("insts", mer_inst_to_xml(InstVarSet), Insts),
|
||||
Xml = elem("bound_functor", [], [XmlCons, XmlInsts]).
|
||||
|
||||
:- func cons_id(cons_id) = xml.
|
||||
:- func cons_id_to_xml(cons_id) = xml.
|
||||
|
||||
cons_id(cons(Name, Arity, _)) = elem("cons", [], [name(Name), arity(Arity)]).
|
||||
cons_id_to_xml(cons(Name, Arity, _)) =
|
||||
elem("cons", [], [name_to_xml(Name), arity_to_xml(Arity)]).
|
||||
% XXX We could do better for tuple_cons and closure_cons.
|
||||
% The return values here are just a continuation of what we used to do.
|
||||
cons_id(tuple_cons(Arity)) =
|
||||
elem("cons", [], [name(unqualified("{}")), arity(Arity)]).
|
||||
cons_id(int_const(I)) = tagged_int("int", I).
|
||||
cons_id(float_const(F)) = tagged_float("float", F).
|
||||
cons_id(char_const(C)) = tagged_char("char", C).
|
||||
cons_id(string_const(S)) = tagged_string("string", S).
|
||||
cons_id(impl_defined_const(_)) = nyi("impl_defined_const").
|
||||
cons_id(closure_cons(_, _)) = nyi("closure_cons").
|
||||
cons_id(type_ctor_info_const(_, _, _)) = nyi("type_ctor_info_const").
|
||||
cons_id(base_typeclass_info_const(_,_,_,_)) = nyi("base_typeclass_info_const").
|
||||
cons_id(type_info_cell_constructor(_)) = nyi("type_info_cell_constructor").
|
||||
cons_id(typeclass_info_cell_constructor) =
|
||||
cons_id_to_xml(tuple_cons(Arity)) =
|
||||
elem("cons", [], [name_to_xml(unqualified("{}")), arity_to_xml(Arity)]).
|
||||
cons_id_to_xml(int_const(I)) = tagged_int("int", I).
|
||||
cons_id_to_xml(float_const(F)) = tagged_float("float", F).
|
||||
cons_id_to_xml(char_const(C)) = tagged_char("char", C).
|
||||
cons_id_to_xml(string_const(S)) = tagged_string("string", S).
|
||||
cons_id_to_xml(impl_defined_const(_)) = nyi("impl_defined_const").
|
||||
cons_id_to_xml(closure_cons(_, _)) = nyi("closure_cons").
|
||||
cons_id_to_xml(type_ctor_info_const(_, _, _)) = nyi("type_ctor_info_const").
|
||||
cons_id_to_xml(base_typeclass_info_const(_,_,_,_)) =
|
||||
nyi("base_typeclass_info_const").
|
||||
cons_id_to_xml(type_info_cell_constructor(_)) =
|
||||
nyi("type_info_cell_constructor").
|
||||
cons_id_to_xml(typeclass_info_cell_constructor) =
|
||||
nyi("typeclass_info_cell_constructor").
|
||||
cons_id(type_info_const(_)) = nyi("type_info_const").
|
||||
cons_id(typeclass_info_const(_)) = nyi("typeclass_info_const").
|
||||
cons_id(ground_term_const(_, _)) = nyi("ground_term_const").
|
||||
cons_id(tabling_info_const(_)) = nyi("tabling_info_const").
|
||||
cons_id(table_io_decl(_)) = nyi("table_io_decl").
|
||||
cons_id(deep_profiling_proc_layout(_)) = nyi("deep_profiling_proc_layout").
|
||||
cons_id_to_xml(type_info_const(_)) = nyi("type_info_const").
|
||||
cons_id_to_xml(typeclass_info_const(_)) = nyi("typeclass_info_const").
|
||||
cons_id_to_xml(ground_term_const(_, _)) = nyi("ground_term_const").
|
||||
cons_id_to_xml(tabling_info_const(_)) = nyi("tabling_info_const").
|
||||
cons_id_to_xml(table_io_decl(_)) = nyi("table_io_decl").
|
||||
cons_id_to_xml(deep_profiling_proc_layout(_)) =
|
||||
nyi("deep_profiling_proc_layout").
|
||||
|
||||
:- func arity(int) = xml.
|
||||
:- func arity_to_xml(int) = xml.
|
||||
|
||||
arity(Arity) = tagged_int("arity", Arity).
|
||||
arity_to_xml(Arity) = tagged_int("arity", Arity).
|
||||
|
||||
:- func determinism(determinism) = xml.
|
||||
:- func determinism_to_xml(determinism) = xml.
|
||||
|
||||
determinism(detism_det) = tagged_string("determinism", "det").
|
||||
determinism(detism_semi) = tagged_string("determinism", "semidet").
|
||||
determinism(detism_multi) = tagged_string("determinism", "multi").
|
||||
determinism(detism_non) = tagged_string("determinism", "nondet").
|
||||
determinism(detism_cc_non) = tagged_string("determinism", "cc_nondet").
|
||||
determinism(detism_cc_multi) = tagged_string("determinism", "cc_multi").
|
||||
determinism(detism_erroneous) = tagged_string("determinism", "erroneous").
|
||||
determinism(detism_failure) = tagged_string("determinism", "failure").
|
||||
determinism_to_xml(detism_det) = tagged_string("determinism", "det").
|
||||
determinism_to_xml(detism_semi) = tagged_string("determinism", "semidet").
|
||||
determinism_to_xml(detism_multi) = tagged_string("determinism", "multi").
|
||||
determinism_to_xml(detism_non) = tagged_string("determinism", "nondet").
|
||||
determinism_to_xml(detism_cc_non) = tagged_string("determinism", "cc_nondet").
|
||||
determinism_to_xml(detism_cc_multi) = tagged_string("determinism", "cc_multi").
|
||||
determinism_to_xml(detism_erroneous) =
|
||||
tagged_string("determinism", "erroneous").
|
||||
determinism_to_xml(detism_failure) = tagged_string("determinism", "failure").
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
%-----------------------------------------------------------------------------%
|
||||
@@ -703,16 +719,17 @@ class_documentation(C, PredTable, class_id(Name, Arity), ClassDefn, !Xml) :-
|
||||
TVarset = ClassDefn ^ class_tvarset,
|
||||
Vars = ClassDefn ^ class_vars,
|
||||
|
||||
XmlName = name(Name),
|
||||
XmlClassVars = xml_list("class_vars", type_param(TVarset), Vars),
|
||||
XmlName = name_to_xml(Name),
|
||||
XmlClassVars = xml_list("class_vars",
|
||||
type_param_to_xml(TVarset), Vars),
|
||||
XmlSupers = xml_list("superclasses",
|
||||
prog_constraint(TVarset), ClassDefn ^ class_supers),
|
||||
prog_constraint_to_xml(TVarset), ClassDefn ^ class_supers),
|
||||
XmlFundeps = xml_list("fundeps",
|
||||
fundep(TVarset, Vars), ClassDefn ^ class_fundeps),
|
||||
XmlMethods = class_methods(C,
|
||||
PredTable, ClassDefn ^ class_hlds_interface),
|
||||
XmlVisibility = visibility(ImportStatus),
|
||||
XmlContext = prog_context(Context),
|
||||
fundep_to_xml(TVarset, Vars), ClassDefn ^ class_fundeps),
|
||||
XmlMethods = class_methods_to_xml(C, PredTable,
|
||||
ClassDefn ^ class_hlds_interface),
|
||||
XmlVisibility = visibility_to_xml(ImportStatus),
|
||||
XmlContext = prog_context_to_xml(Context),
|
||||
|
||||
Xml0 = elem("typeclass", [attr("id", Id)],
|
||||
[XmlName, XmlClassVars, XmlSupers,
|
||||
@@ -725,21 +742,23 @@ class_documentation(C, PredTable, class_id(Name, Arity), ClassDefn, !Xml) :-
|
||||
DefinedInThisModule = no
|
||||
).
|
||||
|
||||
:- func fundep(tvarset, list(tvar), hlds_class_fundep) = xml.
|
||||
:- func fundep_to_xml(tvarset, list(tvar), hlds_class_fundep) = xml.
|
||||
|
||||
fundep(TVarset, Vars, fundep(Domain, Range)) = Xml :-
|
||||
XmlDomain = fundep_2("domain", TVarset, Vars, Domain),
|
||||
XmlRange = fundep_2("range", TVarset, Vars, Range),
|
||||
fundep_to_xml(TVarset, Vars, fundep(Domain, Range)) = Xml :-
|
||||
XmlDomain = fundep_to_xml_2("domain", TVarset, Vars, Domain),
|
||||
XmlRange = fundep_to_xml_2("range", TVarset, Vars, Range),
|
||||
Xml = elem("fundep", [], [XmlDomain, XmlRange]).
|
||||
|
||||
:- func fundep_2(string, tvarset, list(tvar), set(hlds_class_argpos)) = xml.
|
||||
:- func fundep_to_xml_2(string, tvarset, list(tvar), set(hlds_class_argpos))
|
||||
= xml.
|
||||
|
||||
fundep_2(Tag, TVarset, Vars, Set) =
|
||||
xml_list(Tag, type_param(TVarset), restrict_list_elements(Set, Vars)).
|
||||
fundep_to_xml_2(Tag, TVarset, Vars, Set) =
|
||||
xml_list(Tag, type_param_to_xml(TVarset),
|
||||
restrict_list_elements(Set, Vars)).
|
||||
|
||||
:- func class_methods(comments, pred_table, hlds_class_interface) = xml.
|
||||
:- func class_methods_to_xml(comments, pred_table, hlds_class_interface) = xml.
|
||||
|
||||
class_methods(C, PredTable, Methods) = Xml :-
|
||||
class_methods_to_xml(C, PredTable, Methods) = Xml :-
|
||||
AllPredIds = list.map(func(hlds_class_proc(PredId, _)) = PredId, Methods),
|
||||
PredIds = list.sort_and_remove_dups(AllPredIds),
|
||||
PredInfos = list.map(func(Id) = map.lookup(PredTable, Id), PredIds),
|
||||
@@ -748,39 +767,39 @@ class_methods(C, PredTable, Methods) = Xml :-
|
||||
%-----------------------------------------------------------------------------%
|
||||
%-----------------------------------------------------------------------------%
|
||||
|
||||
:- func name(sym_name) = xml.
|
||||
:- func name_to_xml(sym_name) = xml.
|
||||
|
||||
name(unqualified(Name)) = tagged_string("unqualified", Name).
|
||||
name(qualified(Module, Name)) =
|
||||
name_to_xml(unqualified(Name)) = tagged_string("unqualified", Name).
|
||||
name_to_xml(qualified(Module, Name)) =
|
||||
elem("qualified", [], [
|
||||
tagged_string("module", sym_name_to_string(Module)),
|
||||
tagged_string("name", Name)]).
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
|
||||
:- func prog_context(prog_context) = xml.
|
||||
:- func prog_context_to_xml(prog_context) = xml.
|
||||
|
||||
prog_context(context(FileName, LineNumber)) =
|
||||
prog_context_to_xml(context(FileName, LineNumber)) =
|
||||
elem("context", [], [
|
||||
tagged_string("filename", FileName),
|
||||
tagged_int("line", LineNumber)]).
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
|
||||
:- func prog_constraint(tvarset, prog_constraint) = xml.
|
||||
:- func prog_constraint_to_xml(tvarset, prog_constraint) = xml.
|
||||
|
||||
prog_constraint(TVarset, constraint(ClassName, Types)) = Xml :-
|
||||
prog_constraint_to_xml(TVarset, constraint(ClassName, Types)) = Xml :-
|
||||
Id = sym_name_and_arity_to_id("constraint", ClassName, list.length(Types)),
|
||||
XmlName = name(ClassName),
|
||||
XmlTypes = xml_list("constraint_types", mer_type(TVarset), Types),
|
||||
XmlName = name_to_xml(ClassName),
|
||||
XmlTypes = xml_list("constraint_types", mer_type_to_xml(TVarset), Types),
|
||||
Xml = elem("constraint", [attr("ref", Id)], [XmlName, XmlTypes]).
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
%-----------------------------------------------------------------------------%
|
||||
|
||||
:- func visibility(import_status) = xml.
|
||||
:- func visibility_to_xml(import_status) = xml.
|
||||
|
||||
visibility(Status) = tagged_string("visibility", Visibility) :-
|
||||
visibility_to_xml(Status) = tagged_string("visibility", Visibility) :-
|
||||
( status_defined_in_impl_section(Status) = yes ->
|
||||
( Status = status_abstract_exported ->
|
||||
Visibility = "abstract"
|
||||
|
||||
Reference in New Issue
Block a user