Show
Ignore:
Timestamp:
10/04/08 08:30:04 (3 months ago)
Author:
pmoura
Message:

Improved the Logtalk built-in debugger to print clause numbers for static predicates at the unification ports ("fact" and "rule").

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4474 r4480  
    21842184            (   '$lgt_debugging_'(Obj) -> 
    21852185                '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
    2186                 asserta((THead :- ('$lgt_nop'(Body), '$lgt_dbg_head'(Head, DbgCtx), DBody))) 
     2186                asserta((THead :- ('$lgt_nop'(Body), '$lgt_dbg_head'(Head, 0, DbgCtx), DBody))) 
    21872187            ;   asserta((THead :- ('$lgt_nop'(Body), TBody))) 
    21882188            ) 
     
    22162216                '$lgt_ctx_ctx'(Ctx, _, GSender, GThis, GSelf, Prefix, [], _), 
    22172217                '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
    2218                 asserta((THead :- '$lgt_dbg_fact'(Head, DbgCtx))) 
     2218                asserta((THead :- '$lgt_dbg_fact'(Head, 0, DbgCtx))) 
    22192219            ;   '$lgt_add_db_lookup_cache_entry'(Obj, Head, SCtn, DclScope, Sender, THead, DDef, Update), 
    22202220                asserta(THead) 
     
    22862286            (   '$lgt_debugging_'(Obj) -> 
    22872287                '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
    2288                 assertz((THead :- ('$lgt_nop'(Body), '$lgt_dbg_head'(Head, DbgCtx), DBody))) 
     2288                assertz((THead :- ('$lgt_nop'(Body), '$lgt_dbg_head'(Head, 0, DbgCtx), DBody))) 
    22892289            ;   assertz((THead :- ('$lgt_nop'(Body), TBody))) 
    22902290            ) 
     
    23182318                '$lgt_ctx_ctx'(Ctx, _, GSender, GThis, GSelf, Prefix, [], _), 
    23192319                '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
    2320                 assertz((THead :- '$lgt_dbg_fact'(Head, DbgCtx))) 
     2320                assertz((THead :- '$lgt_dbg_fact'(Head, 0, DbgCtx))) 
    23212321            ;   '$lgt_add_db_lookup_cache_entry'(Obj, Head, SCtn, DclScope, Sender, THead, DDef, Update), 
    23222322                assertz(THead) 
     
    24012401    (   TBody = ('$lgt_nop'(Body), _) ->    % rules (compiled both in normal and debug mode) 
    24022402        true 
    2403     ;   TBody = '$lgt_dbg_fact'(_, _) ->    % facts compiled in debug mode 
     2403    ;   TBody = '$lgt_dbg_fact'(_, _, _) -> % facts compiled in debug mode 
    24042404        Body = true 
    24052405    ;   TBody = Body                        % facts compiled in normal mode 
     
    24162416                    (   TBody = ('$lgt_nop'(Body), _) -> 
    24172417                        true 
    2418                     ;   TBody = '$lgt_dbg_fact'(_, _) -> 
     2418                    ;   TBody = '$lgt_dbg_fact'(_, _, _) -> 
    24192419                        Body = true 
    24202420                    ;   TBody = Body 
     
    24352435            (   TBody = ('$lgt_nop'(Body), _) -> 
    24362436                true 
    2437             ;   TBody = '$lgt_dbg_fact'(_, _) -> 
     2437            ;   TBody = '$lgt_dbg_fact'(_, _, _) -> 
    24382438                Body = true 
    24392439            ;   TBody = Body 
     
    24892489                    (   TBody = ('$lgt_nop'(Body), _) -> 
    24902490                        true 
    2491                     ;   TBody = '$lgt_dbg_fact'(_, _) -> 
     2491                    ;   TBody = '$lgt_dbg_fact'(_, _, _) -> 
    24922492                        Body = true 
    24932493                    ;   TBody = Body 
     
    24982498                    (   TBody = ('$lgt_nop'(Body), _) -> 
    24992499                        true 
    2500                     ;   TBody = '$lgt_dbg_fact'(_, _) -> 
     2500                    ;   TBody = '$lgt_dbg_fact'(_, _, _) -> 
    25012501                        Body = true 
    25022502                    ;   TBody = Body 
     
    25182518            (   TBody = ('$lgt_nop'(Body), _) -> 
    25192519                true 
    2520             ;   TBody = '$lgt_dbg_fact'(_, _) -> 
     2520            ;   TBody = '$lgt_dbg_fact'(_, _, _) -> 
    25212521                Body = true 
    25222522            ;   TBody = Body 
     
    25772577                (   call_with_args(DDef, Head, _, _, _, Call) -> 
    25782578                    (   '$lgt_debugging_'(Obj) -> 
    2579                         retract((Call :- '$lgt_dbg_fact'(_, _))) 
     2579                        retract((Call :- '$lgt_dbg_fact'(_, _, _))) 
    25802580                    ;   '$lgt_add_db_lookup_cache_entry'(Obj, Head, SCtn, PScope, Sender, Call, DDef, true), 
    25812581                        retract(Call) 
     
    25842584                ;   call_with_args(Def, Head, _, _, _, Call) -> 
    25852585                    (   '$lgt_debugging_'(Obj) -> 
    2586                         retract((Call :- '$lgt_dbg_fact'(_, _))) 
     2586                        retract((Call :- '$lgt_dbg_fact'(_, _, _))) 
    25872587                    ;   '$lgt_add_db_lookup_cache_entry'(Obj, Head, PScope, Sender, Call), 
    25882588                        retract(Call) 
     
    26012601        (   call_with_args(DDef, Head, _, _, _, Call) -> 
    26022602            (   '$lgt_debugging_'(Obj) -> 
    2603                 retract((Call :- '$lgt_dbg_fact'(_, _))) 
     2603                retract((Call :- '$lgt_dbg_fact'(_, _, _))) 
    26042604            ;   '$lgt_add_db_lookup_cache_entry'(Obj, Head, p, Sender, Call), 
    26052605                retract(Call) 
     
    37743774 
    37753775 
    3776 '$lgt_dbg_fact'(Fact, DbgCtx) :- 
     3776'$lgt_dbg_fact'(Fact, N, DbgCtx) :- 
    37773777    (   '$lgt_dbg_debugging_', \+ '$lgt_dbg_skipping_' -> 
    3778         '$lgt_dbg_port'(fact, Fact, _, DbgCtx, Action), 
     3778        '$lgt_dbg_port'(fact(N), Fact, _, DbgCtx, Action), 
    37793779        call(Action) 
    37803780    ;   true 
     
    37823782 
    37833783 
    3784 '$lgt_dbg_head'(Head, DbgCtx) :- 
     3784'$lgt_dbg_head'(Head, N, DbgCtx) :- 
    37853785    (   '$lgt_dbg_debugging_', \+ '$lgt_dbg_skipping_' -> 
    3786         '$lgt_dbg_port'(rule, Head, _, DbgCtx, Action), 
     3786        '$lgt_dbg_port'(rule(N), Head, _, DbgCtx, Action), 
    37873787        call(Action) 
    37883788    ;   true 
     
    38433843 
    38443844 
    3845 '$lgt_dbg_write_port_name'(fact) :- 
    3846     write('   Fact: '). 
    3847 '$lgt_dbg_write_port_name'(rule) :- 
    3848     write('   Rule: '). 
     3845'$lgt_dbg_write_port_name'(fact(N)) :- 
     3846    (   N =:= 0 -> 
     3847        write('   Fact: ') 
     3848    ;   write('   Fact('), write(N), write('): ') 
     3849    ). 
     3850'$lgt_dbg_write_port_name'(rule(N)) :- 
     3851    (   N =:= 0 -> 
     3852        write('   Rule: ') 
     3853    ;   write('   Rule('), write(N), write('): ') 
     3854    ). 
    38493855'$lgt_dbg_write_port_name'(call) :- 
    38503856    write('   Call: '). 
     
    64316437    throw(type_error(callable, Body)). 
    64326438 
    6433 '$lgt_tr_clause'((Head:-Body), (THead:-'$lgt_nop'(Body), SBody), (THead:-'$lgt_nop'(Body),'$lgt_dbg_head'(Head, DbgCtx),DBody), Ctx, Input) :- 
     6439'$lgt_tr_clause'((Head:-Body), (THead:-'$lgt_nop'(Body), SBody), (THead:-'$lgt_nop'(Body),'$lgt_dbg_head'(Head, 0, DbgCtx),DBody), Ctx, Input) :- 
    64346440    functor(Head, Functor, Arity), 
    64356441    '$lgt_pp_dynamic_'(Functor, Arity), 
     
    64426448    '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx). 
    64436449 
    6444 '$lgt_tr_clause'((Head:-Body), TClause, (THead:-'$lgt_dbg_head'(Head, DbgCtx),DBody), Ctx, Input) :- 
     6450'$lgt_tr_clause'((Head:-Body), TClause, (THead:-'$lgt_dbg_head'(Head, N, DbgCtx),DBody), Ctx, Input) :- 
    64456451    !, 
    64466452    '$lgt_pred_meta_vars'(Head, MetaVars), 
     
    64536459    ;   TClause = (THead:-SBody) 
    64546460    ), 
    6455     '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx). 
     6461    '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
     6462    '$lgt_clause_number'(THead, N). 
    64566463 
    64576464'$lgt_tr_clause'(Fact, _, _, _, _) :- 
     
    64596466    throw(type_error(callable, Fact)). 
    64606467 
    6461 '$lgt_tr_clause'(Fact, TFact, (TFact:-'$lgt_dbg_fact'(Fact, DbgCtx)), Ctx, Input) :- 
     6468'$lgt_tr_clause'(Fact, TFact, (TFact:-'$lgt_dbg_fact'(Fact, N, DbgCtx)), Ctx, Input) :- 
    64626469    '$lgt_tr_head'(Fact, TFact, Ctx, Input), 
    6463     '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx). 
     6470    '$lgt_ctx_dbg_ctx'(Ctx, DbgCtx), 
     6471    '$lgt_clause_number'(TFact, N). 
     6472 
     6473 
     6474'$lgt_clause_number'(THead, N) :- 
     6475    functor(THead, TFunctor, TArity), 
     6476    functor(Template, TFunctor, TArity),  
     6477    findall(1, ('$lgt_pp_eclause_'(Template); '$lgt_pp_eclause_'((Template :- _))), List), 
     6478    '$lgt_length'(List, 0, Length), 
     6479    N is Length + 1. 
     6480 
     6481'$lgt_length'([], Length, Length). 
     6482'$lgt_length'([_| Tail], Acc, Length) :- 
     6483    Acc2 is Acc + 1, 
     6484    '$lgt_length'(Tail, Acc2, Length). 
     6485 
    64646486 
    64656487