Commit Graph

71 Commits

Author SHA1 Message Date
Mark Brown
0731932d14 Construct strings representing c_pointer addresses.
Estimated hours taken: 2
Branches: main

runtime/mercury_ml_expand_body.h:
	Construct strings representing c_pointer addresses.  Used in the
	implementation of functor and deconstruct.

library/deconstruct.m:
	Document the behaviour of functor and deconstruct for c_pointers.

library/string.m:
	Export c_pointer_to_string for getting a string representation
	of the pointer address.

library/io.m:
library/rtti_implementation.m:
	Use c_pointer_to_string/1 to print c_pointers.

	Update comments.

library/pprint.m:
	Undo Ralph's earlier change, since it is no longer required.

tests/debugger/Mmakefile:
tests/debugger/declarative/Mmakefile:
	Canonicalize the output of test cases in which c_pointers appear.

tests:
	Update the expected output of test cases.
2006-08-22 02:33:54 +00:00
Julien Fischer
e006ed939e Fix a bug reported by Jonathan Morgan.
library/rtti_implementation.m:
	s/NULL/null in some C# foreign code.
2006-05-09 05:04:50 +00:00
Julien Fischer
a6508191fc Make the IL backend compile successfully.
(This patch was submitted by Jon Morgan.)

Estimated hours taken: 0.5
Branches: main, release

Make the IL backend compile successfully.

library/private_builtin.m:
       Revert incorrect s/__/. in C# and Java foreign code.
library/rtti_implementation.m:
       s/NULL/null in C# foreign code.
2006-05-01 14:45:19 +00:00
Julien Fischer
e0f5ac47db Make it easier for vi to jump past the initial comments
Estimated hours taken: 0.1
Branches: main

