Changeset 4598 for trunk/compiler

Show
Ignore:
Timestamp:
11/20/08 17:49:29 (7 weeks ago)
Author:
pmoura
Message:

Updated the compilation of the if/1 and elif/1 directives in order to apply any existing goal expansion hook to their arguments.

Corrected a bug that prevented goal expansion of source file initialization goals (expressed using the initialization/1 directive).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4592 r4598  
    52645264 
    52655265 
     5266% '$lgt_tr_expand_goal'(+callable, -callable) 
     5267% 
     5268% expands a goal; fails if no goal expansion hook is defined 
     5269 
     5270'$lgt_tr_expand_goal'(Goal, EGoal) :-   % source-file specific compiler hook 
     5271    '$lgt_pp_hook_goal_expansion_'(Goal, EGoal), 
     5272    !. 
     5273 
     5274'$lgt_tr_expand_goal'(Goal, EGoal) :-   % default compiler hook 
     5275    '$lgt_hook_goal_expansion_'(Goal, EGoal), 
     5276    !. 
     5277 
     5278 
     5279 
    52665280% '$lgt_tr_term'(+term, +integer, @stream, @stream) 
    52675281% 
     
    53455359    \+ callable(Goal), 
    53465360    throw(error(type_error(callable, Goal), directive(if(Goal)))). 
     5361 
     5362'$lgt_tr_directive'(if(Goal), Line, Input, Output) :- 
     5363    '$lgt_tr_expand_goal'(Goal, EGoal), 
     5364    !, 
     5365    '$lgt_tr_directive'(if(EGoal), Line, Input, Output). 
    53475366 
    53485367'$lgt_tr_directive'(if(Goal), _, Input, _) :- 
     
    53825401    \+ '$lgt_pp_cc_if_found_'(_), 
    53835402    throw(error(unmatched_directive, directive(elif(Goal)))). 
     5403 
     5404'$lgt_tr_directive'(elif(Goal), Line, Input, Output) :- 
     5405    '$lgt_tr_expand_goal'(Goal, EGoal), 
     5406    !, 
     5407    '$lgt_tr_directive'(elif(EGoal), Line, Input, Output). 
    53845408 
    53855409'$lgt_tr_directive'(elif(Goal), _, Input, _) :- 
     
    55235547    ensure_loaded(File),                                % assume that ensure_loaded/1 is also a built-in predicate 
    55245548    assertz('$lgt_pp_directive_'(ensure_loaded(File))). 
     5549 
     5550'$lgt_tr_file_directive'(initialization(Goal), Line, Input, Output) :- 
     5551    '$lgt_tr_expand_goal'(Goal, EGoal), 
     5552    !, 
     5553    '$lgt_tr_file_directive'(initialization(EGoal), Line, Input, Output). 
    55255554 
    55265555'$lgt_tr_file_directive'(initialization(Goal), _, _, _) :-