mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
Estimated hours taken: 12
Branches: main
Implement `:- pragma foreign_export'. This is intended to be a replacement
for `:- pragma export'. The principle difference is that `:- pragma
foreign_export' allows you to restrict exports to a particular foreign
language. This language will usually be the target language but in the case
of backends that support multiple foreign languages, e.g. the IL backend, it
also allows us to restrict the exports to a subset of the available foreign
languages.
Add some support for exporting procedures in the Java backend. This is
currently undocumented because I cannot test it properly while the Java
backend is not working. (The reason for adding the support was to make sure
that all of the MLDS backends were handling foreign_export declarations
correctly.)
Make the compiler emit warnings about exports for Java, IL, C# and MC++ not
yet being implemented. For the latter two this is true. As mentioned above
this change adds some support for exports in the Java backend and there was
some pre-existing (but undocumented) support for exports to IL. (The warnings
can be deleted once exports for these languages are properly documented and/or
implemented.)
compiler/prog_item.m:
Rename the export item to foreign_export for consistency with the
rest of the items concerned with the foreign language interface.
Add an extra field to that item. The new field stores the foreign
language that the pragma applies to.
compiler/prog_io_pragma.m:
Parse foreign_export pragmas.
Implement `:- pragma export' declarations as a special case of
`:- pragma foreign_export' declarations.
compiler/add_pramga.m:
Rename some predicates.
Emit warnings about foreign_exports to languages that we do not
currently support.
compiler/export.m:
Rename some of the predicates in this module to make them more C
specific.
Handle foreign exports for the lowlevel C backend.
compiler/hlds_module.m:
Add an extra field to the pragma_exported_proc structure to hold the
name of the foreign language that the corresponding foreign_export
declaration is for.
compiler/mercury_to_mercury.m:
Add code to output foreign_export pragmas.
compiler/ml_code_gen.m:
Don't filter out exports for Java, C# and MC++. The Java exports
can now be passed down to mlds_to_java.m and the other two ought to
be caught by the frontend of the compiler.
compiler/mlds_to_java.m
Add a tentative implementation of pragma foreign_export for Java.
This is currently not documented in the reference manual because
it is (largely) untested.
compiler/mlds_to_c.m:
Change an if-then-else to a switch.
Add a sanity check. Exports for languages other than C should not
reach here.
compiler/mlds_to_il.m:
Update the TODO list at the head of this file.
Add a sanity check. Exports for languages other than IL should not
reach here.
compiler/dead_proc_elim.m:
compiler/det_analysis.m:
compiler/foreign.m:
compiler/handle_options.m:
compiler/make_hlds_passes.m:
compiler/mlds.m:
compiler/mlds_to_managed.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
Conform to the above changes.
Minor formatting changes.
doc/reference_manual.texi:
Add a new section to the foreign language interface chapter
documenting the new pragma.
Update the descriptions of the language specific bindings to include
the new pragma.
tests/hard_coded/Mmakefile:
tests/hard_coded/pragma_foreign_export.{m,exp}:
Make sure that we can parse the new syntax and run a simple program
that uses exported procedures.
tests/invalid/invalid_export_detism.{m,err_exp}:
Update this test case to conform to the new pragma name.
2 lines
13 B
Plaintext
2 lines
13 B
Plaintext
Hello World!
|