mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-18 07:15:19 +00:00
34a278b75b39f3367d35c640909a78f394d4ca74
6 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
660a24a7ad |
Fix a bug reported by Michael Day which caused spurious
Estimated hours taken: 8 Branches: main, release Fix a bug reported by Michael Day which caused spurious "predicate multiply defined" errors if there were predicates `module1.p' and `module2.module1.p'. compiler/hlds_module.m: For each of the predicate table search predicates which takes a module, add an extra argument which states whether the module name passed in is fully qualified. If it is, then a search for `module1.p' will not return `module2.module1.p'. The module name is guaranteed to be fully qualified for the head of predicate, clause, etc. items, and for calls occurring in `.opt' files. Add a predicate `lookup_builtin_pred_proc_id', for looking up the builtin predicates in the predicate table. compiler/goal_util.m: Move code to look up builtin predicates into hlds_module.m. Set the builtin_state field of the call goal returned by generate_simple_call correctly. compiler/hlds_pred.m: Add a function `calls_are_fully_qualified' which takes an import_status, and returns whether calls from goals with that status are always fully qualified, which is true iff the call is in a `.opt' file. compiler/prog_io.m: Module qualify the sym_names in `:- external' items. compiler/*.m: Fill in the extra argument of predicate table searches. Use `lookup_builtin_pred_proc_id' rather than `predicate_table_search_*'. compiler/prog_util.m: Add function versions of mercury_*_builtin_module. compiler/polymorphism.m: compiler/simplify.m: compiler/unify_proc.m: Use goal_util__generate_simple_call to call builtins, rather than duplicating the code. tests/valid/Mmakefile: tests/valid/nested_module_bug.m: tests/valid/intermod_bug_nested.m: Test cases. |
||
|
|
ef7ed9c2f5 |
Support impurity declarations for higher-order code.
Estimated hours taken: 24 Branches: main Support impurity declarations for higher-order code. In particular, allow `impure' and `semipure' annotations on higher-order types, higher-order calls, and lambda expresions. NEWS: doc/reference_manual.texi: Document the new language feature. compiler/hlds_goal.m: compiler/hlds_pred.m: Add `purity' field to - the `higher_order' alternative of the hlds_goal.generic_call type - the `higher_order' alternative of the hlds_pred.generic_call_id type - the `lambda_goal' alternative of the hlds_goal.unify_rhs type compiler/type_util.m: Add a new `purity' argument to the procedures dealing with higher-order types. Add code for parsing impure/semipure higher-order types. compiler/lambda.m: compiler/make_hlds.m: compiler/typecheck.m: compiler/post_typecheck.m: compiler/purity.m: compiler/polymorphism.m: Various minor changes to support impure/semipure higher-order lambda expressions. compiler/polymorphism.m: compiler/pseudo_type_info.m: XXX ought to change these to include purity in the RTTI for higher-order function types. compiler/simplify.m: Don't try to optimize semipure/impure higher-order calls. compiler/assertion.m: compiler/bytecode_gen.m: compiler/call_gen.m: compiler/continuation_info.m: compiler/cse_detection.m: compiler/dead_proc_elim.m: compiler/deep_profiling.m: compiler/det_analysis.m: compiler/det_util.m: compiler/equiv_type.m: compiler/goal_util.m: compiler/higher_order.m: compiler/hlds_out.m: compiler/intermod.m: compiler/magic.m: compiler/magic_util.m: compiler/ml_call_gen.m: compiler/ml_closure_gen.m: compiler/mode_util.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: compiler/modes.m: compiler/module_qual.m: compiler/pd_util.m: compiler/prog_rep.m: compiler/pseudo_type_info.m: compiler/quantification.m: compiler/recompilation.usage.m: compiler/rl_gen.m: compiler/stratify.m: compiler/switch_detection.m: compiler/term_traversal.m: compiler/term_util.m: compiler/unify_gen.m: compiler/unique_modes.m: Trivial changes to handle the new purity fields and/or arguments. tests/hard_coded/purity/Mmakefile: tests/hard_coded/purity/impure_func_t5_fixed2.m: tests/hard_coded/purity/impure_func_t5_fixed2.exp: tests/hard_coded/purity/impure_func_t5_fixed2.exp2: tests/hard_coded/purity/impure_pred_t1_fixed3.m: tests/hard_coded/purity/impure_pred_t1_fixed3.exp: tests/invalid/purity/Mmakefile: tests/invalid/purity/impure_func_t5_fixed.m: tests/invalid/purity/impure_func_t5_fixed.err_exp: tests/invalid/purity/impure_pred_t1_fixed.m: tests/invalid/purity/impure_pred_t1_fixed.err_exp: Add new test cases to test the new feature. tests/invalid/purity/impure_func_t5.err_exp: tests/invalid/purity/impure_pred_t1.err_exp: tests/invalid/purity/impure_pred_t2.err_exp: tests/invalid/purity/purity.err_exp: tests/invalid/purity/purity_nonsense.err_exp: Update the expected error messages for existing test cases. tests/invalid/purity/.cvsignore: New file, copied from tests/invalid/.cvsignore. |
||
|
|
17f53149a4 |
Implement `:- pragma reserve_tag(<TypeName>/<Arity>).'.
Estimated hours taken: 6 Branches: main Implement `:- pragma reserve_tag(<TypeName>/<Arity>).'. This has the same effect as the `--reserve-tag' option, except that it only applies to specified type, rather than to all types. doc/reference_manual.texi: Document the new feature. (However, the documentation is currently commented out.) compiler/prog_data.m: Add `reserve_tag(sym_name, arity)' to the `pragma_type' type. compiler/hlds_data.m: Add a new boolean field to the representation of discriminated union type bodies to record whether or not the type has a reserved tag. compiler/prog_io_pragma.m: Add code to parse the new pragma. compiler/make_hlds.m: Add code to process the new pragma: - check all the appropriate semantic restrictions: - the pragma must have the same visibility as the type - the type must be defined - the type must be a discriminated union type - warn if there are multiple such pragmas for the same type - call make_tags.m to recompute the tags used for the constructor. - record the presence of the reserve_tag pragma in the HLDS type definition body compiler/make_tags.m: compiler/type_util.m: Add an extra argument to assign_constructor_tags (in make_tags.m) and type_constructors_should_be_no_tag (in type_util.m) to specify whether or not there was a `reserve_tag' pragma. Reserve a tag if either this argument or the global `reserve_tag' option is set. compiler/intermod.m: Output a `:- reserve_tag' pragma whenever outputting a type to which such a pragma applies. compiler/ml_type_gen.m: compiler/ml_unify_gen.m: Ignore the reserved_tag field. XXX This means that the `reserve_tag' pragma (or the compiler option) won't have much effect if --high-level-data is set. compiler/code_util.m: compiler/det_report.m: compiler/hlds_out.m: compiler/magic_util.m: compiler/mercury_to_mercury.m: compiler/mode_util.m: compiler/module_qual.m: compiler/modules.m: compiler/post_typecheck.m: compiler/recompilation.usage.m: compiler/recompilation.version.m: compiler/special_pred.m: compiler/stack_opt.m: compiler/switch_util.m: compiler/table_gen.m: compiler/term_util.m: compiler/type_ctor_info.m: compiler/unify_gen.m: compiler/unify_proc.m: Trivial changes to handle the new reserved_tag field of hlds_type_defn_body. tests/valid/Mmakefile: tests/valid/reserve_tag.m: tests/invalid/Mmakefile: tests/invalid/reserve_tag.m: tests/invalid/reserve_tag.err_exp: Some tests of the new feature. |
||
|
|
0387a6e9c2 |
Improvements for `:- pragma foreign_type'.
Estimated hours taken: 10
Branches: main
Improvements for `:- pragma foreign_type'.
- Allow default Mercury definitions. The Mercury definition must define
a discriminated union type. The constructors of the Mercury type are
only visible in predicates which have implementations for all the
foreign languages the type has implementations for. In all other
predicates the type is treated as an abstract type (the check for
this isn't quite right).
- Allow polymorphic foreign types.
- Don't require the `:- pragma foreign_type' for exported foreign types
to be in the interface. We now only require that all definitions
have the same visibility.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Allow polymorphic foreign types.
compiler/prog_io.m:
Export code to parse the type name in a type definition for
use by prog_io_pragma.m.
compiler/make_hlds.m:
Handle Mercury definitions for foreign types.
Separate out the code to add constructors and special predicates
to the HLDS into a separate pass. For foreign types, we don't know
what to add until all type definitions have been seen.
Use the C definition for foreign types with `--target asm'.
compiler/modules.m:
Distinguish properly between `exported' and `exported_to_submodules'.
Previously, if a module had sub-modules, all declarations,
including those in the interface, had import_status
`exported_to_submodules'. Now, the declarations in the
interface have status `exported' or `abstract_exported'.
This is needed to check that the visibility of all the
definitions of a type is the same.
compiler/hlds_pred.m:
Add a predicate status_is_exported_to_non_submodules, which
fails if an item is local to the module and its sub-modules.
compiler/hlds_data.m:
compiler/*.m:
Record whether a du type has foreign definitions as well.
Also record whether uses of the type or its constructors
need to be qualified (this is needed now that adding
the constructors to the HLDS is a separate pass).
compiler/typecheck.m:
Check that a predicate or function has foreign clauses before
allowing the use of a constructor of a type which also has
foreign definitions.
compiler/hlds_pred.m:
compiler/make_hlds.m:
Simplify the code to work out the goal_type for a predicate.
compiler/hlds_out.m:
Don't abort on foreign types.
Print the goal type for each predicate.
compiler/error_util.m:
Handle the case where the message being written is a
continuation of an existing message, so the first line
should be indented.
compiler/module_qual.m:
Remove unnecessary processing of foreign types.
doc/reference_manual.tex:
Document the change.
Update the documentation for mixing Mercury and foreign clauses.
The Mercury clauses no longer need to be mode-specific.
tests/hard_coded/Mmakefile:
tests/hard_coded/foreign_type2.{m,exp}:
tests/hard_coded/foreign_type.m:
tests/hard_coded/intermod_foreign_type.{m,exp}:
tests/hard_coded/intermod_foreign_type2.m:
tests/invalid/Mmakefile:
tests/invalid/foreign_type_2.{m,err_exp}:
tests/invalid/foreign_type_visibility.{m,err_exp}:
Test cases.
tests/invalid/record_syntax.err_exp:
Update expected output.
|
||
|
|
ddd77f6f0e |
Get pragma foreign_type working for the C backend.
Estimated hours taken: 16
Branches: main
Get pragma foreign_type working for the C backend.
doc/reference_manual.texi:
Document C pragma foreign_types.
compiler/prog_data.m:
Add il_foreign_type and c_foreign_type which contain all the
necessary data to output a foreign_type on the respective backends.
Change foreign_language_type to refer to these new types.
compiler/prog_io_pragma.m:
Handle the changes to foreign_language_type, and parse C
foreign_type declarations.
compiler/hlds_data.m:
Change the hlds_data__foreign_type type so that it records both the
C and IL foreign types. This will allow one to output both foreign
type declarations when doing intermodule optimization.
compiler/make_hlds.m:
Changes so that we store both the IL and C foreign types in
hlds_data__foreign_type.
Also add an error checking pass where we check that there is a
foreign type for the back-end we are currently compiling to.
compiler/foreign.m:
Change to_exported_type so that it works for both the C and IL
backends by getting either the C or IL foreign_type definition.
compiler/llds.m:
compiler/pragma_c_gen.m:
Change pragma_c_input and pragma_c_output so that they record
whether or not a type is a foreign_type and if so what is the string
which represents that foreign_type.
compiler/llds_out.m:
When outputting pragma c_code variables that represent foreign_types
get the casts correct. Note that this adds the constraint on C
foreign types that they are word sized, as all we are doing is
casts, not boxing and unboxing.
compiler/mlds.m:
Change mlds__foreign_type so that we store whether a type is an IL
type or a C type. It is the responsibility of the code generator
that we never create a reference to a IL foreign type when on the C
back-end, and vice versa.
compiler/mercury_to_mercury.m:
Handle changes to prog_data__foreign_type.
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_code_gen.m:
compiler/ml_type_gen.m:
compiler/recompilation_usage.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_proc.m:
Handle changes to hlds_data__foreign_type.
compiler/exprn_aux.m:
compiler/livemap.m:
compiler/middle_rec.m:
compiler/opt_util.m:
Handle changes to the pragma_c_input and pragma_c_output types.
compiler/ml_code_util.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_c.m:
Handle changes to mlds__foreign_type.
|
||
|
|
7597790760 |
Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure of the compiler clearer, and to encourage better encapsulation of the major components. compiler/libs.m: compiler/backend_libs.m: compiler/parse_tree.m: compiler/hlds.m: compiler/check_hlds.m: compiler/transform_hlds.m: compiler/bytecode_backend.m: compiler/aditi_backend.m: compiler/ml_backend.m: compiler/ll_backend.m: compiler/top_level.m: New files. One module for each of the major components of the Mercury compiler. These modules contain (as separate sub-modules) all the other modules in the Mercury compiler, except gcc.m and mlds_to_gcc.m. Mmakefile: compiler/Mmakefile: Handle the fact that the top-level module is now `top_level', not `mercury_compile' (since `mercury_compile' is a sub-module of `top_level'). compiler/Mmakefile: Update settings of *FLAGS-<modulename> to use the appropriate nested module names. compiler/recompilation_check.m: compiler/recompilation_version.m: compiler/recompilation_usage.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/recompilation.version.m: Convert the `recompilation_*' modules into sub-modules of the `recompilation' module. compiler/*.m: compiler/*.pp: Module-qualify the module names in `:- module', `:- import_module', and `:- use_module' declarations. compiler/base_type_info.m: compiler/base_type_layout.m: Deleted these unused empty modules. compiler/prog_data.m: compiler/globals.m: Move the `foreign_language' type from prog_data to globals. compiler/mlds.m: compiler/ml_util.m: compiler/mlds_to_il.m: Import `globals', for `foreign_language'. Mmake.common.in: trace/Mmakefile: runtime/Mmakefile: Rename the %.check.c targets as %.check_hdr.c, to avoid conflicts with compiler/recompilation.check.c. |