Show
Ignore:
Timestamp:
06/26/09 18:43:49 (14 months ago)
Author:
pmoura
Message:

Corrected a bug when compiling an object or category normal predicate that redefines a built-in Prolog meta-predicate.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r5047 r5048  
    36293629 
    36303630 
    3631 % '$lgt_call_built_in'(+callable, +execution_context) 
     3631% '$lgt_call_built_in'(+callable, +callable, +execution_context) 
    36323632% 
    36333633% needed for runtime translation of dynamic clauses, for dealing 
    36343634% with meta-calls that turn out to be calls to built-in predicates, 
    36353635% and for dealing with <</2 calls to redefined built-in predicates 
    3636  
    3637 '$lgt_call_built_in'(Pred, ExCtx) :- 
     3636% 
     3637% the first argument, Pred, is the original predicate call, while the second 
     3638% argument, MetaExPred, is equal to the first argument for normal predicates 
     3639% but is meta-argument expanded for non-redefined built-in meta-predicates 
     3640 
     3641'$lgt_call_built_in'(Pred, MetaExPred, ExCtx) :- 
    36383642    (   '$lgt_exec_ctx'(ExCtx, This, _), 
    36393643        '$lgt_current_object_'(This, _, _, Def, _, _, _, _, DDef, _, _), 
     
    36453649        ) 
    36463650    ;   % call the built-in predicate: 
    3647         call(Pred) 
     3651        call(MetaExPred) 
    36483652    ). 
    36493653 
     
    91549158% Prolog proprietary, built-in meta-predicates 
    91559159 
    9156 '$lgt_tr_body'(Pred, '$lgt_call_built_in'(TPred, ExCtx), DPred, Ctx) :- 
     9160'$lgt_tr_body'(Pred, '$lgt_call_built_in'(Pred, TPred, ExCtx), DPred, Ctx) :- 
    91579161    '$lgt_pl_built_in'(Pred), 
    91589162    functor(Pred, Functor, Arity), 
     
    91829186    (   Type == control_construct -> 
    91839187        DGoal =.. [Functor| DArgs], 
    9184         DPred = '$lgt_call_built_in'(DGoal, Ctx) 
    9185     ;   DPred = '$lgt_dbg_goal'(Pred, '$lgt_call_built_in'(TPred, ExCtx), ExCtx) 
     9188        DPred = '$lgt_call_built_in'(Pred, DGoal, Ctx) 
     9189    ;   DPred = '$lgt_dbg_goal'(Pred, '$lgt_call_built_in'(Pred, TPred, ExCtx), ExCtx) 
    91869190    ). 
    91879191 
     
    91899193% Logtalk and Prolog built-in predicates 
    91909194 
    9191 '$lgt_tr_body'(Pred, '$lgt_call_built_in'(Pred, ExCtx), '$lgt_dbg_goal'(Pred, '$lgt_call_built_in'(Pred, ExCtx), ExCtx), Ctx) :- 
     9195'$lgt_tr_body'(Pred, '$lgt_call_built_in'(Pred, Pred, ExCtx), '$lgt_dbg_goal'(Pred, '$lgt_call_built_in'(Pred, Pred, ExCtx), ExCtx), Ctx) :- 
    91929196    '$lgt_built_in'(Pred), 
    91939197    functor(Pred, Functor, Arity), 
     
    1212712131    TPred =.. [Functor| TArgs]. 
    1212812132 
    12129 '$lgt_fix_pred_calls'('$lgt_call_built_in'(Pred, ExCtx), TPred) :- 
    12130     !,                                  % calls to Logtalk and Prolog built-in predicates 
     12133'$lgt_fix_pred_calls'('$lgt_call_built_in'(Pred, MetaExPred, ExCtx), TPred) :- 
     12134    !,                                  % calls to Logtalk and Prolog built-in (meta-)predicates 
    1213112135    (   '$lgt_pp_redefined_built_in_'(Pred, ExCtx, TPred) -> 
    1213212136        true 
    12133     ;   '$lgt_fix_pred_calls'(Pred, TPred) 
     12137    ;   '$lgt_fix_pred_calls'(MetaExPred, TPred) 
    1213412138    ). 
    1213512139 
     
    1220412208    \+ '$lgt_pp_defs_nt_'(Functor, Arity),                  % non-terminal not defined in object/category and 
    1220512209    ExtArity is Arity + 2, 
    12206     \+ '$lgt_pp_defs_pred_'(Functor, ExtArity),     % no corresponding predicate is defined 
    12207     \+ '$lgt_pp_dynamic_'(Functor, ExtArity),           % no dynamic directive for the corresponding predicate  
    12208     once((  '$lgt_pp_public_'(Functor, ExtArity)        % but there is a scope directive for the non-terminal  
    12209         ;   '$lgt_pp_protected_'(Functor, ExtArity) % or the corresponding predicate  
     12210    \+ '$lgt_pp_defs_pred_'(Functor, ExtArity),             % no corresponding predicate is defined 
     12211    \+ '$lgt_pp_dynamic_'(Functor, ExtArity),               % no dynamic directive for the corresponding predicate  
     12212    once((  '$lgt_pp_public_'(Functor, ExtArity)            % but there is a scope directive for the non-terminal  
     12213        ;   '$lgt_pp_protected_'(Functor, ExtArity)         % or the corresponding predicate  
    1221012214        ;   '$lgt_pp_private_'(Functor, ExtArity) 
    1221112215    )).