Show
Ignore:
Timestamp:
05/23/08 09:49:25 (6 months ago)
Author:
pmoura
Message:

Generalized the :/1 control construct to allow its use from within categories that extend other categories.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4269 r4270  
    31543154 
    31553155 
    3156 % '$lgt_call_ctg_pred'(+atom, +atom, +callable, +object_identifier, +object_identifier, +object_identifier) 
    3157 % 
    3158 % calls a category predicate directly, without using the message sending mechanism 
    3159  
    3160 '$lgt_call_ctg_pred'(Dcl, Def, Pred, Sender, This, Self) :- 
     3156% '$lgt_call_pred_from_this'(+atom, +object_identifier, +atom, +atom, +callable, +object_identifier, +object_identifier, +object_identifier) 
     3157% '$lgt_call_pred_from_this'(+atom, +category_identifier, +atom, +atom, +callable, +object_identifier, +object_identifier, +object_identifier) 
     3158% 
     3159% calls a predicate from "this", without using the message sending mechanism 
     3160% prevent loops by ensuring that we look for an inherited or imported definition 
     3161 
     3162'$lgt_call_pred_from_this'(object, Obj, Dcl, Def, Pred, Sender, This, Self) :- 
    31613163    (   call_with_args(Dcl, Pred, _, _, _, _, _, _, _) -> 
    3162         (   '$lgt_imports_category_'(This, Ctg, _), 
    3163             call_with_args(Def, Pred, Sender, This, Self, Call, Ctg) -> 
     3164        (   call_with_args(Def, Pred, Sender, This, Self, Call, Ctn), Obj \= Ctn -> 
     3165            call(Call) 
     3166        ) 
     3167    ;   throw(error(existence_error(predicate_declaration, Pred), ':'(Pred), This)) 
     3168    ). 
     3169 
     3170'$lgt_call_pred_from_this'(category, Ctg, Dcl, Def, Pred, Sender, This, Self) :- 
     3171    (   call_with_args(Dcl, Pred, _, _, _, _, _, _) -> 
     3172        (   call_with_args(Def, Pred, Sender, This, Self, Call, Ctn), Ctg \= Ctn -> 
    31643173            call(Call) 
    31653174        ) 
     
    69246933'$lgt_tr_body'(':'(Pred), _, _, _) :- 
    69256934    \+ '$lgt_pp_imported_category_'(_, _, _, _, _), 
     6935    \+ '$lgt_pp_extended_category_'(_, _, _, _, _), 
     6936    \+ '$lgt_pp_extended_object_'(_, _, _, _, _, _, _, _, _, _), 
     6937    \+ '$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _), 
     6938    \+ '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _), 
    69266939    throw(existence_error(procedure, Pred)). 
    69276940 
    69286941'$lgt_tr_body'(':'(Alias), TPred, '$lgt_dbg_goal'(':'(Alias), TPred, DbgCtx), Ctx) :- 
     6942    '$lgt_pp_object_'(Obj, _, Dcl, Def, _, IDcl, IDef, _, _, _, _), 
    69296943    !, 
    69306944    '$lgt_ctx_ctx'(Ctx, _, Sender, This, Self, _, _, _), 
     
    69386952        true 
    69396953    ;   Pred = Alias, 
    6940         '$lgt_pp_object_'(_, _, Dcl, Def, _, IDcl, _, _, _, _, _), 
    69416954        (   ('$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _); '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _)) -> 
    6942             TPred = '$lgt_call_ctg_pred'(IDcl, Def, Pred, Sender, This, Self) 
    6943         ;   TPred = '$lgt_call_ctg_pred'(Dcl, Def, Pred, Sender, This, Self) 
     6955            TPred = '$lgt_call_pred_from_this'(object, Obj, IDcl, IDef, Pred, Sender, This, Self) 
     6956        ;   TPred = '$lgt_call_pred_from_this'(object, Obj, Dcl, Def, Pred, Sender, This, Self) 
    69446957        ) 
     6958    ). 
     6959 
     6960'$lgt_tr_body'(':'(Alias), TPred, '$lgt_dbg_goal'(':'(Alias), TPred, DbgCtx), Ctx) :- 
     6961    '$lgt_pp_category_'(Ctg, _, Dcl, Def, _, _), 
     6962    '$lgt_ctx_ctx'(Ctx, _, Sender, This, Self, _, _, _), 
     6963    '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
     6964    (   '$lgt_pp_extended_category_'(Ctg2, _, _, _, _), 
     6965        (   '$lgt_pp_alias_'(Ctg2, Pred, Alias) -> 
     6966            true 
     6967        ;   Pred = Alias 
     6968        ), 
     6969        '$lgt_ctg_static_binding_cache'(Ctg2, Pred, Sender, This, Self, TPred) -> 
     6970        true 
     6971    ;   Pred = Alias, 
     6972        TPred = '$lgt_call_pred_from_this'(category, Ctg, Dcl, Def, Pred, Sender, This, Self) 
    69456973    ). 
    69466974