Files
mercury/vim/syntax
Julien Fischer 75a8a4a9b3 Add a new pragma, foreign_export_enum, that allows the names of constructors
Estimated hours taken: 30
Branches: main

Add a new pragma, foreign_export_enum, that allows the names of constructors
of Mercury enumeration types to be exported across the foreign language
interface and referred to by code in the foreign language.

The new pragma is intended to be used to avoid a situation that frequently
occurs when creating Mercury bindings to foreign language libraries, namely
arguments and return values being passed across the foreign language boundary
as small integers.  Exporting the names of enumeration values to foreign
languages should make this task less error prone and more portable.

Using the new construct programmers can either specify a foreign language name
for each enumeration constructor, or since this is tedious, there is also a
default mapping defined for each foreign language that should work in most
cases for that language.  (In the cases where it does not work the compiler
requires the programmer to provide a valid name.)

Currently, pragma foreign_export_enum is only supported by the C backends.

compiler/prog_data.m:
compiler/prog_item.m:
	Add a new item to the parse tree for representing
	foreign_export_enum pragmas.

compiler/prog_io_pragma.m:
	Parse the new pragma.

compiler/module_qual.m:
	Handle foreign_export_enum pragmas.

	Add a predicate to for module qualifying type_ctors, i.e. a
	type identified by its sym_name and arity, for use by the
	above.

compiler/mercury_to_mercury.m:
	Write out foreign_export_enum pragmas.

compiler/hlds_module.m:
	Add a type to represent exported enumerations.

	Add a field to the module_info to hold information about
	exported enumerations.  Add access procedures for this.

compiler/make_hlds_passes.m:
compiler/add_pragma.m:
	Handle foreign_export_enum pragmas: generate the set of foreign names
	for each of the constructors of an enumeration type and check that
	their validity in the foreign language.  Attach this information to
	the HLDS.

compiler/export.m:
	Output #defined constants for C foreign_export_enum pragmas in
	.mh files.

compiler/mlds.m:
	Add an MLDS specific representation of exported enumerations.

compiler/ml_type_gen.m:
	Convert the HLDS representation of exported enumerations into
	an MLDS specific one.

compiler/mlds_to_c.m:
	Output #defined constants for C foreign_export_enum pragmas in
	.mih files.

compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_tailcall.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
	Conform to the above changes to the MLDS.

compiler/mercury_compile.m:
	Pass the list of export enumerations to the code that writes
	out .mh files.

compiler/c_util.m:
	Add a predicate that tests if a string is a valid C identifier.

compiler/modules.m:
compiler/recompilation.version.m:
	Conform to the above changes.

doc/reference_manual.texi:
	Document the new pragma.

tests/hard_coded/Mmakefile:
tests/hard_coded/ee_dummy.{m,exp}:
tests/hard_coded/ee_valid.{m,exp}:
	Test valid uses of foreign_export_enum pragmas.

tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/ee_invalid.{m,err_exp}:
	Check we generate error messages for invalid
	foreign_export_enum pragmas.

NEWS:
	Announce the new pragma.

vim/syntax/mercury.vim:
	Highlight the new syntax.
2007-07-25 06:12:32 +00:00
..