mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 03:13:40 +00:00
Add an attribute may_not_export_body to prevent a foreign_proc from
being opt-exported. Also add may_export_body for completeness.
compiler/prog_data_foreign.m:
Add type to represent those attributes.
Add a field for that attribute to pragma_foreign_proc_attributes,
plus getters and setters.
compiler/parse_pragma_foreign.m:
Parse may_export_body and may_not_export_body attributes on
foreign_proc declarations.
Detect conflicting attributes.
compiler/parse_tree_out_pragma.m:
Write out may_export_body and may_not_export_body attributes.
compiler/intermod.m:
Do not write a foreign_proc with may_not_export_body to .opt files.
compiler/simplify_proc.m:
Report an error if a foreign_proc with may_export_body is
also marked with pragma no_inline.
compiler/add_mutable_aux_preds.m:
Mark auxiliary predicates for mutables with may_not_export_body
instead of may_not_duplicate. This allows calls to those predicates
to be inlined.
doc/reference_manual.texi:
Document the new attributes.
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/intermod_may_export_body.exp:
tests/hard_coded/intermod_may_export_body.m:
tests/hard_coded/intermod_may_export_body2.m:
tests/invalid/Mmakefile:
tests/invalid/test_may_export_body.err_exp:
tests/invalid/test_may_export_body.m:
Add test cases.
vim/syntax/mercury.vim:
Update vim syntax file.
NEWS:
Announce addition.
39 lines
664 B
Mathematica
39 lines
664 B
Mathematica
% vim:ts=4 sw=4 expandtab ft=mercury
|
|
|
|
:- module test_may_export_body.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
main(!IO) :-
|
|
A0 = 0,
|
|
p1(A0, A1),
|
|
p2(A1, A),
|
|
io.write_int(A, !IO),
|
|
io.nl(!IO).
|
|
|
|
:- pred p1(int::in, int::out) is det.
|
|
:- pragma no_inline(p1/2).
|
|
|
|
:- pragma foreign_proc("C",
|
|
p1(N::in, M::out),
|
|
[will_not_call_mercury, promise_pure, may_export_body],
|
|
"
|
|
M = N + 1;
|
|
").
|
|
|
|
:- pred p2(int::in, int::out) is det.
|
|
:- pragma inline(p2/2).
|
|
|
|
:- pragma foreign_proc("C",
|
|
p2(N::in, M::out),
|
|
[will_not_call_mercury, promise_pure, may_not_export_body],
|
|
"
|
|
M = N + 10;
|
|
").
|