mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 05:44:58 +00:00
We used to have only the first of these three forms, we now have all three:
:- external(low_level_backend, a/2).
% declared pred a/2 and func a/2 to be external on llds
:- pragma external_pred(a/2, [low_level_backend]).
% declared pred a/2 (and NOT func a/2) to be external on llds
:- pragma external_func(a/2, [low_level_backend]).
% declared func a/2 (and NOT pred a/2) to be external on llds
The new forms allow for more precise control of what is declared to be
external. The difference in syntax (the options coming after the name,
and the options being in a list, even though this pragma allows only
one option at present) are to fit in with the style of the other pragmas.
Of course, the backend does not have to be specified, so these are
also allowed:
:- pragma external_pred(a/2).
:- pragma external_func(a/2, []).
Using `:- external' declarations is for implementors only, since using it
requires writing target language code by hand in a way that conforms to all
the compiler's conventions for e.g. symbol naming and parameter passing.
It is not a documented part of Mercury. Therefore the new external_{func,pred}
pragmas are not documented either.
compiler/prog_item.m:
Change the representation of the `:- external' declaration from being
a module_defn to being a pragma. Generalize it to allow the new pragmas,
by allowing the recording of an option pred_or_func indication.
Add a function that returns a description of a pragma for use as a context
in error messages. We need this to avoid confusing users by having an
error message refer to a `:- external' declaration when they wrote e.g.
`:- pragma external_pred', or vice versa.
compiler/add_pragma.m:
Move the code for handling external declarations from make_hlds_passes
(which handles module_defns) to this module (which handles pragmas),
and update it.
Execute this code in pass 2, not pass 1, since we need to record
the "external" flag in the pred_info, and that is created in pass 1.
(I think this worked in the past ONLY if the declaration of the affected
predicate or function came textually before the `:- external' declaration.)
compiler/make_hlds_passes.m:
Remove the code that is now in add_pragma.m (in adapted form).
compiler/prog_io_item.m:
Change the code for parsing old-style `:- external' declarations to
generate the new pragma internally.
compiler/prog_io_pragma.m:
Add code for parsing the new pragmas.
compiler/equiv_type.m:
compiler/item_util.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/make_hlds_error.m:
Improve a variable name.
compiler/pred_table.m:
Improve the documentation of several predicates.
tests/hard_coded/backend_external.m:
Improve the documetation of this old test case, which tests the
handling of backend-specific `:- external' declarations.
tests/hard_coded/backend_external_{func,pred}.m:
Two copies of the old backend_external.m test case, which test the
handling of backend-specific `:- pragma external_func' and
`:- pragma external_pred' declarations respectively.
tests/hard_coded/backend_external_func.exp:
tests/hard_coded/backend_external_pred.{exp,exp2}:
The expected outputs of the new test cases.
tests/hard_coded/Mmakefile:
Enable the new test cases.
tests/invalid/type_spec.err_exp:
Expect an error message for a `:- external' declaration in the interface
of type_spec.m. Since declaring a procedure to be external is in essence
a representation of the implementation of that procedure, the previous
absence of an error message for this implementation detail in the interface
was a bug.
tests/invalid/external.err_exp:
We always generated an error for a `:- external' declaration that
did not specify an arity, but the text of the error message used to say
"warning", not "error" (even though the severity level was "error").
Expect the corrected error message.
tests/invalid/not_in_interface.err_exp:
Expect the updated, more precise form of an error message.
vim/syntax/mercury.vim:
Add the two new keywords.
Mercury Syntax Highlighting Under Vim 6.0+ Please consult doc/mercury.txt for installation and configuration information.