1%% Copyright (c) 2014-2015 Robert Virding
2%%
3%% Licensed under the Apache License, Version 2.0 (the "License");
4%% you may not use this file except in compliance with the License.
5%% You may obtain a copy of the License at
6%%
7%%     http://www.apache.org/licenses/LICENSE-2.0
8%%
9%% Unless required by applicable law or agreed to in writing, software
10%% distributed under the License is distributed on an "AS IS" BASIS,
11%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12%% See the License for the specific language governing permissions and
13%% limitations under the License.
14
15%% File    : lfe_comp.hrl
16%% Author  : Robert Virding
17%% Purpose : Common compiler definitions.
18
19%% Common compiler information
20
21-record(cinfo, {file=[],                        %File name
22                opts=[],                        %Compiler options
23                ipath=[],                       %Include path
24                mod=none                        %Module name
25               }).
26
27-record(module, {name=[],                       %Module name
28                 code=none,                     %Module code
29                 warnings=[],                   %Module warnings
30                 docs=[]                        %Module docs
31                }).
32
33%% Bloody useful
34-define(IF(Test,True,False), case Test of true -> True; false -> False end).
35
36%% ?WHEN_OPT(Option, Options, Fun) -> ok.
37%% ?UNLESS_OPT(Option, Options, Fun) -> ok.
38%%  Call Fun when Option is/is not a member of Options.
39
40-define(WHEN_OPT(Opt,Opts,Fun), ?IF(member(Opt, Opts), Fun(), ok)).
41
42%% -define(UNLESS_OPT(Opt,Opts,Fun), ?IF(member(Opt, Opts), ok, Fun())).
43
44-define(DEBUG(Format,Args,Opts),
45        ?WHEN_OPT(debug_print, Opts,
46                  fun () -> lfe_io:format(Format, Args) end)).
47