mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-10 19:33:11 +00:00
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.
45 lines
1.3 KiB
Mathematica
45 lines
1.3 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 2007 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU General
|
|
% Public License - see the file COPYING in the Mercury distribution.
|
|
%-----------------------------------------------------------------------------%
|
|
%
|
|
% The Erlang back-end.
|
|
%
|
|
% This package includes
|
|
% - the ELDS data structure, which is an abstract
|
|
% representation of a subset of the Erlang language;
|
|
% - the ELDS code generator, which converts HLDS to ELDS;
|
|
% - the Erlang back-end which writes out the ELDS as Erlang code.
|
|
%
|
|
:- module erl_backend.
|
|
:- interface.
|
|
|
|
:- import_module hlds.
|
|
:- import_module parse_tree.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- include_module elds.
|
|
|
|
:- include_module erl_code_gen.
|
|
:- include_module erl_call_gen.
|
|
:- include_module erl_unify_gen.
|
|
:- include_module erl_code_util.
|
|
:- include_module erl_rtti.
|
|
|
|
:- include_module elds_to_erlang.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module backend_libs.
|
|
:- import_module check_hlds.
|
|
:- import_module libs.
|
|
:- import_module mdbcomp.
|
|
|
|
:- end_module erl_backend.
|
|
|
|
%-----------------------------------------------------------------------------%
|