Changeset 4517 for trunk/compiler
- Timestamp:
- 10/18/08 17:56:42 (3 months ago)
- Files:
-
- 1 modified
-
trunk/compiler/logtalk.pl (modified) (49 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/compiler/logtalk.pl
r4516 r4517 4568 4568 '$lgt_compiler_error_handler'(OpenError)), 4569 4569 catch( 4570 read_term(Input, Term, [singletons(Singletons)]),4570 '$lgt_read_term'(Input, Term, [singletons(Singletons)], Line), 4571 4571 InputError, 4572 4572 '$lgt_compiler_error_handler'(Input, InputError)), … … 4578 4578 '$lgt_compiler_error_handler'(NewInput, Output, OpenError)), 4579 4579 catch( 4580 '$lgt_tr_file'(Term, Singletons, NewInput, Output),4580 '$lgt_tr_file'(Term, Singletons, Line, NewInput, Output), 4581 4581 Error, 4582 4582 '$lgt_compiler_error_handler'(NewInput, Output, Error)), … … 4625 4625 4626 4626 4627 % '$lgt_tr_file'(+term, +list, @stream, @stream)4628 4629 '$lgt_tr_file'(end_of_file, _, _, Output) :- % module definitions start with an opening4627 % '$lgt_tr_file'(+term, +list, +integer, @stream, @stream) 4628 4629 '$lgt_tr_file'(end_of_file, _, _, _, Output) :- % module definitions start with an opening 4630 4630 '$lgt_pp_module_'(Module), % module/1-2 directive and are assumed to 4631 4631 '$lgt_pp_object_'(Module, _, _, _, _, _, _, _, _, _, _), % end at the end of a source file; there is … … 4634 4634 !. 4635 4635 4636 '$lgt_tr_file'(end_of_file, _, _, _ ) :-4636 '$lgt_tr_file'(end_of_file, _, _, _, _) :- 4637 4637 '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _), 4638 4638 throw(entity_ending_directive_missing(object, Obj)). 4639 4639 4640 '$lgt_tr_file'(end_of_file, _, _, _ ) :-4640 '$lgt_tr_file'(end_of_file, _, _, _, _) :- 4641 4641 '$lgt_pp_protocol_'(Ptc, _, _, _, _), 4642 4642 throw(entity_ending_directive_missing(protocol, Ptc)). 4643 4643 4644 '$lgt_tr_file'(end_of_file, _, _, _ ) :-4644 '$lgt_tr_file'(end_of_file, _, _, _, _) :- 4645 4645 '$lgt_pp_category_'(Ctg, _, _, _, _, _), 4646 4646 throw(entity_ending_directive_missing(category, Ctg)). 4647 4647 4648 '$lgt_tr_file'(end_of_file, _, _, _ ) :-4648 '$lgt_tr_file'(end_of_file, _, _, _, _) :- 4649 4649 !. 4650 4650 4651 '$lgt_tr_file'(Term, Singletons, Input, Output) :-4652 '$lgt_report_singletons'(Singletons, Term, Input),4653 '$lgt_tr_term'(Term, Input, Output),4654 read_term(Input, Next, [singletons(NextSingletons)]),4655 '$lgt_tr_file'(Next, NextSingletons, Input, Output).4656 4657 4658 4659 % '$lgt_add_entity_file_properties'(@ entity_identifier, @stream)4651 '$lgt_tr_file'(Term, Singletons, Line, Input, Output) :- 4652 '$lgt_report_singletons'(Singletons, Term, Line, Input), 4653 '$lgt_tr_term'(Term, Line, Input, Output), 4654 '$lgt_read_term'(Input, Next, [singletons(NextSingletons)], NextLine), 4655 '$lgt_tr_file'(Next, NextSingletons, NextLine, Input, Output). 4656 4657 4658 4659 % '$lgt_add_entity_file_properties'(@nonvar, @entity_identifier) 4660 4660 % 4661 4661 % adds entity properties related to the entity source file 4662 4662 4663 '$lgt_add_entity_file_properties'(Entity, _Input) :- 4664 % ( catch('$lgt_stream_current_line_number'(Input, Line), _, fail) -> 4665 % assertz('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, line_count(Line)))) 4666 % ; true 4667 % ), 4668 '$lgt_pp_file_path_'(File, Path) -> 4669 assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Entity, file(File, Path)))). 4670 4671 4672 4673 % '$lgt_report_singletons'(+list, +term, @stream) 4663 '$lgt_add_entity_file_properties'(start(Start), Entity) :- 4664 ( Start =:= -1 -> 4665 true 4666 ; assertz('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, lines(Start, _)))) 4667 ), 4668 ( '$lgt_pp_file_path_'(File, Path) -> 4669 assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Entity, file(File, Path)))) 4670 ; true 4671 ). 4672 4673 '$lgt_add_entity_file_properties'(end(End), Entity) :- 4674 ( End =:= -1 -> 4675 true 4676 ; retract('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, lines(Start, _)))) -> 4677 assertz('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, lines(Start, End)))) 4678 ). 4679 4680 4681 4682 % '$lgt_report_singletons'(+list, +term, +integer, @stream) 4674 4683 % 4675 4684 % reports the singleton variables found while compiling an entity term 4676 4685 4677 '$lgt_report_singletons'(Singletons, Term, Input) :-4686 '$lgt_report_singletons'(Singletons, Term, Line, Input) :- 4678 4687 ( '$lgt_compiler_flag'(singletons, warning), 4679 4688 '$lgt_compiler_flag'(report, on) -> 4680 4689 '$lgt_filter_singletons'(Singletons, Names), 4681 '$lgt_report_singleton_names'(Names, Term, Input)4690 '$lgt_report_singleton_names'(Names, Term, Line, Input) 4682 4691 ; true 4683 4692 ). 4684 4693 4685 4694 4686 '$lgt_report_singleton_names'([], _, _ ) :-4695 '$lgt_report_singleton_names'([], _, _, _) :- 4687 4696 !. % cut needed to prevent problems with compilers with broken read_term/3 implementations 4688 4697 4689 '$lgt_report_singleton_names'([Name| Names], Term, Stream) :-4698 '$lgt_report_singleton_names'([Name| Names], Term, Line, Input) :- 4690 4699 '$lgt_inc_compile_warnings_counter', 4691 4700 ( '$lgt_pp_entity'(_, _, _, _, _) -> … … 4699 4708 'lgt_report_singletons_term'(Term), 4700 4709 '$lgt_write_list'([Name| Names]), 4701 nl, '$lgt_report_compiler_error_line_number'( Stream),4710 nl, '$lgt_report_compiler_error_line_number'(Line, Input), 4702 4711 ( '$lgt_pp_entity'(_, _, _, _, _) -> 4703 4712 true … … 4822 4831 '$lgt_report_compiler_error'(Stream, Error) :- 4823 4832 '$lgt_report_compiler_error_message'(Error), 4824 '$lgt_report_compiler_error_line_number'(Stream), 4833 ( catch('$lgt_stream_current_line_number'(Stream, Line), _, fail) -> 4834 write(' above line: '), write(Line) 4835 ; true 4836 ), 4825 4837 nl. 4826 4838 … … 4861 4873 4862 4874 4863 '$lgt_report_compiler_error_line_number'(Stream) :- 4864 ( catch('$lgt_stream_current_line_number'(Stream, Line), _, fail) -> 4865 write(' above line: '), write(Line) 4866 ; true 4875 '$lgt_report_compiler_error_line_number'(Line, Stream) :- 4876 ( Line =:= -1 -> 4877 ( catch('$lgt_stream_current_line_number'(Stream, Next), _, fail) -> 4878 write(' above line: '), write(Next) 4879 ; true 4880 ) 4881 ; write(' in line: '), write(Line) 4867 4882 ). 4868 4883 … … 5128 5143 5129 5144 5130 % '$lgt_tr_term'(+term, @stream, @stream)5145 % '$lgt_tr_term'(+term, +integer, @stream, @stream) 5131 5146 % 5132 5147 % translates a source file term (clauses, directives, and grammar rules) 5133 5148 5134 '$lgt_tr_term'(Term, Input, Output) :-5149 '$lgt_tr_term'(Term, Line, Input, Output) :- 5135 5150 ( % source-file specific compiler hook: 5136 5151 '$lgt_pp_hook_term_expansion_'(Term, Terms) -> 5137 '$lgt_tr_expanded_terms'(Terms, Input, Output)5152 '$lgt_tr_expanded_terms'(Terms, Line, Input, Output) 5138 5153 ; % default compiler hook: 5139 5154 '$lgt_hook_term_expansion_'(Term, Terms) -> 5140 '$lgt_tr_expanded_terms'(Terms, Input, Output)5155 '$lgt_tr_expanded_terms'(Terms, Line, Input, Output) 5141 5156 ; % no compiler hook defined: 5142 '$lgt_tr_expanded_term'(Term, Input, Output)5143 ). 5144 5145 5146 5147 % '$lgt_tr_expanded_terms'(+list, @stream, @stream)5157 '$lgt_tr_expanded_term'(Term, Line, Input, Output) 5158 ). 5159 5160 5161 5162 % '$lgt_tr_expanded_terms'(+list, +integer, @stream, @stream) 5148 5163 % 5149 5164 % translates a list of source file terms 5150 5165 5151 '$lgt_tr_expanded_terms'([], _, _ ).5152 5153 '$lgt_tr_expanded_terms'([Term| Terms], Input, Output) :-5154 '$lgt_tr_expanded_term'(Term, Input, Output),5155 '$lgt_tr_expanded_terms'(Terms, Input, Output).5156 5157 5158 5159 % '$lgt_tr_expanded_term'(+ list, @stream, @stream)5166 '$lgt_tr_expanded_terms'([], _, _, _). 5167 5168 '$lgt_tr_expanded_terms'([Term| Terms], Line, Input, Output) :- 5169 '$lgt_tr_expanded_term'(Term, Line, Input, Output), 5170 '$lgt_tr_expanded_terms'(Terms, Line, Input, Output). 5171 5172 5173 5174 % '$lgt_tr_expanded_term'(+term, +integer, @stream, @stream) 5160 5175 % 5161 5176 % translates a source file term (clauses, directives, and grammar rules) 5162 5177 5163 '$lgt_tr_expanded_term'((Head :- Body), Input, _) :-5164 !, 5165 '$lgt_tr_clause'((Head :- Body), Input).5166 5167 '$lgt_tr_expanded_term'((:- Directive), Input, Output) :-5168 !, 5169 '$lgt_tr_directive'(Directive, Input, Output).5170 5171 '$lgt_tr_expanded_term'((Head --> Body), Input, _) :-5178 '$lgt_tr_expanded_term'((Head :- Body), Line, Input, _) :- 5179 !, 5180 '$lgt_tr_clause'((Head :- Body), Line, Input). 5181 5182 '$lgt_tr_expanded_term'((:- Directive), Line, Input, Output) :- 5183 !, 5184 '$lgt_tr_directive'(Directive, Line, Input, Output). 5185 5186 '$lgt_tr_expanded_term'((Head --> Body), Line, Input, _) :- 5172 5187 !, 5173 5188 '$lgt_dcgrule_to_clause'((Head --> Body), Clause), 5174 '$lgt_tr_clause'(Clause, Input).5175 5176 '$lgt_tr_expanded_term'(Fact, Input, _) :-5177 '$lgt_tr_clause'(Fact, Input).5189 '$lgt_tr_clause'(Clause, Line, Input). 5190 5191 '$lgt_tr_expanded_term'(Fact, Line, Input, _) :- 5192 '$lgt_tr_clause'(Fact, Line, Input). 5178 5193 5179 5194 … … 5186 5201 5187 5202 '$lgt_tr_directives'([Dir| Dirs], Input, Output) :- 5188 '$lgt_tr_directive'(Dir, Input, Output),5203 '$lgt_tr_directive'(Dir, -1, Input, Output), 5189 5204 '$lgt_tr_directives'(Dirs, Input, Output). 5190 5205 5191 5206 5192 5207 5193 % '$lgt_tr_directive'(+term, @stream, @stream)5208 % '$lgt_tr_directive'(+term, +integer, @stream, @stream) 5194 5209 % 5195 5210 % translates a directive 5196 5211 5197 '$lgt_tr_directive'(Dir, _, _ ) :-5212 '$lgt_tr_directive'(Dir, _, _, _) :- 5198 5213 var(Dir), 5199 5214 throw(error(instantiantion_error, directive(Dir))). 5200 5215 5201 '$lgt_tr_directive'(Dir, _, _ ) :-% closing entity directive occurs before the opening5216 '$lgt_tr_directive'(Dir, _, _, _) :- % closing entity directive occurs before the opening 5202 5217 \+ '$lgt_pp_entity'(_, _, _, _, _), % entity directive; the opening directive is probably 5203 5218 functor(Dir, Functor, Arity), % missing or misspelt … … 5205 5220 throw(error(unmatched_directive, directive(Dir))). 5206 5221 5207 '$lgt_tr_directive'(Dir, _, _ ) :-5222 '$lgt_tr_directive'(Dir, _, _, _) :- 5208 5223 \+ '$lgt_pp_entity'(_, _, _, _, _), % directive occurs before opening entity directive 5209 5224 functor(Dir, Functor, Arity), … … 5212 5227 '$lgt_tr_file_directive'(Dir). % translate it as a source file-level directive 5213 5228 5214 '$lgt_tr_directive'(Dir, Input, Output) :-% entity closing directive5229 '$lgt_tr_directive'(Dir, Line, Input, Output) :- % entity closing directive 5215 5230 functor(Dir, Functor, Arity), 5216 5231 '$lgt_lgt_closing_directive'(Functor, Arity), 5217 5232 Dir =.. [Functor| Args], 5218 5233 catch( 5219 '$lgt_tr_directive'(Functor, Args, Input, Output),5234 '$lgt_tr_directive'(Functor, Args, Line, Input, Output), 5220 5235 Error, 5221 5236 ( '$lgt_pp_entity'(Type, Entity, _, _, _) -> … … 5225 5240 !. 5226 5241 5227 '$lgt_tr_directive'(Dir, Input, Output) :-% entity opening directive or entity directive5242 '$lgt_tr_directive'(Dir, Line, Input, Output) :- % entity opening directive or entity directive 5228 5243 functor(Dir, Functor, Arity), 5229 5244 '$lgt_lgt_directive'(Functor, Arity), 5230 5245 Dir =.. [Functor| Args], 5231 5246 catch( 5232 '$lgt_tr_directive'(Functor, Args, Input, Output),5247 '$lgt_tr_directive'(Functor, Args, Line, Input, Output), 5233 5248 Error, 5234 5249 throw(error(Error, directive(Dir)))), 5235 5250 !. 5236 5251 5237 '$lgt_tr_directive'(Dir, Input, _) :-5238 '$lgt_ignore_pl_directive'(Dir), % defined in the Prolog config files5252 '$lgt_tr_directive'(Dir, Line, Input, _) :- 5253 '$lgt_ignore_pl_directive'(Dir), % defined in the Prolog config files 5239 5254 !, 5240 5255 ( '$lgt_compiler_flag'(portability, warning) -> 5241 5256 nl, write(' WARNING! Ignoring Prolog directive: '), writeq(Dir), 5242 nl, '$lgt_report_compiler_error_line_number'( Input)5257 nl, '$lgt_report_compiler_error_line_number'(Line, Input) 5243 5258 ; true 5244 5259 ). 5245 5260 5246 '$lgt_tr_directive'(Dir, Input, _) :-5247 '$lgt_rewrite_and_copy_pl_directive'(Dir, RWDir), % defined in the Prolog config files5261 '$lgt_tr_directive'(Dir, Line, Input, _) :- 5262 '$lgt_rewrite_and_copy_pl_directive'(Dir, RWDir), % defined in the Prolog config files 5248 5263 assertz('$lgt_pp_directive_'(RWDir)), 5249 5264 !, … … 5251 5266 nl, write(' WARNING! Rewriting Prolog directive: '), writeq(Dir), 5252 5267 nl, write(' Copying resulting Prolog directive: '), writeq(RWDir), 5253 nl, '$lgt_report_compiler_error_line_number'( Input)5268 nl, '$lgt_report_compiler_error_line_number'(Line, Input) 5254 5269 ; true 5255 5270 ). 5256 5271 5257 '$lgt_tr_directive'(Dir, Input, Output) :-5272 '$lgt_tr_directive'(Dir, Line, Input, Output) :- 5258 5273 '$lgt_rewrite_and_recompile_pl_directive'(Dir, RWDir), % defined in the Prolog config files 5259 5274 !, … … 5261 5276 nl, write(' WARNING! Rewriting Prolog directive: '), writeq(Dir), 5262 5277 nl, write(' Recompiling resulting Prolog directive: '), writeq(RWDir), 5263 nl, '$lgt_report_compiler_error_line_number'( Input)5278 nl, '$lgt_report_compiler_error_line_number'(Line, Input) 5264 5279 ; true 5265 5280 ), 5266 '$lgt_tr_directive'(RWDir, Input, Output). % try to translate the rewritten directive5267 5268 '$lgt_tr_directive'(Dir, _, _ ) :-5281 '$lgt_tr_directive'(RWDir, Line, Input, Output). % try to translate the rewritten directive 5282 5283 '$lgt_tr_directive'(Dir, _, _, _) :- 5269 5284 functor(Dir, Functor, Arity), 5270 5285 throw(error(domain_error(directive, Functor/Arity), directive(Dir))). … … 5312 5327 5313 5328 5314 % '$lgt_tr_directive'(+atom, +list, @ stream, @stream)5329 % '$lgt_tr_directive'(+atom, +list, @nonvar, @stream, @stream) 5315 5330 % 5316 5331 % translates a directive and its (possibly empty) list of arguments 5317 5332 5318 '$lgt_tr_directive'(object, [Obj| _], _, _ ) :-5333 '$lgt_tr_directive'(object, [Obj| _], _, _, _) :- 5319 5334 var(Obj), 5320 5335 throw(instantiation_error). 5321 5336 5322 '$lgt_tr_directive'(object, [Obj| _], _, _ ) :-5337 '$lgt_tr_directive'(object, [Obj| _], _, _, _) :- 5323 5338 \+ callable(Obj), 5324 5339 throw(type_error(object_identifier, Obj)). 5325 5340 5326 '$lgt_tr_directive'(object, [Obj| _], _, _ ) :-5341 '$lgt_tr_directive'(object, [Obj| _], _, _, _) :- 5327 5342 ( '$lgt_built_in_object'(Obj) -> 5328 5343 throw(permission_error(modify, object, Obj)) … … 5333 5348 ). 5334 5349 5335 '$lgt_tr_directive'(object, [Obj| Rels], Input, _) :-5350 '$lgt_tr_directive'(object, [Obj| Rels], Line, _, _) :- 5336 5351 '$lgt_report_compiling_entity'(object, Obj), 5337 '$lgt_add_entity_file_properties'( Obj, Input),5352 '$lgt_add_entity_file_properties'(start(Line), Obj), 5338 5353 '$lgt_save_file_op_table', 5339 5354 '$lgt_tr_object_id'(Obj, static), % assume static object 5340 5355 '$lgt_tr_object_relations'(Rels, Obj). 5341 5356 5342 '$lgt_tr_directive'(end_object, [], _, Output) :-5357 '$lgt_tr_directive'(end_object, [], Line, _, Output) :- 5343 5358 ( '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _) -> 5344 5359 '$lgt_tr_entity'(object, Obj, Output), 5345 5360 '$lgt_restore_file_op_table', 5346 '$lgt_report_compiled_entity'(object, Obj) 5361 '$lgt_report_compiled_entity'(object, Obj), 5362 '$lgt_add_entity_file_properties'(end(Line), Obj) 5347 5363 ; throw(closing_directive_mismatch) 5348 5364 ). 5349 5365 5350 '$lgt_tr_directive'(protocol, [Ptc| _], _, _ ) :-5366 '$lgt_tr_directive'(protocol, [Ptc| _], _, _, _) :- 5351 5367 var(Ptc), 5352 5368 throw(instantiation_error). 5353 5369 5354 '$lgt_tr_directive'(protocol, [Ptc| _], _, _ ) :-5370 '$lgt_tr_directive'(protocol, [Ptc| _], _, _, _) :- 5355 5371 \+ atom(Ptc), 5356 5372 throw(type_error(protocol_identifier, Ptc)). 5357 5373 5358 '$lgt_tr_directive'(protocol, [Ptc| _], _, _ ) :-5374 '$lgt_tr_directive'(protocol, [Ptc| _], _, _, _) :- 5359 5375 ( '$lgt_built_in_object'(Ptc) -> 5360 5376 throw(permission_error(modify, object, Ptc)) … … 5365 5381 ). 5366 5382 5367 '$lgt_tr_directive'(protocol, [Ptc| Rels], Input, _) :-5383 '$lgt_tr_directive'(protocol, [Ptc| Rels], Line, _, _) :- 5368 5384 '$lgt_report_compiling_entity'(protocol, Ptc), 5369 '$lgt_add_entity_file_properties'( Ptc, Input),5385 '$lgt_add_entity_file_properties'(start(Line), Ptc), 5370 5386 '$lgt_save_file_op_table', 5371 5387 '$lgt_tr_protocol_id'(Ptc, static), % assume static protocol 5372 5388 '$lgt_tr_protocol_relations'(Rels, Ptc). 5373 5389 5374 '$lgt_tr_directive'(end_protocol, [], _, Output) :-5390 '$lgt_tr_directive'(end_protocol, [], Line, _, Output) :- 5375 5391 ( '$lgt_pp_protocol_'(Ptc, _, _, _, _) -> 5376 5392 '$lgt_tr_entity'(protocol, Ptc, Output), 5377 5393 '$lgt_restore_file_op_table', 5378 '$lgt_report_compiled_entity'(protocol, Ptc) 5394 '$lgt_report_compiled_entity'(protocol, Ptc), 5395 '$lgt_add_entity_file_properties'(end(Line), Ptc) 5379 5396 ; throw(closing_directive_mismatch) 5380 5397 ). 5381 5398 5382 5399 5383 '$lgt_tr_directive'(category, [Ctg| _], _, _ ) :-5400 '$lgt_tr_directive'(category, [Ctg| _], _, _, _) :- 5384 5401 var(Ctg), 5385 5402 throw(instantiation_error). 5386 5403 5387 '$lgt_tr_directive'(category, [Ctg| _], _, _ ) :-5404 '$lgt_tr_directive'(category, [Ctg| _], _, _, _) :- 5388 5405 \+ atom(Ctg), 5389 5406 throw(type_error(category_identifier, Ctg)). 5390 5407 5391 '$lgt_tr_directive'(category, [Ctg| _], _, _ ) :-5408 '$lgt_tr_directive'(category, [Ctg| _], _, _, _) :- 5392 5409 ( '$lgt_built_in_object'(Ctg) -> 5393 5410 throw(permission_error(modify, object, Ctg)) … … 5398 5415 ). 5399 5416 5400 '$lgt_tr_directive'(category, [Ctg| Rels], Input, _) :-5417 '$lgt_tr_directive'(category, [Ctg| Rels], Line, _, _) :- 5401 5418 '$lgt_report_compiling_entity'(category, Ctg), 5402 '$lgt_add_entity_file_properties'( Ctg, Input),5419 '$lgt_add_entity_file_properties'(start(Line), Ctg), 5403 5420 '$lgt_save_file_op_table', 5404 5421 '$lgt_tr_category_id'(Ctg, static), % assume static category 5405 5422 '$lgt_tr_category_relations'(Rels, Ctg). 5406 5423 5407 '$lgt_tr_directive'(end_category, [], _, Output) :-5424 '$lgt_tr_directive'(end_category, [], Line, _, Output) :- 5408 5425 ( '$lgt_pp_category_'(Ctg, _, _, _, _, _) -> 5409 5426 '$lgt_tr_entity'(category, Ctg, Output), 5410 5427 '$lgt_restore_file_op_table', 5411 '$lgt_report_compiled_entity'(category, Ctg) 5428 '$lgt_report_compiled_entity'(category, Ctg), 5429 '$lgt_add_entity_file_properties'(end(Line), Ctg) 5412 5430 ; throw(closing_directive_mismatch) 5413 5431 ). … … 5416 5434 % compile modules as objects 5417 5435 5418 '$lgt_tr_directive'(module, [Module], Input, Output) :-5419 !, 5420 '$lgt_tr_directive'(module, [Module, []], Input, Output). % empty export list5421 5422 '$lgt_tr_directive'(module, [Module, ExportList], _, _ ) :-5436 '$lgt_tr_directive'(module, [Module], Line, Input, Output) :- 5437 !, 5438 '$lgt_tr_directive'(module, [Module, []], Line, Input, Output). % empty export list 5439 5440 '$lgt_tr_directive'(module, [Module, ExportList], _, _, _) :- 5423 5441 (var(Module); var(ExportList)), 5424 5442 throw(instantiation_error). 5425 5443 5426 '$lgt_tr_directive'(module, [Module, _], _, _ ) :-5444 '$lgt_tr_directive'(module, [Module, _], _, _, _) :- 5427 5445 \+ atom(Module), 5428 5446 throw(type_error(module_identifier, Module)). 5429 5447 5430 '$lgt_tr_directive'(module, [Module, ExportList], Input, Output) :-5448 '$lgt_tr_directive'(module, [Module, ExportList], Line, Input, Output) :- 5431 5449 assertz('$lgt_pp_module_'(Module)), % remeber we are compiling a module 5432 5450 '$lgt_report_compiling_entity'(module, Module), 5433 5451 '$lgt_tr_object_id'(Module, static), % assume static module/object 5434 '$lgt_tr_directive'((public), ExportList, Input, Output), % make the export list public predicates5452 '$lgt_tr_directive'((public), ExportList, Line, Input, Output), % make the export list public predicates 5435 5453 '$lgt_save_file_op_table'. 5436 5454 … … 5438 5456 % create a message queue at object initialization 5439 5457 5440 '$lgt_tr_directive'(threaded, [], _, _) :- 5441 \+ '$lgt_pp_object_'(_, _, _, _, _, _, _, _, _, _, _), 5442 throw(domain_error(object_directive, threaded/0)). 5443 5444 '$lgt_tr_directive'(threaded, [], _, _) :- 5458 '$lgt_tr_directive'(threaded, [], _, _, _) :- 5445 5459 \+ '$lgt_compiler_flag'(threads, on), 5446 5460 throw(error(resource_error(threads), threaded/0)). 5447 5461 5448 '$lgt_tr_directive'(threaded, [], _, _) :- 5449 !, 5450 assertz('$lgt_pp_threaded_'), 5451 '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _), 5452 assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Obj, threaded))). 5462 '$lgt_tr_directive'(threaded, [], _, _, _) :- 5463 !, 5464 ( '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _) -> 5465 assertz('$lgt_pp_threaded_'), 5466 assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Obj, threaded))) 5467 ; throw(domain_error(object_directive, threaded/0)) 5468 ). 5453 5469 5454 5470 5455 5471 % make all object (or category) predicates synchronized using the same mutex 5456 5472 5457 '$lgt_tr_directive'(synchronized, [], _, _ ) :-5473 '$lgt_tr_directive'(synchronized, [], _, _, _) :- 5458 5474 \+ '$lgt_pp_object_'(_, _, _, _, _, _, _, _, _, _, _), 5459 5475 \+ '$lgt_pp_category_'(_, _, _, _, _, _), 5460 5476 throw(domain_error(directive, synchronized/0)). 5461 5477 5462 '$lgt_tr_directive'(synchronized, [], _, _ ) :-5478 '$lgt_tr_directive'(synchronized, [], _, _, _) :- 5463 5479 !, 5464 5480 ( '$lgt_default_flag'(threads, on) -> … … 5474 5490 % dynamic entity directive 5475 5491 5476 '$lgt_tr_directive'((dynamic), [], _, _ ) :-5492 '$lgt_tr_directive'((dynamic), [], _, _, _) :- 5477 5493 !, 5478 5494 '$lgt_update_entity_comp_mode'. 5479 5495 5480 5496 5481 '$lgt_tr_directive'(initialization, [Goal], _, _ ) :-5497 '$lgt_tr_directive'(initialization, [Goal], _, _, _) :- 5482 5498 var(Goal), 5483 5499 throw(instantiation_error). 5484 5500 5485 '$lgt_tr_directive'(initialization, [Goal], _, _ ) :-5501 '$lgt_tr_directive'(initialization, [Goal], _, _, _) :- 5486 5502 \+ callable(Goal), 5487 5503 throw(type_error(callable, Goal)). 5488 5504 5489 '$lgt_tr_directive'(initialization, [Goal], _, _ ) :-5505 '$lgt_tr_directive'(initialization, [Goal], _, _, _) :- 5490 5506 '$lgt_pp_entity'(_, Entity, Prefix, _, _), 5491 5507 '$lgt_ctx_ctx'(Ctx, _, Entity, Entity, Entity, Prefix, [], _), … … 5494 5510 5495 5511 5496 '$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _ ) :-5512 '$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _, _) :- 5497 5513 (var(Pr); var(Spec); var(Ops)), 5498 5514 throw(instantiation_error). 5499 5515 5500 '$lgt_tr_directive'(op, [Pr, _, _], _, _ ) :-5516 '$lgt_tr_directive'(op, [Pr, _, _], _, _, _) :- 5501 5517 \+ '$lgt_valid_op_priority'(Pr), 5502 5518 throw(type_error(operator_priority, Pr)). 5503 5519 5504 '$lgt_tr_directive'(op, [_, Spec, _], _, _ ) :-5520 '$lgt_tr_directive'(op, [_, Spec, _], _, _, _) :- 5505 5521 \+ '$lgt_valid_op_specifier'(Spec), 5506 5522 throw(type_error(operator_specifier, Spec)). 5507 5523 5508 '$lgt_tr_directive'(op, [_, _, Ops], _, _ ) :-5524 '$lgt_tr_directive'(op, [_, _, Ops], _, _, _) :- 5509 5525 \+ '$lgt_valid_op_names'(Ops), 5510 5526 throw(type_error(operator_name, Ops)). 5511 5527 5512 '$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _ ) :-5528 '$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _, _) :- 5513 5529 op(Pr, Spec, Ops), 5514 5530 '$lgt_assert_entity_ops'(Pr, Spec, Ops). 5515 5531 5516 5532 5517 '$lgt_tr_directive'(uses, [Obj, Preds], _, _ ) :-5533 '$lgt_tr_directive'(uses, [Obj, Preds], _, _, _) :- 5518 5534 (var(Obj); var(Preds)), 5519 5535 throw(instantiation_error). 5520 5536 5521 '$lgt_tr_directive'(uses, [Obj, _], _, _ ) :-5537 '$lgt_tr_directive'(uses, [Obj, _], _, _, _) :- 5522 5538 \+ callable(Obj), 5523 5539 throw(type_error(object_identifier, Obj)). 5524 5540 5525 '$lgt_tr_directive'(uses, [_, Preds], _, _ ) :-5541 '$lgt_tr_directive'(uses, [_, Preds], _, _, _) :- 5526 5542 \+ '$lgt_is_proper_list'(Preds), 5527 5543 throw(type_error(list, Preds)). 5528 5544 5529 '$lgt_tr_directive'(uses, [Obj, Preds], _, _ ) :-5545 '$lgt_tr_directive'(uses, [Obj, Preds], _, _, _) :- 5530 5546 !, 5531 5547 assertz('$lgt_pp_referenced_object_'(Obj)), … … 5534 5550 5535 5551 5536 '$lgt_tr_directive'(uses, [Obj], _, _ ) :-5552 '$lgt_tr_directive'(uses, [Obj], _, _, _) :- 5537 5553 var(Obj), 5538 5554 throw(instantiation_error). 5539 5555 5540 '$lgt_tr_directive'(uses, [Obj], _, _ ) :-5556 '$lgt_tr_directive'(uses, [Obj], _, _, _) :- 5541 5557 \+ callable(Obj), 5542 5558 throw(type_error(object_identifier, Obj)). 5543 5559 5544 '$lgt_tr_directive'(uses, [Obj], _, _ ) :-5560 '$lgt_tr_directive'(uses, [Obj], _, _, _) :- 5545 5561 assertz('$lgt_pp_referenced_object_'(Obj)), 5546 5562 assertz('$lgt_pp_uses_'(Obj)). 5547 5563 5548 5564 5549 '$lgt_tr_directive'(use_module, [Module, _], _, _ ) :-5565 '$lgt_tr_directive'(use_module, [Module, _], _, _, _) :- 5550 5566 var(Module), 5551 5567 throw(instantiation_error). 5552 5568
