-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcore.resource.m
More file actions
60 lines (47 loc) · 1.92 KB
/
core.resource.m
File metadata and controls
60 lines (47 loc) · 1.92 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
%-----------------------------------------------------------------------%
% Plasma types representation
% vim: ts=4 sw=4 et
%
% Copyright (C) Plasma Team
% Distributed under the terms of the MIT License see ../LICENSE.code
%
%-----------------------------------------------------------------------%
:- module core.resource.
%-----------------------------------------------------------------------%
:- interface.
:- import_module context.
:- import_module common_types.
:- import_module q_name.
%-----------------------------------------------------------------------%
:- type resource
---> r_io
; r_other(
ro_name :: q_name,
ro_from :: resource_id,
ro_sharing :: sharing_opaque,
ro_imported :: imported,
ro_context :: context
)
% A resource imported from another module, this may only exist
% during interface generation.
; r_abstract(q_name).
:- func resource_to_string(resource) = string.
:- pred resource_is_decendant(core::in, resource::in, resource_id::in)
is semidet.
%-----------------------------------------------------------------------%
%-----------------------------------------------------------------------%
:- implementation.
:- import_module builtins.
%-----------------------------------------------------------------------%
resource_to_string(r_io) =
q_name_to_string(q_name_append(builtin_module_name, nq_name_det("IO"))).
resource_to_string(r_other(Symbol, _, _, _, _)) = q_name_to_string(Symbol).
resource_to_string(r_abstract(Symbol)) = q_name_to_string(Symbol).
resource_is_decendant(_, r_io, _) :- false.
resource_is_decendant(Core, r_other(_, Parent, _, _, _), Ancestor) :-
(
Parent = Ancestor
;
resource_is_decendant(Core, core_get_resource(Core, Parent), Ancestor)
).
%-----------------------------------------------------------------------%