aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/src/xref.hrl
blob: a83271cbdb0111cd90e254c924c4402aa44e1a5b (plain) (blame)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
%%
%% %CopyrightBegin%
%% 
%% Copyright Ericsson AB 2000-2015. All Rights Reserved.
%% 
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%% 
%% %CopyrightEnd%
%%

%%% This file is meant to be included by xref_* only.

-define(VAR_EXPR, '$F_EXPR').
-define(MOD_EXPR, '$M_EXPR').

-define(XREF_END_LINE, (1 bsl 23)).

%%% Filenames are stored as directory and basename. A lot of heap can
%%% be saved by keeping only one (or few) copy of the directory name.

%% 'data' in xref_mod holds "raw" data (as sets) for each module. The
%% data in 'variables' is derived from raw data.
-record(xref, {
	  version = 1,                  % version of the xref record
	  mode = functions,
	  variables = not_set_up,       % table of variables

	  modules = dict:new(),         % dict-of(xref_mod())
	  applications = dict:new(),    % dict-of(xref_app())
	  releases = dict:new(),        % dict-of(xref_rel())

	  library_path = [],         % [string()] | code_path
	  libraries = dict:new(),    % dict-of(xref_lib())

	  builtins_default = false,  % Default value of the 'builtins' option.
	  recurse_default = false,   % Default value of the 'recurse' option.
	  verbose_default = false,   % Default value of the 'verbose' option.
	  warnings_default = true    % Default value of the 'warnings' option.
	  }).

-record(xref_mod, {
	  name = '',
	  app_name = [],     % [] or [AppName]
	  dir = "",          % string(), directory where the BEAM file resides
	  mtime,             % modification time for file
	  builtins,          % whether calls to built-in functions are included
	  info,              % number of exports, locals etc.
	  no_unresolved = 0, % number of unresolved calls
	  data               
	  %% Data has been read from the BEAM file, and is represented here
          %% as a list of sets.
	  %% If xref.mode = functions:
          %% [
	  %% DefAt,         M -> P(V * N)
	  %% L,             M -> P(V)
	  %% X,             M -> P(V)
	  %% LCallAt,       M -> P(V * V -> P(N))
	  %% XCallAt,       M -> P(V * V -> P(N))
	  %% CallAt,        M -> P(V * V -> P(N))
	  %% LC,            M -> P(V * V)
	  %% XC,            M -> P(V * V)
	  %% LU,            M -> P(V)
	  %% EE,            M -> P(EV * EV)
	  %% ECallAt,       M -> P(EV * EV -> P(N))
	  %% Unres,         M -> P(V * V)
	  %% LPredefined    M -> P(V)
          %% ]
	  %%
	  %% If xref.mode = modules:
          %% [
	  %% X,             M -> P(V)
	  %% I              M -> P(V)
          %% ]
	  }).

-record(xref_app, {
	  name = '',
	  rel_name = [], % [] or [RelName]
	  vsn = [],
	  dir = ""     % where BEAM files are read from
	  }).

-record(xref_rel, {
	  name = '',
	  dir = ""     % where application directories reside
	  }).

-record(xref_lib, {
	  name = '',   % atom(), module name 
	  dir = ""     % string(), directory where the file resides
	  }).

-record(xref_var, {
	  name = '',   % atom(), variable name
	  value,       % set or pair of sets, variable value
	  vtype,       % VarType (predef, tmp, user)
	  otype,       % ObjectType (vertex, edge, etc.)
	  type         % Type (function, module, etc.)
	  }).