mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 05:44:58 +00:00
Estimated hours taken: 40 Branches: main Output Managed C++ code using the same mechanisms as we do for C# code, rather than using pragma_c_gen to generate MC++ code. This fixes the problem that functions couldn't be defined in MC++, and also should make the code more maintainable in the future as MC++ is much more similar to C# than to C. compiler/mlds.m: Add a new field to outline_foreign_proc. This field has information which links the mlds variables with the variable names used in the foreign code. compiler/ml_code_gen.m: Generate a foreign proc for MC++ the same way we generate a foreign proc for C#. Generate the data for the new field in outline_foreign_proc. Use the context of the string which contains the pragma foreign proc body for the context of the foreign proc. This ensures that error messages refer to the correct line number. compiler/mlds_to_il.m: Add to the list of foreign languages defined in the module to include those which don't have a foreign_proc defined in them. Move the relevant code from atomic_statement_to_il to generate_method so that we handle external procedures correctly. compiler/mlds_to_ilasm.m: Call mlds_to_managed. compiler/ml_backend.m: Add the new module and remove mlds_to_mcpp and mlds_to_csharp. compiler/ml_elim_nested.m: compiler/ml_optimize.m: compiler/ml_util.m: compiler/mlds_to_c.m: compiler/mlds_to_gcc.m: compiler/mlds_to_java.m: Minor changes to handling the new field in outline_foreign_proc. compiler/mlds_to_csharp.m: compiler/mlds_to_mcpp.m: Removed files whose functionality has been subsumed by mlds_to_managed. library/construct.m: library/float.m: library/io.m: library/std_util.m: library/type_desc.m: Changes required to get the library to be able compile in the ilc grade.
75 lines
2.6 KiB
Mathematica
75 lines
2.6 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 2002 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 MLDS back-end.
|
|
%
|
|
% This package includes
|
|
% - the MLDS data structure, which is an abstract
|
|
% representation of a generic imperative language;
|
|
% - the MLDS code generator, which converts HLDS to MLDS;
|
|
% - the high-level C back-end, the Java back-end, the .NET back-end,
|
|
% and a wrapper for the assembler back-end,
|
|
% each of which convert MLDS to their respective target language.
|
|
%
|
|
% The main part of the assembler back-end, which converts MLDS
|
|
% to GCC's internal abstract syntax trees and then invokes the
|
|
% GCC back-end to convert this to assembler, is in a package of
|
|
% its own, so that this package doesn't depend on the GCC back-end.
|
|
%
|
|
:- module ml_backend.
|
|
:- interface.
|
|
:- import_module transform_hlds, check_hlds. % are these needed?
|
|
:- import_module hlds, parse_tree, libs, backend_libs.
|
|
:- import_module ll_backend. % XXX needed for llds_out__name_mangle, etc.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- include_module mlds.
|
|
:- include_module ml_util.
|
|
|
|
% Phase 4-ml: MLDS-specific HLDS to HLDS transformations and annotations.
|
|
:- include_module add_heap_ops, add_trail_ops. % transformations
|
|
:- include_module mark_static_terms. % annotation
|
|
|
|
% Phase 5-ml: compile HLDS to MLDS
|
|
:- include_module ml_code_gen.
|
|
:- include_module ml_type_gen.
|
|
:- include_module ml_call_gen.
|
|
:- include_module ml_unify_gen, ml_closure_gen.
|
|
:- include_module ml_switch_gen.
|
|
:- include_module ml_string_switch, ml_tag_switch, ml_simplify_switch.
|
|
:- include_module ml_code_util.
|
|
:- include_module rtti_to_mlds.
|
|
|
|
% Phase 6-ml: MLDS -> MLDS transformations
|
|
:- include_module ml_elim_nested.
|
|
:- include_module ml_tailcall.
|
|
:- include_module ml_optimize.
|
|
|
|
% Phase 7-ml: compile MLDS to target code
|
|
|
|
% MLDS->C back-end
|
|
:- include_module mlds_to_c.
|
|
|
|
% MLDS->Assembler back-end
|
|
:- include_module maybe_mlds_to_gcc.
|
|
% :- include_module mlds_to_gcc, gcc.
|
|
|
|
% MLDS->Java back-end
|
|
:- include_module mlds_to_java, java_util.
|
|
|
|
% MLDS->.NET CLR back-end
|
|
:- include_module mlds_to_il.
|
|
:- include_module mlds_to_ilasm.
|
|
:- include_module mlds_to_managed.
|
|
:- include_module ilds.
|
|
:- include_module ilasm.
|
|
:- include_module il_peephole.
|
|
|
|
:- end_module ml_backend.
|
|
|
|
%-----------------------------------------------------------------------------%
|