29
30:- module(object_support,
31 [ object_label/2, 32 33 object_id/2 34 35 ]).
41:- use_module(wiki). 42
43:- dynamic
44 object_id_cache/2.
51object_id(Object, Id) :-
52 object_id_cache(Object, Id), !.
53object_id(Object, Id) :-
54 ground(Object),
55 variant_sha1(Object, Id),
56 assertz(object_id_cache(Object, Id)).
63object_label(Name/Arity, Label) :- !,
64 format(atom(Label), 'predicate ~w/~w', [Name, Arity]).
65object_label(Name//Arity, Label) :- !,
66 format(atom(Label), 'non-terminal ~w/~w', [Name, Arity]).
67object_label(M:Name/Arity, Label) :- !,
68 format(atom(Label), 'predicate ~w:~w/~w', [M, Name, Arity]).
69object_label(M:Name//Arity, Label) :- !,
70 format(atom(Label), 'non-terminal ~w:~w//~w', [M, Name, Arity]).
71object_label(f(Name/Arity), Label) :- !,
72 format(atom(Label), 'function ~w/~w', [Name, Arity]).
73object_label(c(Function), Label) :- !,
74 format(atom(Label), 'C API function ~w()', [Function]).
75object_label(Module:module(_Title), Label) :-
76 module_property(Module, file(File)), !,
77 file_base_name(File, Base),
78 format(atom(Label), 'module ~w', [Base]).
79object_label(section(ID), Label) :-
80 prolog:doc_object_summary(section(_Level, _No, ID, _File),_,_,Title), !,
81 format(atom(Label), 'Section "~w"', [Title]).
82object_label(wiki(Location), Label) :-
83 wiki_page_title(Location, Title),
84 format(atom(Label), 'Wiki page "~w"', [Title]).
85object_label(Obj, Label) :-
86 term_to_atom(Obj, Label)
Object support
*/