Changeset 4324

Show
Ignore:
Timestamp:
06/26/08 03:57:05 (2 months ago)
Author:
pmoura
Message:

Restored the redefined entity warnings for back-end Prolog compilers that support multifile predicates. Simplified updating of the runtime tables when compiling and loading with back-end Prolog compilers that don't support multifile predicates.

When loading a redefined object, also clean all entries in the event handlers table where the object plays the role of a monitor.

Modified the Logtalk runtime to clean all lookup caches when compiling and loading source files (instead of doing it only when the files redefine existing entities).

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4323 r4324  
    40844084'$lgt_load_compiled_file'(Source) :- 
    40854085    '$lgt_file_name'(prolog, Source, PrologFile), 
     4086    '$lgt_clean_lookup_caches', 
     4087    '$lgt_check_redefined_entities', 
    40864088    (   '$lgt_pp_file_encoding_'(_, Encoding) -> 
    40874089        '$lgt_load_prolog_code'(PrologFile, Source, [encoding(Encoding)]) 
     
    40914093 
    40924094 
     4095% '$lgt_check_redefined_entities' 
     4096% 
     4097% check and print a warning for all entities that are about to be redefined; 
     4098% also retract old runtime clauses for the entity being redefined for safety 
     4099 
     4100'$lgt_check_redefined_entities' :- 
     4101    (   '$lgt_pp_file_rclause_'('$lgt_current_protocol_'(Entity, _, _)) 
     4102    ;   '$lgt_pp_file_rclause_'('$lgt_current_category_'(Entity, _, _, _, _, _)) 
     4103    ;   '$lgt_pp_file_rclause_'('$lgt_current_object_'(Entity, _, _, _, _, _, _, _)) 
     4104    ), 
     4105    '$lgt_redefined_entity'(Entity, Type), 
     4106    '$lgt_report_redefined_entity'(Type, Entity), 
     4107    '$lgt_retract_old_runtime_clauses'(Entity), 
     4108    fail. 
     4109 
     4110'$lgt_check_redefined_entities'. 
     4111 
     4112 
     4113 
    40934114% '$lgt_redefined_entity'(@entity_identifier, -atom) 
    40944115% 
    40954116% true if an entity of the same name is already loaded; returns entity type 
    40964117 
    4097 '$lgt_redefined_entity'(Entity, object) :- 
    4098     '$lgt_current_object_'(Entity, _, _, _, _, _, _, _), 
    4099     !. 
    4100  
    4101 '$lgt_redefined_entity'(Entity, protocol) :- 
    4102     '$lgt_current_protocol_'(Entity, _, _), 
    4103     !. 
    4104  
    4105 '$lgt_redefined_entity'(Entity, category) :- 
    4106     '$lgt_current_category_'(Entity, _, _, _, _, _). 
     4118'$lgt_redefined_entity'(Entity, Type) :- 
     4119    (   '$lgt_current_object_'(Entity, _, _, _, _, _, _, _) -> 
     4120        Type = object 
     4121    ;   '$lgt_current_protocol_'(Entity, _, _) -> 
     4122        Type = protocol 
     4123    ;   '$lgt_current_category_'(Entity, _, _, _, _, _) -> 
     4124        Type = category 
     4125    ). 
    41074126 
    41084127 
     
    41194138    ;   true 
    41204139    ). 
     4140 
     4141 
     4142 
     4143% '$lgt_retract_old_runtime_clauses'(@entity_identifier) 
     4144% 
     4145% clean all references to an entity that is about to be redefined from the  
     4146% runtime tables 
     4147 
     4148'$lgt_retract_old_runtime_clauses'(Entity) :- 
     4149    retractall('$lgt_before_'(_, _, _, Entity, _)), 
     4150    retractall('$lgt_after_'(_, _, _, Entity, _)), 
     4151    retractall('$lgt_current_object_'(Entity, _, _, _, _, _, _, _)), 
     4152    retractall('$lgt_current_protocol_'(Entity, _, _)), 
     4153    retractall('$lgt_current_category_'(Entity, _, _, _, _, _)), 
     4154    retractall('$lgt_implements_protocol_'(Entity, _, _)), 
     4155    retractall('$lgt_imports_category_'(Entity, _, _)), 
     4156    retractall('$lgt_instantiates_class_'(Entity, _, _)), 
     4157    retractall('$lgt_specializes_class_'(Entity, _, _)), 
     4158    retractall('$lgt_extends_protocol_'(Entity, _, _)), 
     4159    retractall('$lgt_extends_object_'(Entity, _, _)), 
     4160    retractall('$lgt_extends_category_'(Entity, _, _)), 
     4161    retractall('$lgt_complemented_object_'(_, Entity, _, _)), 
     4162    retractall('$lgt_debugging_'(Entity)). 
    41214163 
    41224164 
     
    47334775 
    47344776 
    4735 % save entity runtime clauses for Prolog compilers supporting the multifile/1 predicate  
    4736 % directive; these clauses are written at the end of the generated Prolog file, just  
    4737 % before the source file initialization goal 
     4777% save entity runtime clauses in order to be able to check for redefined  
     4778% entities when loading the intermediate Prolog files generated by the  
     4779% Logtalk compiler 
    47384780 
    47394781'$lgt_save_entity_rclauses' :- 
    4740     (   '$lgt_compiler_flag'(multifile_directive, supported) -> 
    4741         (   '$lgt_pp_rclause'(Clause), 
    4742             assertz('$lgt_pp_file_rclause_'(Clause)), 
    4743             fail 
    4744         ;   true 
    4745         ) 
    4746     ;   true 
    4747     ). 
     4782    '$lgt_pp_rclause'(Clause), 
     4783    assertz('$lgt_pp_file_rclause_'(Clause)), 
     4784    fail. 
     4785 
     4786'$lgt_save_entity_rclauses'. 
    47484787 
    47494788 
    47504789 
    47514790% clean up all dynamic predicates used during source file compilation 
    4752 % (except any user-defined compiler options specified on the compiling and loading predicates) 
     4791% (except any user-defined compiler options specified on the compiling  
     4792% and loading predicates) 
    47534793 
    47544794'$lgt_clean_pp_clauses' :- 
     
    1055310593        Goal1 = true 
    1055410594    ;   findall(Clause, '$lgt_pp_rclause'(Clause), Clauses), 
    10555         Goal1 = '$lgt_assert_runtime_clauses'(Entity, Clauses) 
     10595        Goal1 = '$lgt_assert_runtime_clauses'(Clauses) 
    1055610596    ), 
    1055710597    (   setof(Mutex, Head^'$lgt_pp_synchronized_'(Head, Mutex), Mutexes) -> 
     
    1068910729 
    1069010730 
    10691 % '$lgt_assert_runtime_clauses'(+callable, +list) 
     10731% '$lgt_assert_runtime_clauses'(+list) 
    1069210732% 
    1069310733% called when loading a compiled Logtalk entity in order to update 
    10694 % Logtalk internal runtime tables 
    10695 % 
    10696 % we may be reloading the entity so we must first retract any old 
    10697 % runtime clauses before asserting the new ones 
    10698 % 
    10699 % this is mostly a workaround for the lack of support of multifile 
    10700 % predicates in some Prolog compilers 
    10701  
    10702 '$lgt_assert_runtime_clauses'(Entity, Clauses) :- 
    10703     (   '$lgt_redefined_entity'(Entity, Type) -> 
    10704         '$lgt_clean_lookup_caches', 
    10705         '$lgt_report_redefined_entity'(Type, Entity) 
    10706     ;   true 
    10707     ), 
    10708     '$lgt_retract_old_runtime_clauses'(Entity), 
    10709     '$lgt_assert_new_runtime_clauses'(Clauses). 
    10710  
    10711  
    10712 '$lgt_retract_old_runtime_clauses'(Entity) :- 
    10713     retractall('$lgt_current_object_'(Entity, _, _, _, _, _, _, _)), 
    10714     retractall('$lgt_current_protocol_'(Entity, _, _)), 
    10715     retractall('$lgt_current_category_'(Entity, _, _, _, _, _)), 
    10716     retractall('$lgt_implements_protocol_'(Entity, _, _)), 
    10717     retractall('$lgt_imports_category_'(Entity, _, _)), 
    10718     retractall('$lgt_instantiates_class_'(Entity, _, _)), 
    10719     retractall('$lgt_specializes_class_'(Entity, _, _)), 
    10720     retractall('$lgt_extends_protocol_'(Entity, _, _)), 
    10721     retractall('$lgt_extends_object_'(Entity, _, _)), 
    10722     retractall('$lgt_extends_category_'(Entity, _, _)), 
    10723     retractall('$lgt_complemented_object_'(_, Entity, _, _)), 
    10724     retractall('$lgt_debugging_'(Entity)). 
    10725  
    10726  
    10727 '$lgt_assert_new_runtime_clauses'([]). 
    10728  
    10729 '$lgt_assert_new_runtime_clauses'([Clause| Clauses]) :- 
     10734% Logtalk internal runtime tables; this is mostly a workaround for  
     10735% the lack of support of multifile predicates in some Prolog compilers 
     10736 
     10737'$lgt_assert_runtime_clauses'([]). 
     10738 
     10739'$lgt_assert_runtime_clauses'([Clause| Clauses]) :- 
    1073010740    assertz(Clause), 
    10731     '$lgt_assert_new_runtime_clauses'(Clauses). 
     10741    '$lgt_assert_runtime_clauses'(Clauses). 
    1073210742 
    1073310743 
  • trunk/RELEASE_NOTES.txt

    r4323 r4324  
    1212 
    13132.32.1 - July ??, 2008 
     14 
     15    Restored the redefined entity warnings for back-end Prolog compilers  
     16    that support multifile predicates. Simplified updating of the runtime  
     17    tables when compiling and loading with back-end Prolog compilers that  
     18    don't support multifile predicates. 
     19 
     20    When loading a redefined object, also clean all entries in the event  
     21    handlers table where the object plays the role of a monitor. 
     22 
     23    Modified the Logtalk runtime to clean all lookup caches when compiling  
     24    and loading source files (instead of doing it only when the files  
     25    redefine existing entities). 
    1426 
    1527    Updated the SWI-Prolog config file notes about possible compatibility