Commit Graph

6 Commits

Author SHA1 Message Date
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
Zoltan Somogyi
57b8f436eb Convert to four-space indentation most of the library modules that
Estimated hours taken: 4
Branches: main

library/*.m:
	Convert to four-space indentation most of the library modules that
	weren't already indented that way. Use predmode syntax where possible.
	In some modules, shorten long lines by deleting module name prefixes.
	Fix departures from our coding standards.

	In some modules, simplify code, mostly using field names and/or state
	variables.

	There are no changes in algorithms, except for neg_list in integer.m.
2005-10-17 11:35:22 +00:00
Mark Brown
e67f75a131 Add a test case for the injection library module.
Estimated hours taken: 3
Branches: main

tests/hard_coded/Mmakefile:
tests/hard_coded/test_injection.exp:
tests/hard_coded/test_injection.m:
	Add a test case for the injection library module.

library/injection.m:
	injection.merge and injection.overlay do not actually throw exceptions
	like the documentation says.  The reason is that the underlying map
	implementation does not throw exceptions in these circumstances, but
	silently accepts the error.  We therefore continue to do the same,
	but update the documentation to reflect this.

	Note that getting map.m to throw exceptions in these circumstances
	would probably be the better solution.
2005-07-23 16:04:25 +00:00
Mark Brown
38d9ef3479 Package the type_info_varmap and typeclass_info_varmap types into an ADT
Estimated hours taken: 25
Branches: main

Package the type_info_varmap and typeclass_info_varmap types into an ADT
called rtti_varmaps.  There are two main purposes for this:

	- We wish to extend this set of maps with new maps.  Doing this
	will be a lot easier and less error prone if all of the maps are
	packaged in a single data structure.

	- Any new maps that we add may contain redundant information that
	just makes searching the maps more efficient.  Therefore they must
	be kept consistent with the existing maps.  Having all the maps
	inside an ADT makes it easier to ensure this.

This change also includes two extensions to the maps.  First, the
typeclass_info_map is made reversible so that it is possible to efficiently
look up the constraint for a given typeclass_info variable.  Second, a new
map from prog_vars to types makes it possible to efficiently look up the
type that a given type_info variable is for.  These two changes mean that
it is no longer necessary to consult the argument of type_info/1 or
typeclass_info/1 to find this information.  (We still do put that information
there, though; changing the RTTI is left for a separate change.)

compiler/hlds_pred.m:
	Move items relating to type_infos and typeclass_infos into a section
	of their own.

	Add a type `rtti_var_info' to hold information about the contents
	of a type_info or typeclass_info variable.

	Define the rtti_varmaps abstract data type.  This data structure
	consists of the type_info_varmap and the typeclass_info_varmap.
	Add a new map, type_info_type_map, which is like the inverse
	to the type_info_varmap.  The difference is that the latter can
	point to locations that are inside a typeclass_info variable,
	whereas the former only refers to type_info variables.  Note that
	the combined maps do not form a bijection, or even an injection,
	since it is possible for two different type variables to point to
	the same location (that is, if they are aliased).

	Make the typeclass_info_varmap reversible, by using the new module
	injection.m.  Unlike the type_info_varmap, this map is always
	injective since the same typeclass_info cannot be used for two
	different constraints.

	The predicates rtti_det_insert_type_info_locn and set_type_info_locn,
	which update the type_info_varmap, contain sanity checks to ensure
	that only type variables that have already been registered with
	the type_info_type_map are used, and that the information in both
	maps is consistent.

	Use the rtti_varmaps structure in proc_info and clauses_info, in
	place of type_info_varmap and typeclass_info_varmap.

compiler/polymorphism.m:
	Remove polymorphism__type_info_or_ctor_type/2 and
	polymorphism__typeclass_info_class_constraint/2, to ensure that
	nobody tries to use the information in the type argument.  Replace
	them with two similar predicates that test if a type is type_info
	or typeclass_info, but that don't return the argument.

	Ensure that the new type_info_type_map in the rtti_varmaps is kept
	up to date by threading the rtti_varmaps through a few more places.
	Some of these places are exported, so this part of the change
	affects other modules as well.

	Fix a comment that referred to a non-existent predicate.

compiler/type_util.m:
	Remove the predicates apply_substitutions_to_var_map/5 and
	apply_substitutions_to_typeclass_var_map/5.  The functionality
	is now provided by the new ADT.

compiler/cse_detection.m:
	Rewrite update_existential_data_structures/4 to use the interface
	provided by rtti_varmaps.  The algorithm for doing this has changed
	in the following ways:

		- The first pass, which builds a map from changed locations
		in the first branch to the tvars concerned, is modified
		slightly to traverse over the keys instead of over key-value
		pairs.

		- The second pass, which previously calculated the induced
		type substitution and reconstructed the type_info_varmap
		now only does the former.

		- Applying the prog_var transformation and the induced type
		substitution is done at the end, using the interface to
		rtti_varmaps.

compiler/goal_util.m:
	Rewrite goal_util__extra_nonlocal_typeinfos/6 to avoid the need
	for using map__member/3 on the typeclass_info_varmap (about which
	the existing comments say "this is probably not very efficient..."),
	and to be more efficient in general.

	Previously, we nondeterministically generated non-local type vars
	and then tested each constraint to see if it had the type var in it.
	Now, we go through each constraint one at a time and check if any of
	the type variables in it are non-local.  This is more efficient
	because we only need to find one non-local type in order to include
	the typeclass_info in the non-locals -- the remaining (duplicate)
	solutions are pruned away.

compiler/higher_order.m:
	Use the new maps instead of looking at the arguments of type_info/1
	and typeclass_info/1 types.  We plan to remove this information
	from type_info and typeclass_info types in future.

	Previously, this module used the type argument in order to update
	the varmaps when the curried arguments of a higher order call are
	added as arguments to the procedure in which the call occurs.
	We now look up this information at the point where the curried arg
	variables are known, and store this information in higher_order_arg
	alongside the types where it used to be stored.  This structure is
	threaded through to the place where the information is needed.

	Fix a cut and paste bug in higher_order_arg_depth/1.  It was
	previously calling higher_order_args_size/1 in the recursive
	call, instead of calling higher_order_args_depth/1.

compiler/inlining.m:
	In inlining__do_inline_call, apply the substitutions to the entire
	rtti_varmaps structure, not just to the type_info_varmap.  (XXX Is
	there a good reason why the substitution should _not_ be applied
	to the typeclass_info varmap?)

compiler/magic_util.m:
	Avoid using polymorphism__type_info_or_ctor_type/2 and
	polymorphism__typeclass_info_class_constraint/2, as these are
	no longer supported.

compiler/*.m:
	Straightforward changes to use the new ADT.

library/injection.m:
	New library module.  This provides an `injection' type which is
	similar to the existing `bimap' type in that it implements
	back-to-back maps, but doesn't have such stringent invariants
	imposed.  In particular, the reverse map is not required to be
	injective.

	This type is used to model the relationship between prog_constraints
	and program variables that hold typeclass_infos for them.  Namely,
	the typeclass_info for a constraint can be held in two different
	variables, but one variable can never hold the typeclass_info for
	two distinct constraints.

library/library.m:
	Add the new library module.

library/list.m:
	Add list__foldl_corresponding and list__foldl2_corresponding, which
	traverse two lists in parallel, which one or two accumulators, and
	abort if there is a length mismatch.

NEWS:
	Mention the changes to the standard library.
2005-07-22 12:32:07 +00:00