vim/syntax/mercury.vim:
Recognise //-style comments in C foreign code blocks.
Recognise `word_aligned_pointer' foreign type assertion.
Delete support for IL foreign code blocks.
vim/syntax/mercury.vim:
Accept suffixes on binary, octal, decimal and hexadecimal integer
literals (i, u, i8, u8, i16, u16, i32, u32, i64, u64),
with optional leading underscores.
Match integer and float literals only if they end at a word
boundary.
vim/syntax/mercury.vim:
Separate matches for Mercury and foreign-language numeric literals,
the latter matching C numeric literals.
Allow underscores in Mercury numeric literals.
Allow floats without fractional part.
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.
Use a less obtrusive default highlighting.
vim/doc/mercury.txt:
Conform to the changes in the *.vim files and fix minor errors.
vim/ftplugin/mercury.vim:
Make variable underlining optional (uses highlight_extra-flag).
Make all variables setlocal and key-mappings silent and buffer-local.
Introduce ,[pftiPMT] and <C-X>[iI] keymappings for rapid typing.
vim/syntax/mercury.vim:
Folding, special comment constructs, concealing operators, foreign
types are all disabled by default.
Increasing synmaxcol from 100 to 250.
Make ::, :, ^, | delimiters and improve colouring of atomic,
or_else, trace and require_* keywords.
Cleanup excessive C(Like)Types.
Clause head expression now correctly recognise zero-arity functions.
All special comment highlighting is strictly optional now.
This was reported and reviewed by Paul already.
vim/syntax/mercury.vim:
Fix spelling mistake and make the mercuryClauseHead expression
recognise digits.
This patch is a major rewrite of the Vim syntax file
(vim/syntax/mercury.vim), supporting following (optional) features:
- highlighting of foreign code, including all doubly escaped characters
such as "" or \\" in strings, etc.
- recognising \uXXXX \OOO\ and formatting specifiers in Mercury strings
- concealing of certain operators and infix functions such as /\,
the `compose` function from std_util,
and set-calculus related operators (`union`, ...)
- supporting markup within comments, i.e. as function headers, ` ',
``'', URIs and Mercury file names, TODO, NOTE, XXX and so on.
- support underlining of local variables within function or predicate
bodies, which is a feature found in SWI-Prolog.
Additionally one can use <C-K>r and <C-K>R to rename the underlined
variable.
- improved speed due to better overlong line detection and a sync on
Mercury line comments '%-----' instead of sync start, which is
noticeable for large files such as io.m.
- Different way of supporting transparent comment highlighting, such
that spell checking works only on comments in both fully highlighted
and partially highlighted comments, this works best if comment
markup is enables (see above).
Without this, spell checking would have to be enabled for Mercury
code as well which Vim is not good at.
- Improved folding support if no user defined setting is in place
- Matching parenthesis detection (here meaning (),[],{}) and marking
unbalanced parens as err
- highlighting of spurious whitespace for better patch management.
vim/.gitignore:
Ignore mercury.vba file.
vim/Makefile:
A makefile to create a Vimball (.vba) and install that.
vim/README:
Moved installation instructions to vim/doc/mercury.txt and point to
that file.
vim/doc/mercury.txt:
Moved the documentation part from mercury.vim to a Vim documentation
file.
vim/ftplugin/mercury.vim:
Adds highlighting and renaming of currently selected variables,
and enables ftplugin/mercuryhdr.sh on Windows.
vim/ftplugin/mercuryhdr.sh:
Adhere to Mercury coding standards.
vim/syntax/mercury.vim:
see above.
vim/README:
Removed warning about ~/.vim/after/filetype.vim,
Add utf-8 encoding detection.
Added more details to the Vim README and
vim/after/filetype.vim:
vim/ftdetect/mercury.vim.
Renamed file type detection for Mercury to ftdetect/mercury.vim. This
allows one to install the vim configuration files with a single command:
$ cp -r vim/ ~/.vim
vim/syntax/mercury.vim:
Fixed escaping of the escape character in strings,
Branches: main, 11.01
Update the vim syntax file.
vim/syntax/mercury.vim:
Highlight the recently added scopes.
Delete some stuff related to the old C interface.
Branches: main
Add support for `try' goals, syntactic sugar on top of the exception handling
predicates in the standard library. The syntax is documented in the reference
manual. Currently one of the proposed try parameters, io(!IO), is implemented.
Try goals are implemented by *two* source-to-source transformations, one at the
parse tree level, then a later one on the HLDS. The reason for this is given
in try_expand.m.
library/ops.m:
Add three new operators: try, catch, catch_any.
library/exception.m:
Add forwarding predicates so that code generated by the try goal
transformation doesn't need to import `univ'.
compiler/prog_item.m:
Add representations of try goals to parse tree.
compiler/prog_io_goal.m:
Parse try goals.
Unrelated: fix spelling of "parameter".
compiler/add_clause.m:
Perform the initial transformation on try goals.
compiler/hlds_goal.m:
Add try goals to HLDS, as shorthand goals.
compiler/try_expand.m:
New module to perform the latter transformation on try goals.
compiler/check_hlds.m:
Import the new module.
compiler/mercury_compile.m:
Call the try_expand pass near the end of the front-end pass.
compiler/module_imports.m:
Implicitly import `exception' if a `try' goal is seen.
compiler/det_analysis.m:
Conform to addition of try goals in HLDS. Make it not wrap a commit
scope around the intermediate try goal (as it might if there are no
outputs) as it is inappropriate.
compiler/prog_util.m:
Conform to parse tree changes.
compiler/assertion.m:
compiler/build_mode_constraints.m:
compiler/cse_detection.m:
compiler/delay_partial_inst.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/equiv_type_hlds.m:
compiler/format_call.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/make_hlds_warn.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/ordering_mode_constraints.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/quantification.m:
compiler/simplify.m:
compiler/stm_expand.m:
compiler/stratify.m:
compiler/structure_reuse.lfu.m:
compiler/switch_detection.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unique_modes.m:
compiler/unused_imports.m:
Conform to changes in HLDS.
compiler/il_peephole.m:
compiler/ilasm.m:
compiler/ilds.m:
compiler/mlds_to_il.m:
Rename some symbols to avoid the new keywords.
library/exception.m:
Add two helper predicates for the try goal transformations.
doc/reference_manual.texi:
NEWS:
Document and announce the new language feature.
compiler/notes/compiler_design.html:
Note new compiler module.
tests/hard_coded/Mmakefile:
tests/hard_coded/try_syntax_1.exp:
tests/hard_coded/try_syntax_1.m:
tests/hard_coded/try_syntax_2.exp:
tests/hard_coded/try_syntax_2.m:
tests/hard_coded/try_syntax_3.exp:
tests/hard_coded/try_syntax_3.m:
tests/hard_coded/try_syntax_4.exp:
tests/hard_coded/try_syntax_4.m:
tests/hard_coded/try_syntax_5.exp:
tests/hard_coded/try_syntax_5.m:
tests/hard_coded/try_syntax_6.exp:
tests/hard_coded/try_syntax_6.m:
tests/hard_coded/try_syntax_7.exp:
tests/hard_coded/try_syntax_7.m:
tests/invalid/Mmakefile:
tests/invalid/try_bad_params.err_exp:
tests/invalid/try_bad_params.m:
tests/invalid/try_io_else.err_exp:
tests/invalid/try_io_else.m:
Add test cases.
tests/debugger/declarative/catch.m:
The module name is now a keyword so requires brackets.
tests/invalid/trace_goal_env.err_exp:
Update test case for fixed spelling for "parameter".
vim/syntax/mercury.vim:
Add try, catch, catch_any as keywords.
Estimated hours taken: 80 by zs, and lots more by lmika
Branches: main
Provide compiler support for Software Transactional Memory through the new
atomic goal. This work was done by Leon Mika; I merely brought it up to date,
resolved conflicts, and cleaned up a few things. There are still several
aspects that are as yet incomplete.
library/ops.m:
Add the operators needed for the syntax of atomic scopes.
library/stm_builtin.m:
Add the builtin operations needed for the implementation of atomic
goals.
compiler/hlds_goal.m:
Add a new HLDS goal type, which represents an atomic goal and its
possible fallbacks (in case an earlier goal throws an exception).
Rename the predicate goal_is_atomic as goal_expr_has_subgoals,
since now its old name would be misleading.
compiler/prog_data.m:
compiler/prog_item.m:
Add a parse tree representation of the new kind of goal.
compiler/prog_io_goal.m:
Parse the new kind of goal.
compiler/add_clause.m:
Translate atomic goals from parse tree form to HLDS.
compiler/typecheck.m:
compiler/typecheck_errors.m:
Do type checking of atomic goals.
compiler/modes.m:
Do mode checking of atomic goals, and determine whether they are nested
or not.
compiler/unique_modes.m:
Do unique mode checking of atomic goals.
compiler/stm_expand.m:
New module to expand atomic goals into sequences of simpler goals.
library/stm_builtin.m:
Add the primitives needed by the transformation.
Improve the existing debugging support.
mdbcomp/prim_data.m:
Add utility functions to allow stm_expand.m to refer to modules in the
library.
mdbcomp/program_representation.m:
Expand the goal_path type to allow the representation of components of
atomic goals.
compiler/notes/compiler_design.html:
Document the new module.
compiler/transform_hlds.m:
Include the new module in the compiler.
compiler/mercury_compile.m:
Invoke the STM transformation.
compiler/hlds_module.m:
Add an auxiliary counter used by the STM transformation.
compiler/hlds_pred.m:
Add a new predicate origin: the STM transformation.
compiler/modules.m:
Import the STM builtin module automatically if the module contains any
atomic goals.
compiler/assertion.m:
compiler/bytecode_gen.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/code_util.m:
compiler/constraint.m:
compiler/cse_detection.m:
compiler/deep_profiling.m:
compiler/code_util.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/erl_code_gen.m:
compiler/exception_analysis.m:
compiler/follow_code.m:
compiler/format_call.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hlds_out.m:
compiler/implicit_parallelism.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/lookup_switch.m:
compiler/make_hlds_warn.m:
compiler/mark_static_terms.m:
compiler/mercury_to_mercury.m:
compiler/middle_rec.m:
compiler/ml_code_gen.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/ordering_mode_constraints.m:
compiler/pd_cost.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prog_type.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.actual_region_arguments.m:
compiler/rbmm.add_rbmm_goal_info.m:
compiler/rbmm.condition_renaming.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/saved_vars.m:
compiler/simplify.m:
compiler/size_prog.m:
compiler/smm_common.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
compiler/switch_detection.m:
compiler/unused_imports.m:
compiler/granularity.m:
compiler/granularity.m:
Conform to the changes above. Mostly this means handling the new
kind of goal.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/build_mode_constraints.m:
compiler/closure_analysis.m:
compiler/dead_proc_elim.m:
compiler/deforest.m:
compiler/follow_vars.m:
compiler/higher_order.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/loop_inv.m:
compiler/module_qual.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/quantification.m:
compiler/store_alloc.m:
compiler/stratify.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/trailing_analysis.m:
Conform to the changes above. Mostly this means handling the new
kind of goal.
Switch syntax from clauses to disj.
runtime/mercury_stm.[ch]:
Implement the primitives needed by the STM transformation.
Add more debugging support to the existing primitives.
library/term.m:
Generalize get_term_context to work on terms of all kinds.
Estimated hours taken: 50
Branches: main
Add support for foreign enumerations to Mercury. These allow the
programmer to assign foreign language values as the representation of
enumeration constructors.
e.g.
:- type status
---> optimal
; infeasible
; unbounded
; unknown.
:- pragma foreign_enum("C", status/0, [
optimal - "STATUS_OPTIMAL",
infeasible - "STATUS_INFEASIBLE",
unbounded - "STATUS_UNBOUNDED",
unknown - "STATUS_UNKNOWN"
]).
The advantage of this is that when values of type status/0 are passed to
foreign code (C in this case) no translation is necessary. This should
simplify the task of writing bindings to foreign language libraries.
Unification and comparison for foreign enumerations are the usual
unification and comparison for enumeration types, except that the default
ordering on them is determined by the foreign representation of the
constructors. User-defined equality and comparison also work for foreign
enumeration types.
In order to implement foreign enumerations we have to introduce two
new type_ctor representations. The existing ones for enum type do not
work since they use the value of an enumeration constructor to perform
table lookups in the RTTI data structures. For foreign enumerations
we need to perform a linear search at the corresponding points. This
means that some RTTI operations related to deconstruction are more
expensive.
The dummy type optimisation is not applied to foreign enumerations as
the code generators currently initialise the arguments of non-builtin
dummy type foreign_proc arguments to zero. For unit foreign enumerations
they should be initialised to the correct foreign value. (This is could be
implemented but in practice it's probably not going to be worth it.)
Currently, foreign enumerations are only supported by the C backends.
compiler/prog_io_pragma.m:
Parse foreign_enum pragmas.
Generalise the code used to parse association lists of sym_names
and strings since this is now used by the code to parse foreign_enum
pragmas as well as that for foreign_export_enum pragmas.
Fix a typo: s/foreign_expor_enum/foreign_export_enum/
compiler/prog_item.m:
Represent foreign_enum pragmas in the parse tree.
compiler/prog_type.m:
Add a new type category for foreign enumerations.
compiler/modules.m:
Add any foreign_enum pragmas for enumeration types defined in the
interface of a module to the interface files.
Output foreign_import_module pragmas in the interface file
if any foreign_enum pragmas are included in it. This ensures that
the contents that any foreign declarations that are needed by the
foreign_enum pragmas are visible.
compiler/make_hlds_passes.m:
compiler/add_pragma.m:
Add pragma foreign_enum items to the HLDS after all the types
have been added. As they are added, error check them.
Change the constructor tag values of foreign enum types to their
foreign values.
compiler/module_qual.m:
Module qualify pragma foreign_enum items.
compiler/mercury_to_mercury.m:
Output foreign_enum pragmas.
Generalise some of the existing code for writing out association
lists in foreign_export_enum pragmas for use with foreign_enum
pragmas as well.
compiler/hlds_data.m:
Add the alternative `is_foreign_type' to the type enum_or_dummy/0.
Add new type of cons_tag, foreign_tag, whose values are directly
embedded in the target language.
compiler/intermod.m:
Write out any foreign_enum pragmas for opt_exported types.
(The XXX concerning attaching language information to foreign tags
will be addressed in a subsequent change.)
compiler/llds.m:
compiler/mlds.m:
Support new kinds of rval constants: llconst_foreign and
mlconst_foreign respectively. Both of these represent tag values
as strings that are intended to be directly embedded in the target
language.
compiler/llds_out.m:
Add code to write out the new kind of rval_const.
s/Integer/MR_Integer/ in a spot.
s/Float/MR_Float/ in a spot.
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/type_ctor_info.m:
Add support the RTTI required by foreign enums.
compiler/switch_util.m:
Handle switches on foreign_enums as-per normal enumerations.
compiler/table_gen.m:
Tabling of foreign_enums is also like normal enumerations.
compiler/type_util.m:
Add a predicate that tests whether a type is a foreign enumeration.
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/ml_unify_gen.m:
Handle unification and comparison of foreign enumeration values.
They are treated like normal enumerations for the purposes of
implementing these operations.
compiler/ml_type_gen.m:
Handle foreign enumerations when generating the MLDS representation
of enumerations.
compiler/ml_util.m:
Add a function to create an initializer for an object with a
foreign tag.
compiler/mlds_to_c.m:
Handle mlconst_foreign/1 rval constants.
compiler/bytecode_gen.m:
compiler/dupproc.m:
compiler/erl_rtti.m:
compiler/exception_analysis.m:
compiler/export.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/hlds_out.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/jumpopt.m:
compiler/llds_to_x86_64.m:
compiler/ml_code_util.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/recompilation.version.m:
compiler/term_norm.m:
compiler/trailing_analysis.m:
Conform to the above changes.
doc/reference_manual.texi:
Document the new pragma.
Fix some typos: s/pramga/pragma/, s/behavior/behaviour/
library/construct.m:
Handle the two new type_ctor reps.
Break an over-long line.
library/rtti_implementation.m:
Support the two new type_ctor reps.
(XXX The Java versions of some of this cannot be implemented until
support for foreign enumerations is added to mlds_to_java.m.)
Reformat the inst usereq/0 and extend it to include foreign enums.
runtime/mercury_type_info.h:
Add two new type_ctor reps. One for foreign enumerations and
another for foreign enumerations with user equality.
Define new types (and extend existing ones) in order to support
RTTI for foreign enumerations.
runtime/mercury_unify_compare_body.h:
Implement generic unify and compare for foreign enumerations.
(It is the same as that for regular enumerations.)
runtime/mercury_construct.[ch]:
runtime/mercury_deconstruct.h:
Handle (de)construction of foreign enumeration values.
runtime/mercury_deep_copy_body.h:
Implement deep copy for foreign enumerations.
runtime/mercury_table_type_body.h:
runtime/mercury_term_size.c:
Handle the new type_ctor representations.
java/runtime/ForeignEnumFunctorDesc.java:
Add a Java version of the MR_ForeignEnumFuntorDesc structure.
(Note: this is untested, as the java grade runtime doesn't work
anyway.)
java/runtime/TypeFunctors.java:
Add a constructor method for foreign enumerations.
(Likewise, untested.)
NEWS:
Announce pragma foreign_enum.
vim/syntax/mercury.vim:
Highlight the new pragma appropriately.
tests/hard_coded/.cvsignore:
Ignore executables generated by the new tests.
Ignore a bunch of other files create by the Mercury compiler.
tests/hard_coded/Mmakefile:
tests/hard_coded/foreign_enum_rtti.{m,exp}:
Test RTTI for foreign enumerations.
tests/hard_coded/foreign_enum_dummy.{m,exp}:
Check that dummy type optimisation is disabled for foreign
enumerations.
tests/hard_coded/Mercury.options:
tests/hard_coded/foreign_enum_mod1.{m,exp}:
tests/hard_coded/foreign_enum_mod2.m:
Test that foreign_enum pragmas are hoisted into interface files
and that they are handled correctly in optimization interfaces.
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
tests/invalid/foreign_enum_import.{m,err_exp}:
tests/invalid/foreign_enum_invalid.{m,err_exp}:
Test that errors in foreign_enum pragmas are reported.
tests/tabling/Mmakefile:
tests/hard_coded/table_foreign_enum.{m,exp}:
Test case for tabling of foreign enumerations.
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.
Estimated hours taken: 1
Branches: main
Various minor cleanups and syntax updates for the standard library.
There are no changes to any algorithms.
library/injection.m:
library/set.m:
library/sparse_bitset.m:
Use promise_equivalent_clauses where appropriate.
library/set_ordlist.m:
library/set_unordlist.m:
Convert these module to 4-space indentation:
Convert these module to 4-space indentation
library/*.m:
Convert some if-then-elses into switches.
Remove unnecessary module qualification - this is related
mainly to the breakup of std_util and the fact that on
the 0.13 branche we had two versions of the all-solutions
predicates.
Various other style cleanups.
vim/syntax/mercury.vim:
Highlight promise_equivalent_clauses appropriately.
Estimated hours taken: 3
Branches: main
Further improve trail usage optimization by omitting reset_undo_ticket
instructions from disjuncts where the previous disjunct did not modify the
trail. This can be done even in disjunctions where some of the disjuncts do
modify the trail. At the moment this optimization is only implemented
for the MLDS backend - I'll add it to the lowlevel backend as a separate
change.
compiler/add_trail_ops.m:
Implement the above optimization for the MLDS backend.
compiler/goal_form.m:
Add a predicate goal_may_modify_trail.
compiler/mercury_compile.m:
Add a comment mentioning that after we have added trail ops
(stage 410) to the HLDS we can no longer reorder disjunctions.
This should be okay since none of the following passes reorder
disjunctions anyway.
vim/syntax/mercury.vim:
Highlight `will_not_modify_trail' and `may_modify_trail'
appropriately.
NEWS:
Make the description of what trail usage optimization does more
precise. It affects goals other than if-then-elses, notably
disjunctions and negations as well.
Estimated hours taken: 8
Branches: main
Add optional support for generating a pure interface to mutables. This is
done by adding a new mutable attribute, `attach_to_io_state'. If this
attribute is specified in the mutable declaration then in addition to the
usual non-pure access predicates, the compiler will also add a pair of access
predicates that take the IO state.
compiler/prog_data.m:
Add the `attach_to_io_state' mutable attribute.
Add the necessary access predicates for the mutable_var_attributes
structure.
compiler/prog_io.m:
Parse the `attach_to_io_state' attribute.
compiler/prog_mutable.m:
Shift some of the code for constructing items related to mutables to
this module from make_hlds_passes. This reduces unnecessary clutter in
the latter.
Remove the XXX comment about needing to mangle the names of the
globals - we now do that.
compiler/make_hlds_passes.m:
If a mutable has the `attach_to_io_state' attribute specified then
create pure access predicates that take the IO state in addition
to the non-pure ones.
compiler/modules.m:
If we are generating the pure access predicates then output the
declarations for these predicates in private interfaces.
compiler/type_util.m:
Replace the use of ':' as a module qualifier in some comments.
doc/reference_manual.texi:
Document the `attach_to_io_state' mutable attribute.
vim/syntax/mercury.vim:
Highlight various mutable attributes appropriately.
tests/hard_coded/Mmakefile:
tests/hard_coded/pure_mutable.m:
tests/hard_coded/pure_mutable.exp:
Test mutables with pure access predicates.
tests/hard_coded/ppc_bug.m:
Unrelated change: update the comments in this test case so
they describe what the cause of the bug and the fix were.
Estimated hours taken: 4
Branches: main
Support impure initialise and finalise predicates in user code. In order to
support this the arity of the initialise or finalise predicate can no longer be
optionally omitted from the declaration. Supporting impure arity zero
initialise/finalise declarations removes the restriction that every module that
has an initialise/finalise declaration must import the io module.
Allow initialize/finalize to be used as synonyms for initialise/finalise.
Improve the documentation of initialise/finalise declarations.
In particular:
- mention the above changes.
- mention that they may be cc_multi.
- specify the order in which they invoked with respect to
standard library initialisation/finalisation.
- mention that these declarations are not currently available
on non-C backends.
compiler/make_hlds_passes.m:
Support impure user initialise/finalise predicates.
compiler/mercury_to_mercury.m:
Write out the arities of the predicates specified in
initialise and finalise declarations.
compiler/prog_data.m:
Add an arity field to the initialise and finalise items.
compiler/prog_io.m:
Don't allow the arity to be omitted in initialise and finalise
declarations.
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the changes in the initialise and finalise items.
library/ops.m:
Add the alternate spellings of initialise and finalise to the ops
table.
doc/reference_manual.texi:
Update the ops table.
Mention that initialise and finalise predicates may be cc_multi.
Document impure initialisation and finalisation predicates.
Add some disclaimers: mutable, initialise and finalise declarations
are not implemented for the non-C backends.
tests/hard_coded/Mmakefile:
tests/hard_coded/impure_init_and_final.m:
tests/hard_coded/impure_init_and_final.exp:
Test impure initialise and finalise declarations.
tests/hard_coded/finalise_decl.m:
tests/hard_coded/intialise_decl.m:
Conform to the above changes. Also test the versions of the
declarations that use the -ize ending.
tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/initialise_child.m:
tests/hard_coded/sub-modules/initialise_parent.m:
Conform to the above changes.
tests/invalid/bad_finalise.m:
tests/invalid/bad_finalise.err_exp:
tests/invalid/bad_initialise.m:
tests/invalid/bad_initialise.err_exp:
Extend these tests to check for missing or bad arities
in intialise or finalise declarations.
vim/syntax/mercury.vim:
Highlight recently added syntax appropriately.
Estimated hours taken: 12
Branches: main
Improve the error checking for mutable declarations.
Fix a bug with solver types and sub-modules reported by Peter Hawkins.
Workaround a bug with mutable declarations and sub-modules. Currently,
the compiler aborts if there is a mutable declaration in the parent module.
With this change mutable declarations will not be visible in child modules.
XXX This is not correct since they should be visible, but this can be fixed
as a separate change.
compiler/prog_data.m:
Extend the item_origin type with information about what
source-to-source transformations are responsible for compiler
introduced items. We need this information for error checking mutable
declarations. It also provides an additional layer of sanity checking
in the parse tree.
Add origin fields to the clause and initialise items, since they can
both now be introduced by source-to-source transformations.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_typeclass.m:
Conform to the above change.
compiler/make_hlds_passes.m:
Don't issue spurious errors about initialise declarations that were
introduced by the transformation for mutable declarations. Abort if
invalid initialise declarations were introduced by other compiler
passes since this indicates a bug in the compiler.
Check if mutable declarations occur in the interface of a module and
emit an error if they do.
Don't generate initialise items and foreign code from a mutable
declaration unless we are in the defining module for the mutable
declaration.
Don't generate foreign_procs for solver types *unless* we are in the
defining module. Doing otherwise breaks the compiler when using
solver types and sub-modules.
Fix the formatting of an error message concerning initialise decls.
s/foreign_code/foreign_proc/ in a spot.
compiler/add_solver.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/add_class.m:
compiler/add_pragma.m:
compiler/state_var.m:
Conform to the above changes.
compiler/modules.m:
Handle mutable declarations in private interfaces.
Clean up some code related to foreign_import_module decls.
Conform to the changes in prog_data.m.
compiler/prog_util.m:
Shift the functions for mutable access predicates and variables to
this module. The code that generates interface files also needs to be
able to access them.
compiler/module_qual.m:
Conform to the above changes.
Fix a bug where the context in the mq_info structure was not being
updated. This caused error messages for mutable declarations that
contain undefined types or insts to have the wrong context.
compiler/hlds_data.m:
Fix a typo.
vim/syntax/mercury.vim:
Highlight `mutable' and `untrailed' appropriately.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/ts.m:
tests/hard_coded/sub-modules/ts.tsub.m:
tests/hard_coded/sub-modules/ts.exp:
Add Peter Hawkin's test case for the bug with solver
types and sub-modules.
tests/invalid/Mmakefile:
tests/invalid/bad_mutable.m:
tests/invalid/bad_mutable.err_exp:
Add a test for the various sorts of errors that can occur with mutable
declarations.
Estimated hours taken: 1.5
Branches: main
Fix a problem with the new initialise declarations and sub-modules.
compiler/modules.m:
Don't write `:- initialise' declarations to private interfaces.
The compiler cannot read them back in and in any case child
modules don't need to know about them.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/initialise_parent.m:
tests/hard_coded/sub-modules/initialise_child.m:
tests/hard_coded/sub-modules/initialise_parent.exp:
tests/hard_coded/sub-modules/initialise_parent.exp2:
Test case for the above. (There are two expected outputs
because the ordering of calls to module initialisers between
a parent and its children is arbitrary.)
vim/syntax/mercury.vim:
Highlight initialise declarations appropriately.
Estimated hours taken: 4.5
Branches: main
Add a new foreign proc attribute `maybe_thread_safe' and
a new compiler option `--maybe-thread-safe'.
The thread safety of foreign procs that have the `maybe_thread_safety'
attribute set is dependent upon the value of the `--maybe-thread-safe'
option. This facility is intended for use in writing bindings to
libraries whose thread safety is itself conditional.
At quite an early stage `maybe_thread_safe' is turned into
either `thread_safe' or `not_thread_safe' depending on the
value of the `--maybe-thread-safe' option. In particular,
it will appear as either `thread_safe' or `not_thread_safe'
in any optimization interfaces.
compiler/prog_io_pragma.m
compiler/prog_data.m
Parse the new foreign code attribute, `maybe_thread_safe'.
Fix a place where the line width was > 79 characters.
compiler/options.m:
compiler/globals.m:
compiler/handle_options.m:
Add a new option `--maybe-thread-safe' that tells the compiler
how to handle `maybe_thread_safe' foreign code attributes.
compiler/make_hlds.m:
Convert any `maybe_thread_safe' attributes into `thread_safe'
or `not_thread_safe' attributes depending upon the value of the
`--maybe-thread-safe' option.
compiler/pragma_c_gen.m:
Call unexpected/2 if we encounter the `maybe_thread_safe'
attribute here, as it should have been replaced with either
`thread_safe' or `not_thread_safe' by this point.
doc/reference_manual.texi:
doc/user_guide.texi:
Document the new attribute and option.
vim/syntax/mercury.vim:
Highlight the new attribute.
Estimated hours taken: 6
Branches: main
Add the foreign proc. attribute `will_not_throw_exception'.
This allows the user to promise the exception analysis that
foreign procs that do not have determinism erroneous and make
calls back to Mercury will not throw an exception.
The behaviour for erroneous foreign procs and those that do
not make calls back to Mercury is unchanged.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Handle the new attribute.
compiler/exception_analysis.m:
If the user has provided the `will_not_throw_exception'
attribute on a foreign proc that makes calls back to
Mercury then set then have the exception analysis
take account of this information.
Fix a typo.
compiler/det_analysis.m:
compiler/det_report.m:
Emit an error if the `will_not_throw_exception'
attribute is used on foreign procs. that have
been declared erroneous.
doc/reference_manual.texi:
Mention the new foreign proc attribute.
tests/term/Mmakefile:
tests/term/Mercury.options:
tests/term/promise_no_throw_exception.m:
tests/term/promise_no_throw_exception.trans_opt_exp:
tests/invalid/Mmakefile:
tests/invalid/erroneous_promise_throw.m:
tests/invalid/erroneous_proimse_throw.err_exp:
Test cases for the above.
vim/syntax/mercury.vim:
Highlight the annotation appropriately.
not attempt to highlight C comments inside strings.
Doing so results in code like the following being
incorrectly highlighted - (thanks to Ralph for fixing this).
io.write_string("/*", !IO),
io.write_string("foo", !IO),
io.write_string("*/", !IO)
vim/syntax/mercury.vim:
Fix highlighting of strings that contain C comments.
Highlight `tabled_for_io' as we do for other foreign
code attributes.
Estimated hours taken: 0.25
Branches: main
vim/syntax/mercury.vim:
When checking for lines with length > 80 columns,
handle tabs properly (assuming the tab size 8).
Etimated hours taken: 8
Branches: main
Files and instructions for adding Mercury syntax highlighting under Vim 6.0.
NEWS:
Mention the new directory.
vim:
vim/after:
vim/after/filetype.vim:
vim/ftplugin:
vim/ftplugin/mercury.vim:
vim/ftplugin/mercuryhdr.vim:
vim/syntax:
vim/syntax/mercury.vim:
vim/README:
New directory structure added and populated.
bindist/Mmakefile:
Added VIM_FILES variable and commands to create
$(MERCURY_VERSION)/vim if necessary and populate it.