Commit Graph

5 Commits

Author SHA1 Message Date
Zoltan Somogyi
33eb3028f5 Clean up the tests in half the test directories.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the debugger tests,
    specify the new line numbers in .inp files and expect them in .exp files.
2015-02-14 20:14:03 +11:00
Peter Wang
417151ca01 Improve the C# backend.
Branches: main

Improve the C# backend.

C# foreign types remain commented out so as not to force an upgrade of the
bootstrap compiler yet.


compiler/handle_options.m:
        Enable static ground cells for C# backend.

compiler/ml_global_data.m:
        Make fields of static vector structures have `public' access.
        Local access doesn't make sense.

        Use structs to hold vector common data in C#.

        Conform to changes.

compiler/ml_proc_gen.m:
        Enable use_common_cells on C#.

        Conform to changes.

compiler/mlds.m:
        Rename `finality' to `overridability'.  The `final' keyword in Java
        has multiple meanings, so avoid that word.  Use the word `sealed'
        to describe classes or virtual methods which cannot be overridden,
        which is the keyword in C#.

compiler/ml_switch_gen.m:
        Remember the types of mlconst_foreign constants.  In the C# backend a
        foreign enum value needs to be cast to the right type.  For some
        reason, there was a field already which could be used for this purpose
        but was only ever set to mlds_native_int_type.

compiler/ml_type_gen.m:
        Replace ml_gen_final_member_decl_flags with
        ml_gen_const_member_decl_flags.  Return flags with the `sealed' flag
        unset, as that wouldn't make sense for member variables.

        Remember the type in mlconst_foreign.

compiler/ml_unify_gen.m:
        Remember the type in mlconst_foreign.

compiler/mlds_to_cs.m:
        Support static data in C#.

        Support foreign enumerations.

        Use the `default(T)' operator to initialise certain types of variables,
        particularly user-defined types, which the Mercury compiler may not
        know enumeration defined in another module, i.e. a value type, which
        cannot be initialised with `null'.

        Remove the requirement to add mark foreign types which are of value
        types with the "valuetype" prefix.

compiler/mlds_to_java.m:
        Write out the `final' keyword when either the `sealed' or `const' flags
        are set.

        Conform to changes.

compiler/rtti_to_mlds.m:
        RTTI data doesn't need the `sealed' flag set.

compiler/ml_code_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/ml_elim_nested.m:
        Conform to changes.

library/builtin.m:
        Export `comparison_result' to C# foreign code.

        Fix `deep_copy' for arrays.

library/bitmap.m:
library/pretty_printer.m:
library/store.m:
library/version_array.m:
library/version_hash_table.m:
        Implement these modules for C#.

library/io.m:
library/dir.m:
        Implement `dir.current_directory' for C#.

library/exception.m:
        Implement `catch_impl' for multi and nondet predicates.

library/rtti_implementation.m:
        Implement `get_typeclass_info_from_term' for C#.

library/string.m:
        Fix `string.set_char' for C#.

library/time.m:
        Delete now-unnecessary "valuetype" prefix on foreign type.

library/type_desc.m:
        Implement `make_type' for C#.

runtime/mercury_dotnet.cs.in:
        Collapse equivalences when comparing TypeInfo_Structs for equality.

tests/hard_coded/Mmakefile:
        Disable some tests in C# grade.

tests/hard_coded/ee_dummy.m:
tests/hard_coded/ee_valid_test.m:
tests/hard_coded/equality_pred_which_requires_boxing.m:
tests/hard_coded/exported_foreign_enum.m:
tests/hard_coded/export_test.m:
tests/hard_coded/external_unification_pred.m:
tests/hard_coded/float_gv.m:
tests/hard_coded/foreign_enum_dummy.m:
tests/hard_coded/foreign_import_module_2.m:
tests/hard_coded/foreign_name_mutable.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/foreign_type.m:
tests/hard_coded/hash_table_test.m:
tests/hard_coded/impure_init_and_final.m:
tests/hard_coded/intermod_poly_mode_2.m:
tests/hard_coded/loop_inv_test1.m:
tests/hard_coded/loop_inv_test.m:
tests/hard_coded/multimode.m:
tests/hard_coded/pragma_export.m:
tests/hard_coded/pragma_foreign_export.m:
tests/hard_coded/redoip_clobber.m:
tests/hard_coded/trace_goal_4.m:
tests/hard_coded/uc_export_enum.m:
tests/hard_coded/user_compare.m:
tests/hard_coded/write_xml.m:
        Make these test cases work on C#.

tests/hard_coded/deep_copy.exp3:
tests/hard_coded/expand.exp3:
tests/hard_coded/float_reg.exp3:
        Add expected results for C#.

tests/hard_coded/string_strip.exp2:
        Update this result, which was not updated when the test case changed
        previously.
2010-09-23 05:32:01 +00:00
Peter Wang
b50738a536 Don't box float and char fields in Java classes.
Branches: main

Don't box float and char fields in Java classes.

compiler/ml_code_util.m:
        Make ml_must_box_field_type take into account the compilation target,
        and not succeed for Java.

        Make ml_gen_box_const_rval only treat floats specially for C and asm
        grades, as per the comment.

compiler/mlds_to_java.m:
        Use '\u0000' as the initialiser for character values.

tests/hard_coded/ee_dummy.m:
tests/hard_coded/foreign_name_mutable.m:
        Unrelated: make these tests compile again in the java grade.
2009-09-24 03:29:26 +00:00
Peter Wang
75771a9b6e Allow testing of java grade. Requires using `mmc --make' for now.
Branches: main

Allow testing of java grade.  Requires using `mmc --make' for now.
This patch does not attempt to fix test failures.

tests/Mmake.common:
        Delete unneeded Java-specific rule, which was broken.

tests/benchmarks/Mmakefile:
tests/general/Mmakefile:
tests/general/string_format/Mmakefile:
tests/grade_subdirs/Mmakefile:
tests/hard_coded/Mmakefile:
tests/recompilation/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
        Don't deliberately disable tests in java grade.

tests/*.m:
        Add Java foreign code.

        Write dummy procedures instead of abusing `:- external'.
2009-08-14 03:21:55 +00:00
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