Changeset 4434 for trunk/compiler

Show
Ignore:
Timestamp:
08/19/08 05:02:08 (5 months ago)
Author:
pmoura
Message:

Added support for using the ensure_loaded/1 and the set_prolog_flag/2 directives in source files. These directives are both processed when read (thus affecting the compilation of the source code that follows) and copied to the generated intermediate Prolog files.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4431 r4434  
    52055205 
    52065206% '$lgt_tr_file_directive'(@nonvar) 
    5207  
    5208 '$lgt_tr_file_directive'(op(Pr, Spec, Ops)) :-  % op/3 directives must be used during entity compilation 
    5209     !, 
    5210     (   '$lgt_valid_op_priority'(Pr) -> 
    5211         (   '$lgt_valid_op_specifier'(Spec) -> 
    5212             (   '$lgt_valid_op_names'(Ops) -> 
    5213                 assertz('$lgt_pp_directive_'(op(Pr, Spec, Ops))), 
    5214                 assertz('$lgt_pp_file_op_'(op(Pr, Spec, Ops))), 
    5215                 op(Pr, Spec, Ops) 
    5216             ;   throw(type_error(operator_name, Ops)) 
    5217             ) 
    5218         ;   throw(type_error(operator_specifier, Spec)) 
    5219         ) 
    5220     ;   throw(type_error(operator_priority, Pr)) 
    5221     ). 
     5207% 
     5208% translates file-level directives, i.e. directives that are not encapsulated in a Logtalk entity 
     5209% error-checking is delegated to the back-end Prolog compiler 
     5210 
     5211'$lgt_tr_file_directive'(encoding(_)) :-        % the encoding/1 directive is already processed  
     5212    !. 
     5213 
     5214'$lgt_tr_file_directive'(ensure_loaded(File)) :- 
     5215    !, 
     5216    ensure_loaded(File),                        % assume that ensure_loaded/1 is also a built-in predicate 
     5217    assertz('$lgt_pp_directive_'(ensure_loaded(File))). 
    52225218 
    52235219'$lgt_tr_file_directive'(initialization(Goal)) :- 
     
    52285224    ). 
    52295225 
    5230 '$lgt_tr_file_directive'(encoding(_)) :-        % the encoding/1 directive is already processed  
    5231     !. 
     5226'$lgt_tr_file_directive'(op(Pr, Spec, Ops)) :-  % op/3 directives must be used during entity compilation 
     5227    !, 
     5228    op(Pr, Spec, Ops), 
     5229    assertz('$lgt_pp_directive_'(op(Pr, Spec, Ops))), 
     5230    assertz('$lgt_pp_file_op_'(op(Pr, Spec, Ops))). 
     5231 
     5232'$lgt_tr_file_directive'(set_prolog_flag(Flag, Value)) :- 
     5233    !, 
     5234    set_prolog_flag(Flag, Value), 
     5235    assertz('$lgt_pp_directive_'(set_prolog_flag(Flag, Value))). 
    52325236 
    52335237'$lgt_tr_file_directive'(Dir) :-