Commit Graph

13 Commits

Author SHA1 Message Date
Peter Wang
c08b0aa544 Keep Erlang function names a fair bit shorter than the maximum length,
Estimated hours taken: 1
Branches: main

compiler/elds_to_erlang.m:
	Keep Erlang function names a fair bit shorter than the maximum length,
	as the Erlang compiler can derive other function names from them, which
	then exceed the maximum length.

compiler/erl_rtti.m:
	Fix a bug in generating method wrappers for non-special preds.  We were
	using the proc_arity field from the rtti_proc_label but that is the
	original arity, whereas we need to include inserted type_info arguments
	in our calculation.

	Work around a problem in which the Erlang compiler aborts on a term we
	generate for the details of type constructors, because the term is too
	big (it happens on the libs.option type).
2007-06-14 04:43:50 +00:00
Peter Ross
b397669dad Implement the array module in erlang.
Estimated hours taken: 1
Branches: main

Implement the array module in erlang.

compiler/erl_rtti.m:
compiler/erlang_rtti.m:
	Handle RTTI for an array.

library/array.m:
	Erlang implementation of arrays.

library/erlang_rtti_implementation.m:
	Handle deconstruct of arrays.
2007-06-07 07:53:06 +00:00
Peter Ross
d4749f2a3b Handle dummy types in the RTTI.
Estimated hours taken: main
Branches: 2

Handle dummy types in the RTTI.

compiler/erl_rtti.m:
	Output the RTTI for dummy types.

compiler/erlang_rtti.m:
	Add the dummy alternative.

library/erlang_rtti_implementation.m:
	Handle dummy types in deconstruct.
2007-06-05 07:59:35 +00:00
Peter Ross
a740857022 Finish the implementation of deconstruct.
Estimated hours taken: 6
Branches: main

Finish the implementation of deconstruct.
We now handle plain and pseudo type_infos correctly.

compiler/erl_rtti.m:
	Make rtti_pseudo_type_info_to_elds and rtti_type_info_to_elds
	return a erlang_rtti_implementation.maybe_pseudo_type_info.
	Records in the details field for the equivalence type, the
	pseudo type info which is the RHS of the equivalence.

library/erlang_rtti_implementation.m:
	Implement collapse_equivalences, and thus handle equivalence
	types in deconstruct.
	Add XXX for handling the noncanonical special types.
	Implement the function type_info/2 which will take a
	maybe_pseudo_type_info and return the instantiated type_info.
2007-06-05 04:55:46 +00:00
Peter Ross
28dbb5766e Get deconstruct working on list's for the erlang backend.
Estimated hours taken: 2
Branches: main

Get deconstruct working on list's for the erlang backend.

compiler/erlang_rtti.m:
	Remove the rtti_maybe_pseudo_type_info from erlang_list
	as it isn't needed.

compiler/erl_rtti.m:
	Handle the new type of erlang_list.

library/erlang_rtti_implementation.m:
	The code for handling deconstruct of a list.
	Plus add some more debugging printfs.
2007-06-04 09:05:41 +00:00
Peter Ross
b2d0b45997 Implement the RTTI for calling deconstruct on du types.
Estimated hours taken: 8
Branches: main

Implement the RTTI for calling deconstruct on du types.

compiler/erl_rtti.m:
	Fix a bug where we gave the incorrect arity of notag functors.
	Give the correct ordinal to enum and du functors.
	Rewrite rtti_type_info_to_elds and rtti_pseudo_type_info_to_elds
	so that we no longer generate code which causes an infinite loop
	when constructing these types.
	Represent functors of a du type
	as the list(erlang_rtti_implementaiton.erlang_du_functor) in the
	RTTI.
	Rename convert_to_elds_term to rtti_elds_expr and adapt the code
	so that it can be passed erlang_du_functors and generate the correct
	representation.

compiler/erl_unify_gen.m:
	Add a comment about a case where we generate unifications which
	the RTTI deconstruct code can't deal with correctly.

compiler/erlang_rtti.m:
	Fix up the documentation on edu_ordinal.
	Change edu_rep to be a distinct type so that rtti_to_elds_expr
	can handle this part of the erlang_du_functor specially.

library/erlang_rtti_implementation.m:
	Make a "copy" of the erlang_du_functor type and all the associated
	types.
	Interpret the new erlang_du_functor type so that we can
	deconstruct du types.
