1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2000-2015. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% %CopyrightEnd%
19%%
20
21%%% This file is meant to be included by xref_* only.
22
23-define(VAR_EXPR, '$F_EXPR').
24-define(MOD_EXPR, '$M_EXPR').
25
26-define(XREF_END_LINE, (1 bsl 23)).
27
28%%% Filenames are stored as directory and basename. A lot of heap can
29%%% be saved by keeping only one (or few) copy of the directory name.
30
31%% 'data' in xref_mod holds "raw" data (as sets) for each module. The
32%% data in 'variables' is derived from raw data.
33-record(xref, {
34	  version = 1,                  % version of the xref record
35	  mode = functions,
36	  variables = not_set_up,       % table of variables
37
38	  modules = dict:new(),         % dict-of(xref_mod())
39	  applications = dict:new(),    % dict-of(xref_app())
40	  releases = dict:new(),        % dict-of(xref_rel())
41
42	  library_path = [],         % [string()] | code_path
43	  libraries = dict:new(),    % dict-of(xref_lib())
44
45	  builtins_default = false,  % Default value of the 'builtins' option.
46	  recurse_default = false,   % Default value of the 'recurse' option.
47	  verbose_default = false,   % Default value of the 'verbose' option.
48	  warnings_default = true    % Default value of the 'warnings' option.
49	  }).
50
51-record(xref_mod, {
52	  name = '',
53	  app_name = [],     % [] or [AppName]
54	  dir = "",          % string(), directory where the BEAM file resides
55	  mtime,             % modification time for file
56	  builtins,          % whether calls to built-in functions are included
57	  info,              % number of exports, locals etc.
58	  no_unresolved = 0, % number of unresolved calls
59	  data
60	  %% Data has been read from the BEAM file, and is represented here
61          %% as a list of sets.
62	  %% If xref.mode = functions:
63          %% [
64	  %% DefAt,         M -> P(V * N)
65	  %% L,             M -> P(V)
66	  %% X,             M -> P(V)
67	  %% LCallAt,       M -> P(V * V -> P(N))
68	  %% XCallAt,       M -> P(V * V -> P(N))
69	  %% CallAt,        M -> P(V * V -> P(N))
70	  %% LC,            M -> P(V * V)
71	  %% XC,            M -> P(V * V)
72	  %% LU,            M -> P(V)
73	  %% EE,            M -> P(EV * EV)
74	  %% ECallAt,       M -> P(EV * EV -> P(N))
75	  %% Unres,         M -> P(V * V)
76	  %% LPredefined    M -> P(V)
77          %% ]
78	  %%
79	  %% If xref.mode = modules:
80          %% [
81	  %% X,             M -> P(V)
82	  %% I              M -> P(V)
83          %% ]
84	  }).
85
86-record(xref_app, {
87	  name = '',
88	  rel_name = [], % [] or [RelName]
89	  vsn = [],
90	  dir = ""     % where BEAM files are read from
91	  }).
92
93-record(xref_rel, {
94	  name = '',
95	  dir = ""     % where application directories reside
96	  }).
97
98-record(xref_lib, {
99	  name = '',   % atom(), module name
100	  dir = ""     % string(), directory where the file resides
101	  }).
102
103-record(xref_var, {
104	  name = '',   % atom(), variable name
105	  value,       % set or pair of sets, variable value
106	  vtype,       % VarType (predef, tmp, user)
107	  otype,       % ObjectType (vertex, edge, etc.)
108	  type         % Type (function, module, etc.)
109	  }).
110