Show
Ignore:
Timestamp:
05/23/08 15:12:42 (6 months ago)
Author:
pmoura
Message:

Fixed a Logtalk runtime bug when using the :/1 control construct to call a predicate defined in a category extended by a category that is imported by the object making the call. Reverted the changes that allowed the use of the :/1 control construct within categories that extend other categories.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4270 r4271  
    4141 
    4242 
    43 % category predicate direct call operator 
     43% imported/inherited predicate call operator 
    4444 
    4545:- op(600,  fy,  :). 
     
    6565 
    6666:- dynamic('$lgt_current_protocol_'/3).         % '$lgt_current_protocol_'(Ptc, Prefix, Type) 
    67 :- dynamic('$lgt_current_category_'/4).         % '$lgt_current_category_'(Ctg, Prefix, Type, Synchronized) 
     67:- dynamic('$lgt_current_category_'/5).         % '$lgt_current_category_'(Ctg, Prefix, Def, Type, Synchronized) 
    6868:- dynamic('$lgt_current_object_'/8).           % '$lgt_current_object_'(Obj, Prefix, Dcl, Def, Super, Type, Synchronized, Threaded) 
    6969                                                 
     
    314314    ;   '$lgt_extends_protocol_'(_, CtgOrPtc, _), \+ '$lgt_current_protocol_'(CtgOrPtc, _, _) -> 
    315315        throw(error(existence_error(protocol, CtgOrPtc), _, _)) 
    316     ;   '$lgt_imports_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _) -> 
     316    ;   '$lgt_imports_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _, _) -> 
    317317        throw(error(existence_error(category, CtgOrPtc), _, _)) 
    318     ;   '$lgt_extends_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _) -> 
     318    ;   '$lgt_extends_category_'(_, CtgOrPtc, _), \+ '$lgt_current_category_'(CtgOrPtc, _, _, _, _) -> 
    319319        throw(error(existence_error(category, CtgOrPtc), _, _)) 
    320320    ). 
     
    408408 
    409409current_category(Ctg) :- 
    410     '$lgt_current_category_'(Ctg, _, _, _). 
     410    '$lgt_current_category_'(Ctg, _, _, _, _). 
    411411 
    412412 
     
    452452 
    453453category_property(Ctg, Prop) :-             % static/dynamic property 
    454     '$lgt_current_category_'(Ctg, _, Prop, _). 
     454    '$lgt_current_category_'(Ctg, _, _, Prop, _). 
    455455 
    456456category_property(Ctg, synchronized) :- 
    457     '$lgt_current_category_'(Ctg, _, _, yes). 
     457    '$lgt_current_category_'(Ctg, _, _, _, yes). 
    458458 
    459459 
     
    491491 
    492492create_object(Obj, Rels, Dirs, Clauses) :- 
    493     '$lgt_current_category_'(Obj, _, _, _), 
     493    '$lgt_current_category_'(Obj, _, _, _, _), 
    494494    throw(error(permission_error(modify, category, Obj), create_object(Obj, Rels, Dirs, Clauses))). 
    495495 
     
    537537 
    538538create_category(Ctg, Rels, Dirs, Clauses) :- 
    539     '$lgt_current_category_'(Ctg, _, _, _), 
     539    '$lgt_current_category_'(Ctg, _, _, _, _), 
    540540    throw(error(permission_error(modify, category, Ctg), create_category(Ctg, Rels, Dirs, Clauses))). 
    541541 
     
    594594 
    595595create_protocol(Ptc, Rels, Dirs) :- 
    596     '$lgt_current_category_'(Ptc, _, _, _), 
     596    '$lgt_current_category_'(Ptc, _, _, _, _), 
    597597    throw(error(permission_error(modify, category, Ptc), create_protocol(Ptc, Rels, Dirs))). 
    598598 
     
    670670 
    671671abolish_category(Ctg) :- 
    672     (   '$lgt_current_category_'(Ctg, Prefix, Type, _) -> 
     672    (   '$lgt_current_category_'(Ctg, Prefix, _, Type, _) -> 
    673673        (   Type == (dynamic) -> 
    674674            call_with_args(Prefix, Dcl, Def, Rnm), 
     
    679679            abolish(Rnm/3), 
    680680            abolish(Prefix/3), 
    681             retractall('$lgt_current_category_'(Ctg, _, _, _)), 
     681            retractall('$lgt_current_category_'(Ctg, _, _, _, _)), 
    682682            retractall('$lgt_extends_category_'(Ctg, _, _)), 
    683683            retractall('$lgt_implements_protocol_'(Ctg, _, _)), 
     
    19631963'$lgt_alias_pred'(Ctg1, _, Alias, Pred, _) :- 
    19641964    '$lgt_extends_category_'(Ctg1, Ctg2, _), 
    1965     '$lgt_current_category_'(Ctg2, Prefix, _, _), 
     1965    '$lgt_current_category_'(Ctg2, Prefix, _, _, _), 
    19661966    '$lgt_alias_pred'(Ctg2, Prefix, Alias, Pred, _). 
    19671967 
    19681968'$lgt_alias_pred'(Obj, _, Alias, Pred, _) :- 
    19691969    '$lgt_imports_category_'(Obj, Ctg, _), 
    1970     '$lgt_current_category_'(Ctg, Prefix, _, _), 
     1970    '$lgt_current_category_'(Ctg, Prefix, _, _, _), 
    19711971    '$lgt_alias_pred'(Ctg, Prefix, Alias, Pred, _). 
    19721972 
     
    31543154 
    31553155 
    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) :- 
     3156% '$lgt_call_ctg_pred'(+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, Pred, Sender, This, Self) :- 
    31633161    (   call_with_args(Dcl, Pred, _, _, _, _, _, _, _) -> 
    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 -> 
     3162        (   '$lgt_imports_category_'(This, Ctg, _), 
     3163            '$lgt_current_category_'(Ctg, _, Def, _, _), 
     3164            call_with_args(Def, Pred, Sender, This, Self, Call, _) -> 
    31733165            call(Call) 
    31743166        ) 
     
    33313323 
    33323324'$lgt_hidden_functor'(Functor) :- 
    3333     '$lgt_current_category_'(_, Prefix, _, _), 
     3325    '$lgt_current_category_'(_, Prefix, _, _, _), 
    33343326    atom_concat(Prefix, _, Functor), 
    33353327    !. 
     
    40734065 
    40744066'$lgt_redefined_entity'(Entity, category) :- 
    4075     '$lgt_current_category_'(Entity, _, _, _). 
     4067    '$lgt_current_category_'(Entity, _, _, _, _). 
    40764068 
    40774069 
     
    49294921    !. 
    49304922 
    4931 '$lgt_pp_rclause'('$lgt_current_category_'(Ctg, Prefix, Mode, Synchronized)) :- 
    4932     '$lgt_pp_category_'(Ctg, Prefix, _, _, _, Mode), 
     4923'$lgt_pp_rclause'('$lgt_current_category_'(Ctg, Prefix, Def, Mode, Synchronized)) :- 
     4924    '$lgt_pp_category_'(Ctg, Prefix, _, Def, _, Mode), 
    49334925    (   '$lgt_pp_synchronized_' -> 
    49344926        Synchronized = yes 
     
    69336925'$lgt_tr_body'(':'(Pred), _, _, _) :- 
    69346926    \+ '$lgt_pp_imported_category_'(_, _, _, _, _), 
    6935     \+ '$lgt_pp_extended_category_'(_, _, _, _, _), 
    6936     \+ '$lgt_pp_extended_object_'(_, _, _, _, _, _, _, _, _, _), 
    6937     \+ '$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _), 
    6938     \+ '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _), 
    69396927    throw(existence_error(procedure, Pred)). 
    69406928 
    69416929'$lgt_tr_body'(':'(Alias), TPred, '$lgt_dbg_goal'(':'(Alias), TPred, DbgCtx), Ctx) :- 
    6942     '$lgt_pp_object_'(Obj, _, Dcl, Def, _, IDcl, IDef, _, _, _, _), 
    6943     !, 
    69446930    '$lgt_ctx_ctx'(Ctx, _, Sender, This, Self, _, _, _), 
    69456931    '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
     
    69526938        true 
    69536939    ;   Pred = Alias, 
     6940        '$lgt_pp_object_'(_, _, Dcl, _, _, IDcl, _, _, _, _, _), 
    69546941        (   ('$lgt_pp_instantiated_class_'(_, _, _, _, _, _, _, _, _, _); '$lgt_pp_specialized_class_'(_, _, _, _, _, _, _, _, _, _)) -> 
    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) 
     6942            TPred = '$lgt_call_ctg_pred'(IDcl, Pred, Sender, This, Self) 
     6943        ;   TPred = '$lgt_call_ctg_pred'(Dcl, Pred, Sender, This, Self) 
    69576944        ) 
    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) 
    69736945    ). 
    69746946 
     
    88018773'$lgt_unknown_category'(Ctg) :- 
    88028774    '$lgt_pp_referenced_category_'(Ctg), 
    8803     \+ '$lgt_current_category_'(Ctg, _, _, _),      % not a currently loaded category 
     8775    \+ '$lgt_current_category_'(Ctg, _, _, _, _),   % not a currently loaded category 
    88048776    \+ '$lgt_pp_category_'(Ctg, _, _, _, _, _),     % not the category being compiled (self references) 
    88058777    \+ '$lgt_pp_entity_init_'(category, Ctg, _).    % not a category defined in the source file being compiled 
     
    1063110603    retractall('$lgt_current_object_'(Entity, _, _, _, _, _, _, _)), 
    1063210604    retractall('$lgt_current_protocol_'(Entity, _, _)), 
    10633     retractall('$lgt_current_category_'(Entity, _, _, _)), 
     10605    retractall('$lgt_current_category_'(Entity, _, _, _, _)), 
    1063410606    retractall('$lgt_implements_protocol_'(Entity, _, _)), 
    1063510607    retractall('$lgt_imports_category_'(Entity, _, _)), 
     
    1069810670'$lgt_construct_category_functors'(Ctg, Prefix, Dcl, Def, Rnm) :- 
    1069910671    (   '$lgt_built_in_category'(Ctg) -> 
    10700         '$lgt_current_category_'(Ctg, Prefix, _, _), 
     10672        '$lgt_current_category_'(Ctg, Prefix, _, _, _), 
    1070110673        Call =.. [Prefix, Dcl, Def, Rnm], 
    1070210674        once(Call) 
     
    1074710719    (   '$lgt_current_object_'(Entity, Prefix, _, _, _, _, _, _), 
    1074810720        Type = object 
    10749     ;   '$lgt_current_category_'(Entity, Prefix, _, _), 
     10721    ;   '$lgt_current_category_'(Entity, Prefix, _, _, _), 
    1075010722        Type = category 
    1075110723    ), 
     
    1335813330        true 
    1335913331    ;   '$lgt_static_binding_entity_'(Ctg), 
    13360         '$lgt_current_category_'(Ctg, Prefix, _, _), 
     13332        '$lgt_current_category_'(Ctg, Prefix, _, _, _), 
    1336113333        Clause =.. [Prefix, Dcl, Def, _], 
    1336213334        call(Clause),