2007-06-04 07:46:09 +00:00
Peter Ross
843ce107f1 Place a prefix on each functor of
Estimated hours taken: 0.25
Branches: main

compiler/erl_rtti.m:
library/erlang_rtti_implementation.m:
	Place a prefix on each functor of
	erlang_type_ctor_rep.
2007-06-01 06:05:43 +00:00
Peter Ross
58ad897b40 Fill in the maybe(exist_info) part of the du_functor description.
Estimated hours taken: 2
Branches: main

Fill in the maybe(exist_info) part of the du_functor description.

compiler/erl_rtti.m:
	Define convert_to_elds_term which takes a ground mercury
	type and creates the erlang term representation of that
	ground type.
	This means that the part of the du_functor which contains
	the maybe(exist_info) can directly interpret that part of
	the RTTI as maybe(exist_info).

compiler/elds.m:
	Fix a bug that we were using elds_atom_raw, rather than
	elds_atom.
2007-06-01 05:28:26 +00:00
Peter Ross
ced4348612 Implement the Erlang RTTI details field for du types,
Estimated hours taken: 2
Branches: main

compiler/erl_rtti.m:
	Implement the Erlang RTTI details field for du types,
	except for exist_info structures.
2007-06-01 04:22:10 +00:00
Peter Ross
6546696001 Implement the RTTI for describing equivalence types fully.
Estimated hours taken: 6
Branches: main

Implement the RTTI for describing equivalence types fully.  This
required implementing the RTTI for outputting static pseudo and plain
type_infos.

compiler/erl_rtti.m:
	Generate the full RTTI for equivalence types, this required
	generating RTTI for static pseudo and plain type_infos.


compiler/elds_to_erlang.m:
	Fix output_rtti_id to use the routines from rtti.m to generate
	unique names for pieces of rtti.

compiler/elds.m:
	Use rtti_type_ctor, rtti_type_info and rtti_pseudo_type_info to
	identify pieces of rtti.
	Rearrange some code.

compiler/erl_unify_gen.m:
	Handle changes to elds_rtti_id.

compiler/rtti.m:
	Move type_info_to_string and pseudo_type_info_to_string to
	the interface so that output_rtti_id could use them.
2007-06-01 04:12:50 +00:00
Peter Ross
85bb27cfe0 New implementation of RTTI for the Erlang backend.
Estimated hours taken: 12
Branches: main

New implementation of RTTI for the Erlang backend.  Currently the RTTI only
supports generic compare and unify, deconstruct and construct are still to
come.

compiler/erl_rtti.m:
	Add a function which converts rtti_data to erlang_rtti_data.
	Change rtti_data_list_to_elds to operate on erlang_rtti_data,
	and output a erlang tuple which represents a type_ctor_info.

compiler/erlang_rtti.m:
	The definition of the RTTI needed for the Erlang backend,
	for the moment only the type_ctor_info differs from the
	low-level backends.
	This was designed in conjunction with zs.

compiler/backend_libs.m:
	Add erlang_rtti.

compiler/elds.m:
	Add a utility predicate which returns the erlang representation
	of enum type for a given functor.

compiler/mercury_compile.m:
	Call the new erl_rtti predicates.

library/builtin.m:
	Call the erlang_rtti_implementation generic compare and unify
	predicates.

library/erlang_rtti_implementation.m:
	An implementation of generic compare and unify in Mercury,
	with some tiny bits of erlang foreign_procs to inspect a type_info
	and type_ctor_info.

library/library.m:
	Reference the erlang_rtti_implementation module.

library/rtti_implementation.m:
	Remove all the Erlang code as this implementation of
	RTTI is too low-level.
2007-06-01 02:13:02 +00:00
Peter Ross
e3f8bbf9aa Implement the TypeCtorInfo RTTI so that generic compare
Estimated hours taken: 16
Branches: main

Implement the TypeCtorInfo RTTI so that generic compare
and unify work via rtti_implementation.

However after discussion with zs, this current design of
RTTI has to be adapted to become more erlang specific, due
to the different data representation on the erlang backend.
The current code will serve as a template for this new design
though, which is why it is being checked in.

Add various erlang library implementations which are
needed to run useful programs when testing the erlang backend.

compiler/elds.m:
	Add a type_info_id.

compiler/elds_to_erlang.m:
	We now generate type_ctor_info's so call them.

