Changeset 5270

Show
Ignore:
Timestamp:
01/30/10 10:11:21 (6 weeks ago)
Author:
pmoura
Message:

Added a '$lgt_tr_predicate_heads'/3 hook predicate to the Logtalk compiler in order to simplify handling of proprietary directives in config files.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r5267 r5270  
    1336813368 
    1336913369 
    13370 % '$lgt_tr_predicate_heads'(@callable, -callable) 
    13371 % 
    13372 % translates a single predicate head, a conjunction of predicate heads, or a 
    13373 % list of predicate heads; used as a hook predicate in the config files 
    13374      
    13375 '$lgt_tr_predicate_heads'(Head, _) :- 
     13370% '$lgt_tr_predicate_heads'(@callable, -callable, @term) 
     13371% 
     13372% translates a single predicate head, a conjunction of predicate heads, or 
     13373% a list of predicate heads; used mainly as a hook predicate in the config 
     13374% files for processing proprietary directives 
     13375 
     13376'$lgt_tr_predicate_heads'(Head, _, _) :- 
    1337613377    var(Head), 
    1337713378    throw(instantiation_error). 
    13378 '$lgt_tr_predicate_heads'([], []) :- 
     13379'$lgt_tr_predicate_heads'([], [], _) :- 
    1337913380    !. 
    13380 '$lgt_tr_predicate_heads'([Head| Heads], [THead| THeads]) :- 
    13381     !, 
    13382     '$lgt_tr_predicate_heads'(Head, THead), 
    13383     '$lgt_tr_predicate_heads'(Heads, THeads). 
    13384 '$lgt_tr_predicate_heads'((Head, Heads), (THead, THeads)) :- 
    13385     !, 
    13386     '$lgt_tr_predicate_heads'(Head, THead), 
    13387     '$lgt_tr_predicate_heads'(Heads, THeads). 
    13388 '$lgt_tr_predicate_heads'(Head, THead) :- 
     13381'$lgt_tr_predicate_heads'([Head| Heads], [THead| THeads], Context) :- 
     13382    !, 
     13383    '$lgt_tr_predicate_heads'(Head, THead, Context), 
     13384    '$lgt_tr_predicate_heads'(Heads, THeads, Context). 
     13385'$lgt_tr_predicate_heads'((Head, Heads), (THead, THeads), Context) :- 
     13386    !, 
     13387    '$lgt_tr_predicate_heads'(Head, THead, Context), 
     13388    '$lgt_tr_predicate_heads'(Heads, THeads, Context). 
     13389'$lgt_tr_predicate_heads'(Head, THead, Context) :- 
    1338913390    functor(Head, Functor, Arity), 
    1339013391    '$lgt_pp_entity'(_, _, Prefix, _, _), 
     
    1339313394    Head =.. [Functor| Args], 
    1339413395    THead =.. [TFunctor| Targs], 
    13395     '$lgt_append'(Args, [_], Targs). 
     13396    '$lgt_append'(Args, [Context], Targs). 
     13397 
     13398 
     13399'$lgt_tr_predicate_heads'(Heads, THeads) :- 
     13400    '$lgt_tr_predicate_heads'(Heads, THeads, _). 
    1339613401 
    1339713402 
     
    1340013405% '$lgt_tr_predicate_indicators'(+predicate_indicator, -predicate_indicator) 
    1340113406% 
    13402 % translates a single predicate indicator, a conjunction of predicate indicators, or a 
    13403 % list of predicate indicators; used as a hook predicate in the config files 
     13407% translates a single predicate indicator, a conjunction of predicate indicators, or 
     13408% a list of predicate indicators; used mainly as a hook predicate in the config files 
     13409% for processing proprietary directives 
    1340413410 
    1340513411'$lgt_tr_predicate_indicators'(PI, _) :- 
  • trunk/configs/b.pl

    r5268 r5270  
    533533    '$lgt_tr_predicate_indicators'(PIs, CPIs). 
    534534'$lgt_rewrite_and_copy_pl_directive'(table(':'(Head, N)), table(':'(THead, N))) :- 
    535     '$lgt_rewrite_and_copy_pl_directive_head'(Head, THead). 
     535    !, 
     536    '$lgt_tr_predicate_heads'(Head, THead, '-'). 
    536537'$lgt_rewrite_and_copy_pl_directive'(table(PIs), table(CPIs)) :- 
    537538    '$lgt_tr_predicate_indicators'(PIs, CPIs). 
    538 '$lgt_rewrite_and_copy_pl_directive'(mode(Pred), mode(TPred)) :- 
    539     functor(Pred, Functor, Arity), 
    540     '$lgt_tr_predicate_indicators'(Functor/Arity, TFunctor/TArity), 
    541     functor(TPred, TFunctor, TArity), 
    542     Pred =.. [Functor| Args], 
    543     TPred =.. [TFunctor| TArgs], 
    544     append(Args, ['?'], TArgs). 
    545  
    546  
    547 '$lgt_rewrite_and_copy_pl_directive_head'(Head, _) :- 
    548     var(Head), 
    549     throw(instantiation_error). 
    550 '$lgt_rewrite_and_copy_pl_directive_head'(Head, THead) :- 
    551     functor(Head, Functor, Arity), 
    552     \+ (Functor == '/', Arity =:= 2),   % not a predicate indicator 
    553     '$lgt_tr_predicate_indicators'(Functor/Arity, TFunctor/TArity), 
    554     functor(THead, TFunctor, TArity), 
    555     Head =.. [_| Args], 
    556     THead =.. [_| TArgs], 
    557     append(Args, ['-'], TArgs). 
     539'$lgt_rewrite_and_copy_pl_directive'(mode(Head), mode(THead)) :- 
     540    '$lgt_tr_predicate_heads'(Head, THead, '?'). 
    558541 
    559542 
  • trunk/configs/swi.pl

    r5267 r5270  
    583583    '$lgt_tr_predicate_indicators'(PIs, CPIs). 
    584584'$lgt_rewrite_and_copy_pl_directive'(index(Head), index(THead)) :- 
    585     '$lgt_tr_predicate_heads'(Head, THead), 
    586     Head =..  [_|  Args], 
    587     THead =.. [_| TArgs], 
    588     '$lgt_append'(Args, [0], TArgs). 
     585    '$lgt_tr_predicate_heads'(Head, THead, 0). 
    589586'$lgt_rewrite_and_copy_pl_directive'(hash(Head), hash(THead)) :- 
    590587    '$lgt_tr_predicate_heads'(Head, THead). 
  • trunk/RELEASE_NOTES.txt

    r5269 r5270  
    2929    all config files. 
    3030 
    31     Added '$lgt_tr_predicate_heads'/2 and '$lgt_tr_predicate_indicators'/2 
    32     hook predicates to the Logtalk compiler in order to simplify handling 
    33     of proprietary directives in config files. 
     31    Added '$lgt_tr_predicate_indicators'/2, '$lgt_tr_predicate_heads'/2, and 
     32    '$lgt_tr_predicate_heads'/3 hook predicates to the Logtalk compiler in 
     33    order to simplify handling of proprietary directives in config files. 
    3434 
    3535    Added support for the proprietary directive eager_consume/0 to the config