Changeset 4521 for trunk/compiler

Show
Ignore:
Timestamp:
10/19/08 20:18:33 (3 months ago)
Author:
pmoura
Message:

Corrected a bug where compiler options are not cleared after compilation of source files. This bug would result in wrong compilation of messages sent from the top-level interpreter (i.e. messages sent by the pseudo-object "user") whenever events or hooks compiler options are used.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4518 r4521  
    4141% bitwise left-shift operator (used for unit test context-switching) 
    4242 
    43 :- op(400, yfx, <<). 
     43:- op(400, yfx, <<).    % some Prolog compilers don't declare this operator 
    4444 
    4545 
     
    15451545         '$lgt_set_compiler_flags'(Flags), 
    15461546         '$lgt_compile_files'(Files), 
     1547         '$lgt_clear_compiler_flags', 
    15471548         '$lgt_report_warning_numbers'(logtalk_compile(Files, Flags))), 
    15481549        Error, 
    1549         ('$lgt_reset_warnings_counter', 
     1550        ('$lgt_clear_compiler_flags', 
     1551         '$lgt_reset_warnings_counter', 
    15501552         throw(error(Error, logtalk_compile(Files, Flags))))). 
    15511553 
     
    17511753 
    17521754'$lgt_set_compiler_flags'(Flags) :- 
    1753     retractall('$lgt_pp_compiler_flag_'(_, _)),                     % retract old flag values 
    1754     retractall('$lgt_pp_hook_term_expansion_'(_, _)),               % and any old term and 
    1755     retractall('$lgt_pp_hook_goal_expansion_'(_, _)),               % goal expansion hooks 
    17561755    '$lgt_assert_compiler_flags'(Flags), 
    17571756    (   '$lgt_pp_compiler_flag_'(debug, on) ->                      % debug flag on requires the 
     
    17831782 
    17841783 
     1784% '$lgt_clear_compiler_flags'(@list) 
     1785% 
     1786% clears the compiler flag options 
     1787 
     1788'$lgt_clear_compiler_flags' :- 
     1789    retractall('$lgt_pp_compiler_flag_'(_, _)),         % retract flag values 
     1790    retractall('$lgt_pp_hook_term_expansion_'(_, _)),   % and any term and 
     1791    retractall('$lgt_pp_hook_goal_expansion_'(_, _)).   % goal expansion hooks 
     1792 
     1793 
     1794 
    17851795% logtalk_load(@source_file_name) 
    17861796% logtalk_load(@source_file_name_list) 
     
    18101820         '$lgt_set_compiler_flags'(Flags), 
    18111821         '$lgt_load_files'(Files), 
     1822         '$lgt_clear_compiler_flags', 
    18121823         '$lgt_report_warning_numbers'(logtalk_load(Files, Flags))), 
    18131824        Error, 
    1814         ('$lgt_reset_warnings_counter', 
     1825        ('$lgt_clear_compiler_flags', 
     1826         '$lgt_reset_warnings_counter', 
    18151827         throw(error(Error, logtalk_load(Files, Flags))))). 
    18161828 
     
    47434755    write(': '). 
    47444756 
    4745 'lgt_report_singletons_term'(Term) :- 
     4757'lgt_report_singletons_term'(Term) :-   % facts 
    47464758    functor(Term, Functor, Arity), 
    47474759    write('in clause for predicate '), 
     
    52145226    throw(error(instantiantion_error, directive(Dir))). 
    52155227 
    5216 '$lgt_tr_directive'(Dir, _, _, _) :-            % closing entity directive occurs before the opening 
    5217     \+ '$lgt_pp_entity'(_, _, _, _, _),         % entity directive; the opening directive is probably 
    5218     functor(Dir, Functor, Arity),               % missing or misspelt 
     5228'$lgt_tr_directive'(Dir, _, _, _) :-                    % closing entity directive occurs before the opening 
     5229    \+ '$lgt_pp_entity'(_, _, _, _, _),                 % entity directive; the opening directive is probably 
     5230    functor(Dir, Functor, Arity),                       % missing or misspelt 
    52195231    '$lgt_lgt_closing_directive'(Functor, Arity), 
    52205232    throw(error(unmatched_directive, directive(Dir))). 
    52215233 
    5222 '$lgt_tr_directive'(Dir, _, _, _) :- 
    5223     \+ '$lgt_pp_entity'(_, _, _, _, _),         % directive occurs before opening entity directive 
     5234'$lgt_tr_directive'(Dir, Line, Input, Output) :- 
     5235    \+ '$lgt_pp_entity'(_, _, _, _, _),                 % directive occurs before opening entity directive 
    52245236    functor(Dir, Functor, Arity), 
    52255237    \+ '$lgt_lgt_opening_directive'(Functor, Arity), 
    52265238    !, 
    5227     '$lgt_tr_file_directive'(Dir).              % translate it as a source file-level directive 
    5228  
    5229 '$lgt_tr_directive'(Dir, Line, Input, Output) :-    % entity closing directive 
     5239    '$lgt_tr_file_directive'(Dir, Line, Input, Output). % translate it as a source file-level directive 
     5240 
     5241'$lgt_tr_directive'(Dir, Line, Input, Output) :-        % entity closing directive 
    52305242    functor(Dir, Functor, Arity), 
    52315243    '$lgt_lgt_closing_directive'(Functor, Arity), 
     
    52405252    !. 
    52415253 
    5242 '$lgt_tr_directive'(Dir, Line, Input, Output) :-    % entity opening directive or entity directive 
     5254'$lgt_tr_directive'(Dir, Line, Input, Output) :-        % entity opening directive or entity directive 
    52435255    functor(Dir, Functor, Arity), 
    52445256    '$lgt_lgt_directive'(Functor, Arity), 
     
    52875299 
    52885300 
    5289 % '$lgt_tr_file_directive'(@nonvar) 
     5301% '$lgt_tr_file_directive'(@nonvar, +integer, @stream, @stream) 
    52905302% 
    52915303% translates file-level directives, i.e. directives that are not encapsulated in a Logtalk entity 
    52925304% error-checking is delegated in most cases to the back-end Prolog compiler 
    52935305 
    5294 '$lgt_tr_file_directive'(encoding(_)) :-        % the encoding/1 directive is already processed  
     5306'$lgt_tr_file_directive'(encoding(_), _, _, _) :-       % the encoding/1 directive is already processed  
    52955307    !. 
    52965308 
    5297 '$lgt_tr_file_directive'(ensure_loaded(File)) :- 
     5309'$lgt_tr_file_directive'(ensure_loaded(File), _, _, _) :- 
    52985310    !, 
    5299     ensure_loaded(File),                        % assume that ensure_loaded/1 is also a built-in predicate 
     5311    ensure_loaded(File),                                % assume that ensure_loaded/1 is also a built-in predicate 
    53005312    assertz('$lgt_pp_directive_'(ensure_loaded(File))). 
    53015313 
    5302 '$lgt_tr_file_directive'(initialization(Goal)) :- 
     5314'$lgt_tr_file_directive'(initialization(Goal), _, _, _) :- 
    53035315    !, 
    53045316    (   callable(Goal) -> 
     
    53075319    ). 
    53085320 
    5309 '$lgt_tr_file_directive'(op(Pr, Spec, Ops)) :-  % op/3 directives must be used during entity compilation 
    5310     !, 
    5311     op(Pr, Spec, Ops), 
     5321'$lgt_tr_file_directive'(op(Pr, Spec, Ops), _, _, _) :- 
     5322    !, 
     5323    op(Pr, Spec, Ops),                                  % op/3 directives must be used during entity compilation 
    53125324    assertz('$lgt_pp_directive_'(op(Pr, Spec, Ops))), 
    53135325    (   atom(Ops) -> 
     
    53175329    ). 
    53185330 
    5319 '$lgt_tr_file_directive'(set_prolog_flag(Flag, Value)) :- 
     5331'$lgt_tr_file_directive'(set_prolog_flag(Flag, Value), _, _, _) :- 
    53205332    !, 
    53215333    set_prolog_flag(Flag, Value), 
    53225334    assertz('$lgt_pp_directive_'(set_prolog_flag(Flag, Value))). 
    53235335 
    5324 '$lgt_tr_file_directive'(Dir) :- 
    5325     assertz('$lgt_pp_directive_'(Dir)).         % directive will be copied to the generated Prolog file 
     5336'$lgt_tr_file_directive'(Dir, _, _, _) :- 
     5337    assertz('$lgt_pp_directive_'(Dir)).                 % directive will be copied to the generated Prolog file 
    53265338 
    53275339 
     
    53525364    '$lgt_add_entity_file_properties'(start(Line), Obj), 
    53535365    '$lgt_save_file_op_table', 
    5354     '$lgt_tr_object_id'(Obj, static),                           % assume static object 
     5366    '$lgt_tr_object_id'(Obj, static),                   % assume static object 
    53555367    '$lgt_tr_object_relations'(Rels, Obj). 
    53565368 
     
    53855397    '$lgt_add_entity_file_properties'(start(Line), Ptc), 
    53865398    '$lgt_save_file_op_table', 
    5387     '$lgt_tr_protocol_id'(Ptc, static),                         % assume static protocol 
     5399    '$lgt_tr_protocol_id'(Ptc, static),                 % assume static protocol 
    53885400    '$lgt_tr_protocol_relations'(Rels, Ptc). 
    53895401 
     
    54195431    '$lgt_add_entity_file_properties'(start(Line), Ctg), 
    54205432    '$lgt_save_file_op_table', 
    5421     '$lgt_tr_category_id'(Ctg, static),                         % assume static category 
     5433    '$lgt_tr_category_id'(Ctg, static),                 % assume static category 
    54225434    '$lgt_tr_category_relations'(Rels, Ctg). 
    54235435 
     
    54475459 
    54485460'$lgt_tr_directive'(module, [Module, ExportList], Line, Input, Output) :- 
    5449     assertz('$lgt_pp_module_'(Module)),                         % remeber we are compiling a module 
     5461    assertz('$lgt_pp_module_'(Module)),                             % remeber we are compiling a module 
    54505462    '$lgt_report_compiling_entity'(module, Module), 
    5451     '$lgt_tr_object_id'(Module, static),                        % assume static module/object 
     5463    '$lgt_tr_object_id'(Module, static),                            % assume static module/object 
    54525464    '$lgt_tr_directive'((public), ExportList, Line, Input, Output), % make the export list public predicates 
    54535465    '$lgt_save_file_op_table'.