compiler/erl_rtti.m:
	After discussions with zs, type_info and pseudo_type_infos
	should never occur on the erlang backend as they are needed
	for gc and the debugger so throw an exception for them.
	Add an implementation of creating a static type_info, but which
	isn't used in case we need it again later.
	Create type_ctor_info with all the fields except the
	TypeFunctors, the TypeLayout and the FunctorNumberMap

compiler/special_pred.m:
	Make sure we generate RTTI for the builtin types.

library/builtin.m:
library/char.m:
library/exception.m:
library/float.m:
library/int.m:
library/io.m:
library/lexer.m:
library/math.m:
library/mutvar.m:
library/ops.m:
library/par_builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/solutions.m:
library/store.m:
library/string.m:
library/table_builtin.m:
library/thread.semaphore.m:
library/time.m:
library/type_desc.m:
	Erlang implementations of std library functions.
2007-05-30 08:16:09 +00:00
Peter Wang
4f723d6a53 Add initial support for typeclasses in the Erlang backend.
Estimated hours taken: 30
Branches: main

Add initial support for typeclasses in the Erlang backend.

Fix some bugs in the Erlang backend.  Most of these are related to the
optimisation that does away with unused and dummy arguments.  We cannot drop
those arguments for higher order functions, and we must materialise any
references to dummy arguments if they appear for some reason, e.g. in
contexts where they can't be dropped.

compiler/elds.m:
	Extend the ELDS for Erlang functions that, when called, return
	structures containing RTTI data.

	Collapse the representations of plain calls, higher order calls and
	calls to builtins so they share a single function symbol.

	Add references to RTTI data as a new type of ELDS expression.

	Simplify the implementation of join_exprs, whic also works better if
	one of the expressions to be joined could be an empty elds_block.

	Add some more helper predicates.

compiler/elds_to_erlang.m:
	Generate to code of standard modules to mercury__<module>.erl files,
	rather than <module>.erl.

	Output RTTI function definitions and export them to other modules.

	Fix a bug where opt_imported predicates were being qualified with their
	declaring module, even though the code was being generated in the
	current module.

	Quote more atoms which are spelt the same as Erlang keywords.

	Conform to other changes in the ELDS.

compiler/erl_call_gen.m:
	Generate code for class method calls.

	Materialise variables of dummy types if they appear in the argument
	lists of calls.

	Fix bugs in which arguments of dummy types were being dropped from
	the argument lists of higher order procedure calls.

	Refactor some code which was duplicated between plain calls, higher
	order calls and class method calls.

compiler/erl_code_gen.m:
	Fix some cases where references to unbound variables would show up
	after `erroneous' goals.

	Generate code for promise_purity and barrier scopes goals.

compiler/erl_code_util.m:
	Add a parameter to erl_gen_arg_list to control whether dummy and
	unused arguments should be discarded when dividing call arguments
	into inputs and outputs.

	Add erl_gen_arg_list_arg_modes which can be used instead of
	erl_gen_arg_list_arg_modes when only arg_modes are available
	(instead of modes).

	Add erl_base_typeclass_info_method_offset which returns the offset
	into the typeclass_info tuple of the first typeclass method.

	Conform to changes in the ELDS.

compiler/erl_rtti.m:
	New module to generate ELDS functions that return RTTI data structures.
	Currently we only generate functions for base_typeclass_infos.

compiler/erl_backend.m:
	Include erl_rtti.

compiler/erl_unify_gen.m:
	Ignore assignment unifications between variables of dummy types.

	Handle construction of partially instantiated data structures
	by assigning free variables to `false' before the construction.

	Handle construction of type ctor infos (incomplete due to missing
	RTTI function definitions), base typeclass infos and type infos and
	typeclass infos.

	Handle dummy arguments properly when creating higher order terms.

compiler/instmap.m:
	Fix an assumption in `var_is_bound_in_instmap_delta' that the instmap
	and instmap_delta that it is passed are reachable.  It used to succeed
	for unreachable instmaps (deltas) implying that the variable was bound.
	In some cases this resulted in Erlang code not binding some variables
	that it should have when `erroneous' code was reached.

	The only other user of `var_is_bound_in_instmap_delta' is the dependent
	parallel conjunction transformation.  Currently `erroneous' goals are
	not allowed in parallel conjunctions anyway.

compiler/mercury_compile.m:
	Call the code to generate ELDS function definitions for RTTI data.

compiler/notes/compiler_design.html:
	Mention erl_rtti.m.

	s/mlds_to_rtti/rtti_to_mlds/ in a spot.
2007-05-28 03:13:53 +00:00