library/*.m:
	Make it easier for vi to jump past the initial comments
	at the head of a module.
2006-04-19 05:18:00 +00:00
Julien Fischer
5e92224eec Improve the library reference manual by formatting the beginning of
Estimated hours taken: 0.2
Branches: main, release

library/*.m:
	Improve the library reference manual by formatting the beginning of
	library modules consistently.

library/integer.m:
	Fix some bad indentation.
2006-04-13 06:08:05 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Julien Fischer
a4519ed079 Move the all-solutions predicates from the library module std_util into their
Estimated hours taken: 4
Branches: main

Move the all-solutions predicates from the library module std_util into their
own module, solutions.

Move semidet_fail, semidet_succeed, cc_multi_equal and dynamic cast from
std_util.m into builtin.m.

Add some more utility functions for performing determinism or purity casts.
(The later are primarily intended for use by solver implementors.)

library/std_util.m:
	Move the all-solutions predicates into their own module, solutions.m.
	For now there are (obsolete) forwarding predicates from this module to
	the new one.  The forwarding predicates will be included in the
	upcoming 0.13 release and then removed in later versions.

	Move semidet_succeed, semidet_fail, cc_multi_equal and dynamic_cast
	to builtin.m

library/solutions.m:
	New file.  This is the new home for the all-solutions predicates.
	This is pretty much cut and pasted from std_util (with module
	qualifiers updated accordingly).  I've rearranged the code in a more
	top-down fashion as per our current coding standard.

library/builtin.m:
	Move semidet_fail/0, semidet_succeed/0, cc_multi_equal/2 and
	dynamic_cast/2 to this module.

	Add semidet_true/0 and semidet_false/0 as synonyms for semidet_fail/0
	and semidet_succeed/0.

	Add impure_true/0 and semipure_true/0.  These are useful for performing
	purity casts, e.g. in solver implementations.

library/library.m:
	Add the new module.

NEWS:
	Announce the changes.

library/*.m:
	Update to conform to the above.

compiler/const_prop.m:
	Update evaluate_semidet_call/5 with the new module name for
	dynamic_cast.

compiler/*.m:
	Module qualify calls to solutions to either disambiguate them from the
	versions in std_util (where they weren't module qualified) or change
	the module qualifier where they were (to avoid warnings about calls to
	the now deprecated versions).

tests/debugger/declarative/solutions.*:
	Rename this module as the name conflicts with the new library module.

tests/debugger/declarative/solns.*:
	Renamed version of above (with updated expected output).

tests/debugger/declarative/Mmakefile:
	Handle the renamed version of the solutions test.

tests/debugger/all_solutions.m:
tests/debugger/declarative/args.m:
tests/debugger/declarative/library_forwarding.m:
tests/hard_coded/constant_prop_2.m:
tests/invalid/multisoln_func.m:
tests/invalid/one_member.m:
tests/invalid/promise_equivalent_claueses.m:
tests/valid/simplify_bug2.m:
tests/valid/solv.m:
	Update to conform to the above changes.

sample/solutions/*.m:
	Update to conform to the above changes.
2006-03-24 04:40:59 +00:00
Zoltan Somogyi
ef55b420fd Remove from std_util.m the predicates that merely call predicates in
Estimated hours taken: 12
Branches: main

Remove from std_util.m the predicates that merely call predicates in
the type_desc, construct and deconstruct modules, to reduce clutter
in std_util.m.

library/std_util.m:
	Remove those predicates from std_util.m.

library/deconstruct.m:
	Add a type we need that was previously defined in std_util.m.

library/construct.m:
	Delete some module qualifications that have now become unnecessary,

browser/browse.m:
browser/browser_info.m:
browser/declarative_tree.m:
browser/dl.m:
browser/help.m:
browser/sized_pretty.m:
browser/term_rep.m:
compiler/bytecode_gen.m:
compiler/llds_out.m:
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
library/assoc_list.m:
library/hash_table.m:
library/io.m:
library/pprint.m:
library/private_builtin.m:
library/prolog.m:
library/require.m:
library/rtti_implementation.m:
library/store.m:
library/term.m:
library/term_to_xml.m:
library/version_hash_table.m:
mdbcomp/program_representation.m:
	Import type_desc.m, construct.m and/or deconstruct.m to provide
	definitions of functions or predicates that up till now were in
	std_util.m. Modify the calls if the called function or predicate
	had a slightly different interface in std_util.m.

	Also, convert term_to_xml.m to four-space indentation, and delete
	unnecessary module qualifications in term.m.

tests/debugger/polymorphic_output.{m,inp,exp,exp2}:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
tests/hard_coded/elim_special_pred.m:
tests/hard_coded/existential_bound_tvar.m:
tests/hard_coded/expand.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/higher_order_type_manip.m:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/tuple_test.m:
tests/hard_coded/type_ctor_desc.m:
tests/hard_coded/type_qual.m:
tests/hard_coded/write_xml.m:
tests/hard_coded/sub-modules/class.m:
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested2.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/parent2.child.m:
tests/hard_coded/typeclasses/existential_rtti.m:
tests/recompilation/type_qual_re.m.1:
cvs update: Updating tests/submodules
cvs update: Updating tests/tabling
cvs update: Updating tests/term
cvs update: Updating tests/tools
cvs update: Updating tests/trailing
cvs update: Updating tests/typeclasses
cvs update: Updating tests/valid
tests/valid/agc_unbound_typevars.m:
tests/valid/agc_unbound_typevars2.m:
tests/valid/agc_unused_in.m:
	Replace references to the deleted predicates in std_util with
	references to the equivalent predicates in type_desc, construct
	and/or deconstruct. In test cases that already tested both the
	functionality in std_util and in the other modules, simply delete
	the part exercising std_util.
2006-03-22 02:56:44 +00:00
Julien Fischer
c6d91ff386 Add some preliminary support for using the il grade with DotGNU.
Estimated hours taken: 1
Branches: main

aclocal.m4:
scripts/Mmake.vars.in:
	Add some preliminary support for using the il grade with DotGNU.

library/rtti_implementation.m:
	Avoid a warning.
2006-02-01 12:10:17 +00:00
Zoltan Somogyi
b819fbc0a6 Give the compiler the capability of detecting errors that manifest themselves
Estimated hours taken: 16
Branches: main

Give the compiler the capability of detecting errors that manifest themselves
as mismatches between the format string and the list of values to be printed
in calls to string.format and io.format.

This capability is controlled through two new options:

	--warn-known-bad-format-calls
	--warn-unknown-format-calls

The first (which will default to "on" once this change has bootstrapped)
controls whether the compiler emits warnings for statically known mismatches.
The second (which will default to "off") controls whether the compiler emits
warnings in cases where either the format string or the structure of the list
of values to be printed is not available statically to be checked.

NEWS:
	Mention the new capability.

compiler/options.m:
	Add the two new options.

doc/user_guide.texi:
	Document the new options.

compiler/format_call.m:
	New module to implement the new capability.

compiler/notes/compiler_structure.html:
	Document the new module.

compiler/check_hlds.m:
	Include the new module.

compiler/simplify.m:
	Invoke the new module if the procedure being processed contains calls
	to string.format or io.format.

	Fix an old bug: we could generate warnings or even errors when
	simplifying predicate bodies imported from other modules via
	intermodule optimization.

	Don't export get/set predicates that do not need to be exported.

compiler/det_report.m:
	Add new kinds of error specifications for the errors detected by the
	new module.

	Separate out the context of each error specification, in order
	to allow the error messages to be sorted by context; this makes
	the output much easier to read.

compiler/common.m:
compiler/det_analysis.m:
compiler/simplify.m:
	Conform to the change to det_report.m.

mdbcomp/prim_data.m:
	Add a utility function for forming the possibly qualified names of
	library modules (such as "io" and "string").

library/Mercury.options:
compiler/Mercury.options:
	Add the lines that disable the new checks in the modules that need them
	disabled. The new lines are commented out until installed compilers all
	understand them, at which point in time we will add the requirement to
	understand the option to configure.in.

compiler/fact_table.m:
compiler/mlds_to_il.m:
	Fix three bugs reported by the new check that have apparently escaped
	detection all this time.

library/rtti_implementation.m:
	Change some code to avoid a spurious warning from the new checks.

library/string.m:
	Rename a predicate to avoid an unnecessary and confusing overloading of
	its name.

	Replace __ with . as module qualifier connective.

compiler/handle_options.m:
library/pprint.m:
	Misc cleanups.

tests/invalid/string_format_bad.{m,err_exp}:
tests/invalid/string_format_unknown.{m,err_exp}:
	New test cases to test the new warnings.

tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
	Enable the new test cases.

tests/general/string_format_test*.exp*:
	Update any expected abort messages to expect . instead of __ as module
	qualifier connective.

tests/invalid/det_errors_cc.err_exp:
tests/invalid/erroneous_throw_promise.err_exp:
tests/warnings/simple_code.exp:
	Expect the same error messages in program context order.
2006-01-27 05:52:27 +00:00
Zoltan Somogyi
b9ca44672b Fix the bugs were exposed by my pre-dummy-type-diff cleanup of polymorphism.m.
Estimated hours taken: 24
Branches: main

Fix the bugs were exposed by my pre-dummy-type-diff cleanup of polymorphism.m.
This diff deleted a "semidet_fail" in the predicate that tested whether a
foreign_proc used a variable, making the test a real test, not a dummy.

The main bugs were in unused_args.m, polymorphism.m and ml_unify_gen.m.

compiler/unused_args.m:
	Fix the mismatch between the analysis and fixup passes' treatment of
	foreign_procs. The analysis pass says that variables representing
	unnamed foreign_proc arguments are unused, and therefore the code
	generating them can be optimized away, but the fixup pass used to leave
	those arguments unchanged. This is usually fine, but there was a
	problem if a variable had two or more such conjoined consumers but no
	other consumers. It then had its generator optimized away, but the
	variable was left in the nonlocal set of each consumer, which meant
	that the code generator aborted when trying to save the value of the
	variable after the first consumer.

	The fix is to rename unnamed foreign proc args, ensuring that they are
	local to the foreign_proc they appear in. The code generators can
	already handle such arguments.

compiler/typecheck.m:
	Detect foreign_procs that are supposed to bind type_info variables,
	but don't, and generate error messages for them. This is now necessary,
	since if we accept such predicates, unused_args.m will now rename apart
	the unused type_info argument, and the code generator will abort
	due to the type_info missing its generator.

compiler/typecheck_errors.m:
	Add a predicate for reporting the error.

compiler/goal_util.m:
	Add a utility predicate and export some previously internal predicates
	for use by unused_args.m.

	Delete redundant module prefixes on predicate names to avoid having to
	split long lines.

compiler/polymorphism.m:
	Ensure that all arguments of import foreign_procs are considered used,
	since our contract with foreign language code prevents us from
	optimizing them away.

	Redefine a predicate using the new utility predicate in goal_util.m.

compiler/pragma_c_gen.m:
	Ensure that all arguments of import foreign_procs are considered used,
	since our contract with foreign language code prevents us from
	optimizing them away. This is a belt-and-suspenders fix: the change to
	polymorphism.m should be sufficient to ensure this objective by itself.

compiler/ml_unify_gen.m:
	The mark_static_terms pass was assuming that if X is a static term,
	then after the assignment unification Y = X Y is also a static term.
	However, when processing such assignments, the code generator here
	neglected to copy over the part of the X's state that says what static
	term it is to become part of Y's state. This diff fixes that neglect.

compiler/ml_code_util.m:
	We used to identify MLDS variables holding static terms by a sequence
	number, and then create a name from the number by tacking on the name
	of the HLDS variable referring to it at each reference. This worked
	because each static term was referred to by only one HLDS variable;
	but after the diff to ml_unify_gen, this is no longer the case.
	We therefore now construct the MLDS variable's name when the static
	term is created, and use that name as the translation of all the HLDS
	variables referring to that static term.

compiler/add_pragma.m:
	Minor cleanup.

library/rtti_implementation.m:
library/store.m:
	In some predicates that don't define type_infos for existentially typed
	arguments, mention the type_info that *should* be defined there in
	comments to avoid the error now generated by typecheck.m.

browser/Mercury.options:
deep_profiler/Mercury.options:
	Undo the workaround for the fixed bug.

tests/existential_type_classes.m:
	In predicates that don't define type_infos for existentially typed
	arguments, mention the type_info that *should* be defined there in
	comments to avoid the error now generated by typecheck.m.

tests/existential_type_classes.exp:
	Conform to the changed line numbers in existential_type_classes.m.

tests/invalid/exist_foreign_error.{m,exp}:
	New test case for the error now detected by typecheck.m.

tests/invalid/Mmakefile:
	Enable the new test case.
2005-10-14 01:42:56 +00:00
Zoltan Somogyi
47cbf9b5fa Change the names of some predicates so that they are meaningful without
Estimated hours taken: 2
Branches: main

compiler/simplify.m:
	Change the names of some predicates so that they are meaningful without
	the module name as prefix. Delete module prefixes to shorten some
	lines.

compiler/magic.m:
compiler/mercury_compile.m:
compiler/size_prof.m:
	Conform to the new names of simplify's predicates.

compiler/typecheck.m:
	Misc cleanups.

library/rtti_implementation.m:
library/store.m:
	Convert to four-space indentation.
2005-10-11 03:17:27 +00:00
Zoltan Somogyi
d609181cb9 Consider types of the form
Estimated hours taken: 30
Branches: main

Consider types of the form

	:- type x ---> f.

to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.

runtime/mercury_type_info.h:
	Add a new type_ctor_rep for dummy types.

runtime/mercury_tabling.h:
	Add a representation for "tabled" dummy types, which don't actually
	have a level in the trie, so that the runtime system can handle that
	fact.

runtime/mercury_ml_expand_body.h:
	When deconstructing a value of a dummy type, ignore the actual value
	(since it will contain garbage) and instead return the only possible
	value of the type.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
	Handle the type_ctor_rep of dummy types.

runtime/mercury_builtin_types.c:
	Provide a place to record profiling information about unifications and
	comparisons for dummy types.

runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
	Add a new type_ctor_rep for dummy types, and fix some previous
	discrepancies in type_ctor_reps.

mdbcomp/prim_data.m:
	Move a bunch of predicates for manipulating special_pred_ids here from
	the browser and compiler directories.

	Rename the function symbols of the special_pred_id type to avoid the
	need to parenthesize the old `initialise' function symbol.

	Convert to four-space indentation.

mdbcomp/rtti_access.m:
	Don't hardcode the names of special preds: use the predicates in
	prim_data.m.

	Convert to four-space indentation.

browser/declarative_execution.m:
	Delete some predicates whose functionality is now in
	mdbcomp/prim_data.m.

compiler/hlds_data.m:
	Replace the part of du type that says whether a type an enum, which
	used to be a bool, with something that also says whether the type is a
	dummy type.

	Convert to four-space indentation.

compiler/make_tags.m:
	Compute the value for the new field of du type definitions.

compiler/hlds_out.m:
	Write out the new field of du type definitions.

compiler/rtti.m:
	Modify the data structures we use to create type_ctor_infos to allow
	for dummy types.

	Convert to four-space indentation.

compiler/type_ctor_info.m:
	Modify the code that generates type_ctor_infos to handle dummy types.

compiler/type_util.m:
	Provide predicates for recognizing dummy types.

	Convert to four-space indentation.

compiler/unify_proc.m:
	Generate the unify and compare predicates of dummy types using a new
	code scheme that avoids referencing arguments that contain garbage.

	When generating code for unifying or comparing other types, ignore
	any arguments of function symbols that are dummy types.

	Don't use DCG style access predicates.

compiler/higher_order.m:
	Specialize the unification and comparison of values of dummy types.

	Break up an excessively large predicate, and factor out common code
	from the conditions of a chain of if-then-elses.

compiler/llds.m:
	For each input and output of a foreign_proc, include a field saying
	whether the value is of a dummy type.

compiler/pragma_c_gen.m:
	Fill in the new fields in foreign_proc arguments.

compiler/hlds_goal.m:
	Rename some predicates for constructing unifications to avoid
	unnecessary ad-hoc overloading. Clarify their documentation.

	Rename a predicate to make clear the restriction on its use,
	and document the restriction.

	Add a predicate for creating simple tests.

	Add a utility predicate for setting the context of a goal directly.

compiler/modules.m:
	Include dummy types interface files, even if they are private to the
	module. This is necessary because with the MLDS backend, the generated
	code inside the module and outside the module must agree whether a
	function returning a value of the type returns a real value or a void
	value, and this requires them to agree on whether the type is dummy
	or not.

	The impact on interface files is minimal, since very few types are
	dummy types, and changing a type from a dummy type to a non-dummy type
	or vice versa is an ever rarer change.

compiler/hlds_pred.m:
	Provide a representation in the compiler of the trie step for dummy
	types.

compiler/layout_out.m:
	Print the trie step for dummy types.

compiler/table_gen.m:
	Don't table values of dummy types, and record the fact that we don't
	by including a dummy trie step in the list of trie steps.

compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
	Conform to the changes above.

compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
	Conform to the changes above.

	Convert to four-space indentation.

compiler/mlds_to_java.m:
compiler/var_locn.m:
	Conform to the changes above, which requires threading the module_info
	through the module.

	Convert to four-space indentation.

compiler/mercury_compile.m:
	Pass the module_info to mlds_to_java.m.

compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
	Delete some previously missed references to the temporary types used
	to bootstrap the change to the type_info type's arity.

compiler/polymorphism.m:
	Turn back on an optimization that avoids passing parameters (such as
	type_infos) to foreign_procs if they are not actually referred to.

compiler/prog_data.m:
	Convert to four-space indentation.

library/svvarset.m:
	Add a missing predicate.

trace/mercury_trace.c:
	Delete the unused function that used to check for dummy types.

tests/debugger/field_names.{m,inp,exp}:
	Add to this test case a test of the handling of dummy types. Check that
	their values can be printed out during normal execution, and that the
	debugger doesn't consider them live nondummy variables, just as it
	doesn't consider I/O states live nondummy variables.
2005-10-05 06:34:27 +00:00
Zoltan Somogyi
477d041397 This is step 2 of eliminating the arguments of the type_ctor_info, type_info,
Estimated hours taken: 8
Branches: main

This is step 2 of eliminating the arguments of the type_ctor_info, type_info,
base_typeclass_info and typeclass_info type constructors. This step changes
the arity of those type constructors from 1 to 0, and starts generating
references to them again. Due to bootstrapping issues, we can't delete the
zero_type_ctor_info, zero_type_info, zero_base_typeclass_info and
zero_typeclass_info types yet; that will be step 3.

library/private_builtin.m:
	Change the arity of those type constructors.

runtime/mercury_builtin_types.m:
	Update the unify and compare predicates of the old type constructors
	for their new arity.

compiler/polymorphism.m:
compiler/size_prof.m:
compiler/type_util.m:
	Generate references to the newly arity-0 old type constructions.

compiler/type_ctor_info.m:
compiler/type_util.m:
trace/mercury_trace_vars.c:
	Update references to the old types to reflect their new arities.

compiler/type_ctor_info.m:
	There are no more fake arities.

library/io.m:
library/rtti_implementation.m:
library/string.m:
library/table_builtin.m:
	Update references to the old types for their new arities.
2005-09-22 06:17:33 +00:00
Mark Brown
3fc6b3f128 Change the representation of types in the compiler.
Estimated hours taken: 30
Branches: main

Change the representation of types in the compiler.

We also add some support for handling kinds, which will be used later when we
have a kind system.  There are a number of places where kinds are not yet
handled correctly -- we assume that all kinds will be `star'.  Each of these
locations is flagged with a comment that contains "XXX kind inference:".


compiler/prog_data.m:
	Implement the new version of type (type).

	Change the definition of type_param to be a variable instead of a
	term, since all parameters must be variables anyway.

	Implement versions of varset.merge_* which work with tvarsets and
	produce renamings instead of substitutions.  Renamings are more
	convenient than substitutions because we don't need to know the
	kinds of type variables in order to build the renaming, and in any
	case the substitutions shouldn't have anything other than variables
	in the range so renamings will be more efficient and safe.

	Define the type of kinds, and provide a couple of utility predicates
	to operate on them.

compiler/prog_io.m:
	Parse type definition heads as a sym_name and list of type_params,
	rather than a functor.  Handle this change in other predicates.

	Allow parse errors to be returned by get_with_type/3, and handle
	these errors.

	Remove parse_type/2.  This predicate didn't do any processing, it
	just forwarded handling to convert_type/2.

compiler/prog_io_typeclass.m:
	Change type_is_functor_and_vars to handle the new representation
	of types.  In doing so, we retain the old behaviour that pure
	predicates pass this test, but no other pred or func types.  This
	behaviour is arguably incorrect, but there is little point changing
	the behaviour at the moment.  Instead we should remove these kind of
	restrictions entirely, but that should be done later.

compiler/prog_io_util.m:
	Provide predicates to both parse and unparse types.  We need to
	unparse types before printing them out, since we do a lot of special
	case handling when printing out terms and we don't want to duplicate
	this functionality for types.

compiler/module_qual.m:
	Remove report_invalid_type.  We now report ill-formed types during
	parsing.

compiler/superhomogeneous.m:
	Handle errors from the parsing of type expressions.

compiler/prog_out.m:
	Provide a predicate to convert builtin_types to their string names,
	and vice-versa.

compiler/prog_type.m:
	Add a bunch of simple tests to use on types which may have kind
	annotations present.  In such cases, types do not have a canonical
	representation so the simple handling of these tests is not what we
	want.  (Note that these are only required in early phases.  The kind
	annotations -- when they are implemented -- will be removed before
	type checking.)

	Consistently handle the application of renamings, substitutions and
	recursive substitutions to various data structures.

compiler/mercury_to_mercury.m:
	Implement mercury_output_type, mercury_format_type and
	mercury_type_to_string.  These convert the type to a term before
	formatting -- the reason for this is so that appropriate parentheses
	are used when formatting operators.  This results in some slight
	changes to error messages, which are reflected in changes to the
	expected output files in the tests.

	Remove the old version of mercury_type_to_string.

	Change the argument ordering of mercury_format_var to be consistent
	with mercury_format_type.  (Other predicates in this module should
	probably be changed in a similar way, since this argument ordering
	is more amenable to higher-order programming.  But that can be left
	for another change.)

compiler/type_util.m:
	Implement type unification.  The behaviour is much the same as the
	previous behaviour, except that we now handle apply/N types properly,
	and we also allow for kind annotations.

	Implement an occurs check for types.

	Remove the example definition of replace_eqv_type.  It isn't used and
	would no longer work anyway even if it would have worked before.

	Add a tvar_kind_map field to ctor_defn.

	The functions type_info_type and type_ctor_info_type now return
	types with `void' as their argument, rather than the type that the
	type_info or type_ctor_info was for.

	Remove type_util.real_vars/2, since it no longer does anything
	different from prog_type.vars/2.

	Remove the commented out implementation of type_to_ctor_and_args/3.
	Its implementation is in prog_type.m, and has changed significantly
	in any case.

compiler/add_clause.m:
	Move parse_purity_annotation/3 to prog_io_util.m.

compiler/check_typeclass.m:
	Remove apply_substitution_to_var_list/3, since we now have predicates
	in prog_type.m to handle such things.

compiler/continuation_info.m:
compiler/trace.m:
	Use prog_type.vars/2 instead of type_util.real_vars/2.  The two
	predicates have the same meaning now since type_infos don't contain
	any type variables.

compiler/hlds_data.m:
	Add tvar_kind_map fields to hlds_type_defn and hlds_class_defn.

compiler/hlds_pred.m:
	Add a tvar_kind_map field to pred_info.

compiler/polymorphism.m:
	Add a tvar_kind_map field to poly_info.

	Remove unify_corresponding_types, which is no longer used.

compiler/hlds_out.m:
	Use mercury_output_type/5 instead of term_io__write_term/4 and
	mercury_output_term/5.

compiler/post_typecheck.m:
	Build the void substitution directly rather than building intermediate
	lists.

compiler/recompilation.version.m:
	Use term__list_subsumes instead of type_list_subsumes, which now
	operates only on types.  This follows up on what was suggested in
	an XXX comment.

compiler/typecheck_errors.m:
	Use unparse_type/2 to format error messages.

compiler/typecheck_info.m:
	Don't export write_type_with_bindings/5.  It is no longer used
	outside of this module.

compiler/*.m:
	Conform to the above changes.

library/rtti_implementation.m:
	Fix a syntax error that went undetected in our previous
	implementation, and amazingly enough was compiled correctly anyway.

library/term.m:
	Move the versions of term__unify, term__unify_list and
	term__list_subsumes that were implemented specifically for types
	to here.  The version of term_unify that takes a list of bound
	variables (i.e., variables that should not be bound any further)
	is used by the subsumption check, which in turn is used by
	recompilation.version.m.

tests/invalid/kind.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/misc_tests/pretty_print_test.exp:
	Update the expected output of these tests to match what we now do.
2005-09-12 05:25:01 +00:00
Julien Fischer
18f1e61783 Fix some compilation errors for the library in the non-C grades.
Estimated hours taken: 1.5
Branches: main

Fix some compilation errors for the library in the non-C grades.

Provide a workaround for a problem with the library in the java
grade.

library/rtti_implementation.m:
	s/get_functor_2/get_functor_with_names/ since that is
	how it is referred to in the calls from the construct
	module.

library/type_desc.m:
	Import std_util since semidet_fail is now used in this
	module.

	Provide a foreign type definition for pseudo_type_desc.
	XXX This is not correct but something is amiss with
	either the Java backend and/or the Java runtime.  Providing
	a foreign type definition  means that the library will at
	least compile in grade java.
2004-12-16 07:00:34 +00:00
Zoltan Somogyi
941be20e27 Type_desc__get_functor looks up the types of the arguments of a function
Estimated hours taken: 16
Branches: main

Type_desc__get_functor looks up the types of the arguments of a function
symbol. This predicate used to abort when an argument has an existential
type. This diff makes type_desc__get_functor work even in that case.
However, since in such cases the type of an argument is not a ground type,
this diff has to add the concept of a pseudo_type_desc, a descriptor for
a not necessarily ground type. Pseudo_type_descs are implemented as
MR_PseudoTypeInfos.

runtime/mercury_type_info.[ch]:
	Add new macros to operate on pseudo_type_infos. Most have a structure
	modelled on corresponding macros operating on type_infos.

	Provide versions of MR_get_arg_type_info, MR_compare_type_info,
	MR_unify_type_info, MR_collapse_equivalences,
	MR_type_params_vector_to_list, MR_create_type_info and
	MR_create_type_info_maybe_existq that work on pseudo_type_infos,
	not type_infos.

	Change MR_pseudo_type_info_vector_to_type_info_list, which implements
	the core of get_functor, to return pseudo_type_infos instead of
	type_infos, and rename it to reflect this fact.

	Change to four-space indentation to reduce the number of lines
	that have to be wrapped.

runtime/mercury_make_type_info_body.h:
	Generalize the code for creating type_infos to also be handle
	pseudo_type_infos.

	Change to four-space indentation to reduce the number of lines
	that have to be wrapped.

runtime/mercury_type_desc.[ch]:
	Provide versions of MR_make_type_ctor_desc and MR_type_ctor_and_args
	that work on pseudo_type_infos, not type_infos.

	Change to four-space indentation to reduce the number of lines
	that have to be wrapped.

runtime/mercury_builtin_types.[ch]:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_hlc_types.h:
runtime/mercury_unify_compare_body.h:
	Add the C types, global variables and functions necessary for the
	new builtin Mercury type pseudo_type_desc. This type must be builtin,
	because its structure (MR_PseudoTypeInfo) is defined in C, and as such
	cannot be unified, compared, deconstructed etc without hand-written
	C code.

runtime/mercury_deep_copy.c:
runtime/mercury_deep_copy_body.h:
	Handle the copying of pseudo_type_infos/pseudo_type_descs. This code
	is almost the same as the code to copy type_infos, but must of course
	handle type variables, and the arguments are themselves copied as
	pseudo_type_infos, not type_infos.

runtime/mercury_types.h:
	Since deep copy needs to create pseudo_type_infos, provide a version
	of the MR_PseudoTypeInfo type without const.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
	Handle pseudo_type_descs just as we handle type_descs: neither can be
	constructed, nor do they have function symbols with named arguments.

runtime/mercury_ml_expand_body.c:
	Provide code to deconstruct pseudo_type_descs. This code is almost
	the same as the code to deconstruct type_descs, but must of course
	handle type variables, and the arguments are themselves
	pseudo_type_descs, not type_descs.

runtime/mercury_tabling.c:
	Catch attempts to table pseudo_type_infos.

runtime/mercury_tags.h:
	Add macros for constructing lists of
	pseudo_type_infos/pseudo_type_descs.

runtime/mercury_wrapper.[ch]:
	Define global variables holding the addresses of the typeinfos for
	describing pseudo_type_descs and lists of pseudo_type_descs.

runtime/mercury_init.c:
	Add the extern declarations required by new code in mkinit.c.

util/mkinit.c:
	Make the addresses of the typeinfos for describing pseudo_type_descs
	and lists of pseudo_type_descs, defined in the library, known to the
	runtime.

library/type_desc.m:
	Add a new builtin type, pseudo_type_desc, for describing possibly
	nonground types.

	Add utility predicates for operating on pseudo_type_descs.

library/private_builtin.m:
	Handle the new builtin type.

	Add builtin typeinfos for describing pseudo_type_descs and lists of
	pseudo_type_descs, since some functions in the runtime need them
	for memory profiling.

library/rtti_implementation.m:
	Handle the new builtin type, mostly by ignoring it, since the backends
	that use this module do not have any notion of pseudo_type_infos.

	Bring the module up to date with our formatting guidelines.

library/construct.m:
	Make get_functor return a list of pseudo_type_descs instead of
	type_descs.

	Change the name of the version of get_functor that returns argument
	names, to distinguish it from the base version by more than just the
	arity.

	Make the order of predicates more logical.

library/std_util.m:
	Change the name of the version of get_functor that returns argument
	names, to distinguish it from the base version by more than just the
	arity.

	However, this name change is effectively the only change: both
	get_functor and get_functor_with_names still return lists of
	type_descs. This means that they will throw exceptions in the presence
	of existential types, but code using them need no algorithmic changes.

library/term.m:
library/term_to_xml.m:
	Add module qualifiers as necessary; no algorithmic changes.

library/list.m:
	Add two general-purpose predicates, all_true and all_false,
	for use in the other library modules.

compiler/ml_util.m:
compiler/mlds_to_gcc.m:
compiler/rtti.m:
compiler/type_ctor_info.m:
	Make sure we handle the new builtin type as a builtin type, and not
	try to have the compiler create a type_ctor_info for it.

deep_profiler/canonical.m:
	Delete the local definition of all_true.

tests/hard_coded/construct_test.{m,exp}:
	Update this test case to test the ability to retrieve the names of the
	fields of function symbols with existential types.

	Add module qualifications as necessary.

tests/hard_coded/construct_test_exist.{m,exp}:
	Add a tougher test case to print the types of the arguments of
	function symbols with existential types.

tests/hard_coded/Mmakefile:
	Add the new test case, and sort the names of the tests.
2004-12-14 01:07:32 +00:00
Fergus Henderson
d0228c4489 Some work towards getting the "browser" directory to build in grade java.
Estimated hours taken: 24
Branches: main

Some work towards getting the "browser" directory to build in grade java.

In particular, this is a step towards fixing a problem in the Java
back-end with sub-modules.  When compiling code that uses sub-modules,
we run up against a Java restriction that a class which is in a package
is not allowed to have the same name as the package.  The work-around
is to use names starting with an uppercase letter for Java class names,
and names starting with a lower-case letter for Java package names.

XXX This diff is a partial step: it uses names starting with an
uppercase letter for Java class names that correspond to Mercury types.
It does not yet use an uppercase letter for Java classes that correspond
to Mercury modules.

XXX With this diff, we just flip the case of the initial letter,
which just works around the problem by avoiding the clashing cases,
rather than eliminating them.  We should use a more complicated mangling
that eliminates the problem completely, e.g. map lowercase Mercury names
to uppercase, map uppercase Mercury names to "U_" followed by the name.

compiler/mlds_to_java.m:
	Output type names with an initial uppercase letter.

compiler/mlds.m:
	Add a new enumeration type qual_kind, with values type_qual
	and module_qual.
	Add a qual_kind field to the fully_qualified_type type.
	Add a qual_kind argument to the append_class_qualifier function,
	and if the qual_kind is module_qual, adjust the case of the
	qualifier appropriately for the back-end.

compiler/ml*.m:
compiler/rtti_to_mlds.m:
	Fill in the new qual_kind field, and pass qual_kind to
	append_class_qualifier.

library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
library/io.m:
library/rtti_implementation.m:
	Use type names with an initial uppercase letter.

browser/Mmakefile:
	Work around problems where Java compilers don't like the file names
	generated by mmc for code using sub-modules.

	For IL and Java, build with --allow-stubs --no-warn-stubs.

browser/declarative_execution.m:
	Give a Java definition for the "proc_layout" type.
	This is needed to avoid compilation errors in grade java.
2004-08-02 08:30:17 +00:00
Zoltan Somogyi
e4b0328ade Provide a mechanism for declaring foreign types that can be operated on by
Estimated hours taken: 4
Branches: main

Provide a mechanism for declaring foreign types that can be operated on by
compare_representation. The intended use of the mechanism is to declare
a foreign type to represent proc_layouts in the declarative debugger,
as part of the representation of atoms; since atoms are keys in maps
in the oracle, they are input to compare_representation.

Since we don't want the result of compare_representation to change as
execution proceeds, we require an assertion that the foreign value is
stable, i.e. that the value of the foreign type variable completely
determines the data it points to, directly and indirectly. Proc_layouts
are static, so this is not a problem. Being able to do the comparison
requires the foreign type to be an integral type or a pointer, which
is what the existing can_pass_as_mercury_type assertion promises.
The stability is promised by a new assertion.

For foreign types that have both assertions, we use a new type_ctor_rep,
which differs from the existing type_ctor_rep for foreign types by doing
a real comparison instead of an abort in compare_representation.

doc/reference_manual.texi:
	Document the new kind of assertion.

compiler/prog_data.m:
	Add the new kind of assertion.

compiler/prog_io_pragma.m:
	Parse the new kind of assertion.

compiler/rtti.m:
	Add the representation of the new type_ctor_rep. Factor out the
	stability of c_pointers as well as foreign types.

compiler/type_ctor_info.m:
	Generate the new type_ctor_rep for types with both assertions.

compiler/foreign.m:
	Export a predicate for use by type_ctor_info.m.

compiler/mercury_to_mercury.m:
	Print the new assertion.

compiler/*.m:
	Minor changes to conform to the diffs above.

	Use state variable notation.

library/rtti_implementation.m:
	Handle the new type_ctor_rep.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
java/runtime/TypeCtorRep.java:
	Add the new type_ctor_rep to the runtime.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
compiler/type_ctor_info.m:
	Increment the rtti version number.

	When we rely on the availability of this new capability,
	we should add a test for the new rtti version number to configure.in.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_term_size.h:
	Handle stable foreign types the same way as other foreign types.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
	Handle stable foreign types in a useful manner, relying on the
	assertions behind them.

tests/hard_coded/stable_foreign.{m,exp}:
	A test case for the handling of values of a stable foreign type.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2004-06-28 04:50:10 +00:00
James Goddard
1aa44ba2da Implement RTTI for the Java-backend (incomplete)
Estimated hours taken: 30
Branches: main

Implement RTTI for the Java-backend (incomplete)

java/runtime/PseudoTypeInfo.java:
java/runtime/TypeCtorInfo_Struct.java:
java/runtime/TypeInfo_Struct.java:
	Implement the `unify' operation for these classes.  This implementation
	actually just compares them.

library/rtti_implementation.m:
	Document a bug in notag_functor_arg_type/1

	Define the foreign type of `type_layout' as `TypeLayout' in Java.

	Correct an off-by-one error in type_ctor_and_args/3.

	Implement deconstruct/8 for TypeCtorRep = enum.

	Implement the following predicates in Java:
		get_var_arity_typeinfo_arity/1
		get_pti_from_arg_types/2
		typeinfo_is_variable/2
		get_type_ctor_info/1
		get_primary_tag/1
		get_remote_secondary_tag/1
		ptag_index/2
		sectag_locn/1
		du_sectag_alternatives/2
		type_info_index/2
		type_ctor_arity/1
		type_ctor_rep/1
		type_ctor_module_name/1
		type_ctor_name/1
		type_ctor_functors/1
		type_layout/1
		unsafe_cast/1
		du_functor_desc/3
		du_functor_name/1
		du_functor_arity/1
		du_functor_arg_type_contains_var/1
		du_functor_sectag_locn/1
		du_functor_primary/1
		du_functor_secondary/1
		du_functor_ordinal/1
		du_functor_arg_types/1
		du_functor_arg_names/1
		du_functor_exist_info/1
		enum_functor_desc/3
		enum_functor_name/1
		enum_functor_ordinal/1
		notag_functor_desc/3
		notag_functor_name/1
		notag_functor_arg_type/1
		notag_functor_arg_name/1
		null/1
		null_string/0
		unsafe_get_enum_value/1

library/type_desc.m:
	Implement the following procedures for Java:
		type_of/1
		has_type/1
		type_ctor_and_args/3
		type_ctor_name_and_arity/4

	Implement the Java classes `type_desc_0' and `type_ctor_desc_0'.
2004-02-26 08:17:54 +00:00
Fergus Henderson
496bcd1b9c Another step towards implementing RTTI support for Java.
Estimated hours taken: 1.25
Branches: main

Another step towards implementing RTTI support for Java.

library/rtti_implementation.m:
	Add Java `foreign_type' declarations for all the abstract types
	defined here, and provide Java `foreign_proc' definitions for
	get_type_info and high_level_data.
2004-02-20 01:56:33 +00:00
Peter Ross
261a92fa47 Document the amount of support for RTTI in this module.
Estimated hours taken: 0.25
Branches: main

library/rtti_implementation.m:
	Document the amount of support for RTTI in this module.
2003-12-04 09:11:34 +00:00
Peter Ross
38ba6a76c3 Swap the order of some C# statements in typeinfo_is_variable/2
Estimated hours taken: 0.1
Branches: main

library/rtti_implementation.m:
	Swap the order of some C# statements in typeinfo_is_variable/2
	so that the line which can cause an exception occurs first.
2003-12-02 08:55:51 +00:00
Peter Ross
fca99a6704 Delete uneeded cast in the C version of null_string.
Estimated hours taken: 0.1
Branches: main

library/rtti_implementation.m:
	Delete uneeded cast in the C version of null_string.
2003-11-13 13:41:43 +00:00
Peter Ross
4cfd32d3f4 Implement typeinfo_is_variable in C#.
Estimated hours taken: 1
Branches: main

library/rtti_implementation.m:
	Implement typeinfo_is_variable in C#.
2003-11-13 12:08:58 +00:00
Peter Ross
7721c29f40 Fix a bug where the null function was returning an object, while it
Estimated hours taken: 2
Branches: main

Fix a bug where the null function was returning an object, while it
was meant to return a string.  This lead to failures when the mercury
generated code attempted to do a "castclass string".

library/rtti_implementation.m:
	Rename null to null_string and make it return a string.
2003-11-13 11:54:11 +00:00
Peter Ross
d28ac0ec53 Begin porting the the library just to use C# as its foreign_proc
Estimated hours taken: 2
Branches: main

Begin porting the the library just to use C# as its foreign_proc
language.

library/array.m:
library/char.m:
library/exception.m:
library/float.m:
library/int.m:
library/math.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/std_util.m:
	Trivial changes to convert MC++ to C#.

library/table_builtin.m:
	Delete some unused MC++ functions.
2003-11-07 16:51:36 +00:00
Zoltan Somogyi
2f93756e7f Fix indentation in foreign_procs and in comments.
Estimated hours taken: 0.2
Branches: main

library/builtin.m:
library/rtti_implementation.m:
	Fix indentation in foreign_procs and in comments.
2003-06-22 11:56:27 +00:00
Zoltan Somogyi
112ddad251 Delete the univ type_ctor_rep, since we haven't used it in a long time,
Estimated hours taken: 2
Branches: main

Delete the univ type_ctor_rep, since we haven't used it in a long time,
and add two new type_ctor_reps: one for subgoals, so that they won't have
to be treated specially when deconstructed, and one for a future type,
stable_c_pointer, which is the same as c_pointer except that it guarantees
that the entire data structure it points to, directly and indirectly is
read only, which means that its values can be tabled. The intention is
to use stable_c_pointers to represent robdds.

runtime/mercury_type_info.h:
	Make the change above.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Handle the two new type_ctor_reps, and delete the code handling univs.

compiler/mlds_to_gcc.m:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
runtime/mercury_mcpp.h:
runtime/mercury_mcpp.cpp:
	Update the list of type_ctor_reps, including fixing some old errors
	in some files.

library/rtti_implementation.m:
	Update the list of type_ctor_reps, and modify the routines that
	interpret the RTTI accordingly.
2003-05-13 08:52:09 +00:00
Zoltan Somogyi
f623db5513 Add a facility for recording boolean flags in the RTTI structures
Estimated hours taken: 4
Branches: main

Add a facility for recording boolean flags in the RTTI structures
of type constructors. At the moment, the only flag records whether
the type constructor has a tag value reserved for HAL variables.
The flag is not used yet.

runtime/mercury_type_info.h:
	Add the extra field if MR_TYPE_CTOR_INFO_HAS_FLAG is defined.
	(The #ifdef will be deleted once bootstrapping is complete.)

runtime/mercury_mcpp.h:
	Add the extra field, since it will be needed after bootstrapping.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Define MR_TYPE_CTOR_INFO_HAS_FLAG for bootstrapping.

compiler/rtti.m:
	Add the field to the backend-independent RTTI description of
	type_ctor_infos, together with its encoding function.

compiler/type_ctor_info.m:
	Gather the information about the flags, for use when constructing
	the RTTI structure.

compiler/rtti_out.m:
	Add the flag field to the type_ctor_info structure for the LLDS backend.

compiler/rtti_to_mlds.m:
	Add the flag field to the type_ctor_info structure for the MLDS
	backends.

compiler/mlds_to_gcc.m:
	Add the flag field to the type_ctor_info structure for the gcc backend.

library/rtti_implementation.m:
	Add the flag field to list of fields of the type_ctor_info structure.
2003-02-26 07:43:51 +00:00
Fergus Henderson
9338352410 Delete Mercury clauses that just call sorry/1.
Estimated hours taken: 4
Branches: main

library/*.m:
	Delete Mercury clauses that just call sorry/1.
	I applied this change to all files except the following:
	rtti_implementation.m (because in that case, there is no C
	implementation) and profiling_builtin.m and table_builtin.m
	(because new back-ends needn't support profiling or tabling;
	the warnings with `--warn-stubs' for those would be just noise.)

library/array.m:
	Provide C# code for the (in, array_uo) mode of array__copy/2,
	by copying the code for the (array_ui, array_uo) mode.

library/math.m:
	Provide Mercury implementations of some of the math functions.
2003-02-22 11:17:36 +00:00
Fergus Henderson
5ba4991946 Fix a bug introduced by petdr in revision 1.38: there were some
Estimated hours taken: 0.5
Branches: main

library/rtti_implementation.m:
	Fix a bug introduced by petdr in revision 1.38: there were some
	type errors in the C and MC++ code for null/0 and null/1, which
	resulted in warnings from GCC (and potentially errors from other
	C compilers).
2003-02-04 07:37:22 +00:00
Ralph Becket
a8ffd3680c Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14
Branches: main

Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.

Infix `.' now has associativity yfx and priority 10.

NEWS:
	Report the change.

configure.in:
	Amend the test for an up-to-date Mercury compiler to check whether
	it recognises `.' as a module qualifier.

compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
	Change `:' to `.' as module separator for output.

compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
	As above.
	Fixed a bug where `.' was not being recognised as a module separator.

doc/reference_manual.texi:
	Report the change.

library/term_io.m:
	Ensure that infix `.' is written without surrounding spaces.

tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
	Test case added.
2003-01-17 05:57:20 +00:00
Peter Ross
ad4da4314a Implement construct__get_functor/5 and construct__get_functor/6 on the
Estimated hours taken: 16
Branches: main

Implement construct__get_functor/5 and construct__get_functor/6 on the
IL backend.

library/construct.m:
	Forward get_functor/5 and get_functor/6 to the respective
	calls in rtti_implementation.

library/rtti_implementation.m:
	Implement get_functor/5 and get_functor/6.
	Implemenent all the access predicates for du_functor_desc,
	enum_functor_desc and notag_functor_desc in a type-safe
	manner.
2002-12-24 11:56:08 +00:00
Peter Ross
e5170b87ca Back out the change to make rtti_implementatation:type_info
Estimated hours taken: 0.1
Branches: main

library/rtti_implementation.m:
	Back out the change to make rtti_implementatation:type_info
	and rtti_implementatation:type_ctor_info equivalent to
	type_desc:type_desc to type_desc:type_ctor_desc.
	See runtime/mercury_type_desc.h for why they cannot be
	equivalent.
2002-12-23 11:46:40 +00:00
Peter Ross
2b8d29402c Implement construct__num_functors in Mercury.
Estimated hours taken: 2
Branches: main

Implement construct__num_functors in Mercury.

libray/rtti_implementation.m:
	Implement num_functors in Mercury.
	Make type_info and type_ctor_info be synonyms for type_desc
	and type_ctor_desc, seeing that they are.

library/construct.m:
	Call the rtti_implementation version of num_functors.
2002-12-20 16:11:39 +00:00
Peter Ross
3ce41c9a7d Address fjh's review comments.
Estimated hours taken: 0.1
Branches: main

library/rtti_implementation.m:
	Address fjh's review comments.
2002-12-03 11:25:36 +00:00
Peter Ross
d2849923ef Implement deconstruct for arrays.
Estimated hours taken: 0.75
Branches: main

library/rtti_implementation.m:
	Implement deconstruct for arrays.
2002-12-02 17:23:05 +00:00
Peter Ross
28652585ac Change handle_usereq_type so that we explicitly list in the
Estimated hours taken: 0.5
Branches: main

library/rtti_implementation.m:
	Change handle_usereq_type so that we explicitly list in the
	mode the type_ctor_reps that we handle, and move the
	calculation of the base type_ctor_rep into handle_usereq_type.
2002-11-30 08:31:49 +00:00
Peter Ross
0d8fa97581 Add the ability to handle noncanonical types.
Estimated hours taken: 1
Branches: main

library/rtti_implementation.m:
library/deconstruct.m:
	Add the ability to handle noncanonical types.

library/deconstruct.m:
	Note that the cc_nondet modes of limited_deconstruct_idcc of
	univ_arg_idcc are incorrect.  These two predicates need to be
	altered so that they return maybe(result) so that we can make
	them cc_multi.
2002-11-30 08:03:33 +00:00
Peter Ross
805a59f174 Put the framework in place for handling noncanonical terms.
Estimated hours taken: 2
Branches: main

library/rtti_implementation.m:
	Put the framework in place for handling noncanonical terms.
	Handle the specific case of types with a user-defined equality.
2002-11-29 16:30:57 +00:00
Peter Ross
9afb439287 Implement tuple deconstruction.
Estimated hours taken: 2
Branches: main


library/rtti_implementation.m:
	Implement tuple deconstruction.
2002-11-29 15:00:10 +00:00
Peter Ross
6df7652737 Implement compare and unify for tuples and handle variable arity
Estimated hours taken: 3
Branches: main

Implement compare and unify for tuples and handle variable arity
type_infos in rtti_implementatation.

library/rtti_implementation.m:
	Implement compare and unify for tuples.
	Implement compare_collapsed_type_infos for the case where the
	type_infos are variable arity.
	Handle variable arity type_infos in type_ctor_and_args.
2002-11-29 13:56:29 +00:00
Peter Ross
b92b2cde5c Apply review comments of fjh.
Estimated hours taken: 0.1
Branches: main

library/rtti_implementation.m:
	Apply review comments of fjh.
2002-11-29 13:38:41 +00:00
Peter Ross
8a23d79321 Implement the trivial to implement branches of deconstruct.
Estimated hours taken: 2
Branches: main

library/rtti_implementation.m:
	Implement the trivial to implement branches of deconstruct.
	Mark all the noncanonical branches to remind me that they need
	to be handled specially.
2002-11-29 09:50:27 +00:00
Simon Taylor
09dad66315 Fix determinism warnings in Pete's last change.
Estimated hours taken: 0.1
Branches: main

library/rtti_implementation.m:
	Fix determinism warnings in Pete's last change.
2002-11-28 15:13:24 +00:00
Peter Ross
5812abd1b0 Fix bugs in get_arg when used with high-level data on the il backend.
Estimated hours taken: 8
Branches: main

Fix bugs in get_arg when used with high-level data on the il backend.
These bugs fixed in this change were exercised by the first two io__write's
in `tests/hard_coded/typeclasses/existential_rtti.m'.

library/rtti_implementation.m:
	Fix a bug where the number of extra args in a functor where
	being calculated according to whether or not a particular arg
	of that functor was an existentially quantified type variable,
	instead of just calculating the number of extra args from the
	information in the exist_info for that functor when it exists.
	Fix a bug where with high-level data the type of the secondary
	tag doesn't matter for determing the offset to find a functors
	arg.
2002-11-28 07:26:08 +00:00
Peter Ross
7c9965cea6 Fix a bug in C# implementation get_subterm.
Estimated hours taken: 3
Branches: main

Fix a bug in C# implementation get_subterm.

library/rtti_implementation.m:
	Fix a bug where for the high-level data case we weren't
	indexing into the array after any extra arguments.
	s/TagOffset/ExtraArgs/ as IMHO the new name is more
	descriptive.
2002-11-26 16:26:11 +00:00
Peter Ross
3748aa8c24 Adapt get_typeinfo_from_term so that it works for high level
Estimated hours taken: 2
Branches: main

library/rtti_implementation.m:
	Adapt get_typeinfo_from_term so that it works for high level
	data as well.
2002-11-26 14:40:47 +00:00
Fergus Henderson
0bcd5941a1 Fix a bug where `mercury.dll' was not being found by the C# compiler.
Estimated hours taken: 3
Branches: main

Fix a bug where `mercury.dll' was not being found by the C# compiler.
when you configured with a non-MS C compiler.  This bug broke
tests/hard_coded/foreign_type in grade il.

configure.in:
bindist/bindist.build_vars.in:
	Rename CYGPATH as FIX_PATH_FOR_CC.

scripts/Mmake.vars.in:
	Rename CYGPATH as FIX_PATH_FOR_CC,
	and add new variables FIX_PATH_FOR_CL and FIX_PATH_FOR_CSC.
	The new variables are currently hard-wired as `cygpath -w',
	since currently we only support the MS versions of CL and CSC.

	Also, change the definition of MERC_DLL_DIR to use $(GRADE)
	rather than hard-coding "ilc".

scripts/Mmake.rules:
	Use the new variables, rather than $(CYGPATH).

	Also, update various comments, and delete the unnecessary version
	number from the MS_VC7_INCLUDES_DIR and MS_VC7_INCLUDES variable
	names.

scripts/mmake.in:
	Use the new variables, rather than $(CYGPATH).
2002-10-24 17:11:45 +00:00