[m-rev.] For review: Remove support for Managed C++
Jonathan Morgan
jonmmorgan at gmail.com
Sat Jul 7 12:25:21 AEST 2007
This change is fairly straightforward and boring. What I want review
comments on are:
* Is there anything that I've missed removing?
* Should this change be mentioned in NEWS?
* Should I move mlds_to_managed.m back to mlds_to_csharp.m (where it
was originally), or leave it as is?
I will be bootchecking this change in hlc.gc before committing to make
sure, as it is the only really important MLDS-based grade.
Jon
==================================================================
Estimated hours taken: 3
Branches: main
Removed support Managed C++ as a foreign language for the IL backend. This is
being removed for the following reasons:
* It is only supported by Microsoft, making it harder to use code
using it with other CIL platforms (e.g. Mono).
* It is not used in any of the standard library (only C# and IL are used).
* Removing it will simplify the dependencies and the build process.
* Microsoft have deprecated it in favour of C++/CLI.
aclocal.m4:
Remove checks for the Microsoft.NET C++ compiler.
compiler/globals.m:
Delete Managed C++ from the set of supported languages.
compiler/mlds_to_managed.m:
Remove support for Managed C++ code generation.
compiler/*.m:
Remove all references to Managed C++.
runtime/Mmakefile:
runtime/mercury_mcpp.h:
Remove the Managed C++ part of the Mercury runtime.
runtime/mercury_il.il:
runtime/mercury_typeclass_info.h:
runtime/mercury_type_info.h:
Remove all references to Managed C++, including instructions to keep
certain parts in sync with Managed C++ part of the runtime.
doc/reference_manual.texi:
Remove the Managed C++ sections in the Foreign Language Interface
chapter.
doc/user_guide.texi:
Remove the documentation of Managed C++ related flags.
library/Mmakefile:
Remove Managed C++ flag settings.
library/io.m:
Remove commented out Managed C++ code.
library/list.m:
Change a comment referring to Managed C++ to refer to C# instead.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Remove all rules and variables for Managed C++ from mmake.
Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.25
diff -u -u -r1.25 aclocal.m4
--- aclocal.m4 1 Feb 2006 12:10:16 -0000 1.25
+++ aclocal.m4 7 Jul 2007 01:30:29 -0000
@@ -210,22 +210,6 @@
ILASM=`basename "$ILASM"`
GACUTIL=`basename "$GACUTIL"`
-AC_PATH_PROG(MS_CL, cl)
-AC_MSG_CHECKING(for Microsoft.NET Visual C++)
-AC_CACHE_VAL(mercury_cv_microsoft_visual_cpp, [
-if test "$MS_CL" != ""; then
- changequote(<<,>>)
- MS_VISUALCPP_DIR=`expr "$MS_CL" : '\(.*\)[/\\]*[bB]in[/\\]*cl'`
- changequote([,])
- mercury_cv_microsoft_visual_cpp="yes"
-else
- MS_VISUALCPP_DIR=""
- mercury_cv_microsoft_visual_cpp="no"
-fi
-])
-AC_MSG_RESULT($mercury_cv_microsoft_visual_cpp)
-MS_CL=`basename "$MS_CL"`
-
# Check for the C# (C sharp) compiler.
# cscc is the DotGNU C# compiler.
AC_PATH_PROGS(MS_CSC, csc cscc)
@@ -278,7 +262,6 @@
AC_SUBST(ILASM)
AC_SUBST(GACUTIL)
-AC_SUBST(MS_CL)
AC_SUBST(MS_CSC)
AC_SUBST(MS_AL)
AC_SUBST(MS_DOTNET_SDK_DIR)
Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.65
diff -u -u -r1.65 add_pragma.m
--- compiler/add_pragma.m 18 May 2007 06:04:23 -0000 1.65
+++ compiler/add_pragma.m 7 Jul 2007 01:33:34 -0000
@@ -405,7 +405,6 @@
(
( Lang = lang_java
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
),
Pieces = [words("Warning:"),
fixed("`:- pragma foreign_export' declarations"),
@@ -428,11 +427,10 @@
globals.get_backend_foreign_languages(Globals,
ForeignLanguages),
(
- % XXX C# and Managed C++ exports currently cause an
+ % XXX C# exports currently cause an
% assertion failure in the MLDS->IL code generator.
Lang \= lang_csharp,
- Lang \= lang_managed_cplusplus,
list.member(Lang, ForeignLanguages)
->
module_info_get_pragma_exported_procs(!.ModuleInfo,
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.170
diff -u -u -r1.170 code_gen.m
--- compiler/code_gen.m 7 May 2007 05:21:29 -0000 1.170
+++ compiler/code_gen.m 7 Jul 2007 01:34:01 -0000
@@ -256,7 +256,6 @@
;
( Lang = lang_java
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_il
; Lang = lang_erlang
),
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.112
diff -u -u -r1.112 compile_target_code.m
--- compiler/compile_target_code.m 14 Jun 2007 11:51:33 -0000 1.112
+++ compiler/compile_target_code.m 7 Jul 2007 01:34:11 -0000
@@ -70,11 +70,6 @@
:- pred il_assemble(io.output_stream::in, file_name::in, file_name::in,
has_main::in, bool::out, io::di, io::uo) is det.
- % compile_managed_cplusplus_file(ErrorStream, MCPPFile, DLLFile, Succeeded)
- %
-:- pred compile_managed_cplusplus_file(io.output_stream::in,
- file_name::in, file_name::in, bool::out, io::di, io::uo) is det.
-
% compile_csharp_file(ErrorStream, C#File, DLLFile, Succeeded)
%
:- pred compile_csharp_file(io.output_stream::in, module_imports::in,
@@ -228,7 +223,7 @@
module_name_to_file_name(ModuleName, ".dll", yes, DllFile, !IO),
% If the module contains main/2 then we it should be built as an
- % executable. Unfortunately MC++ or C# code may refer to the dll
+ % executable. Unfortunately C# code may refer to the dll
% so we always need to build the dll.
%
il_assemble(ErrorStream, IL_File, DllFile, no_main, DllSucceeded, !IO),
@@ -285,42 +280,6 @@
invoke_system_command(ErrorStream, cmd_verbose_commands, Command,
Succeeded, !IO).
-compile_managed_cplusplus_file(ErrorStream, MCPPFileName, DLLFileName,
- Succeeded, !IO) :-
- globals.io_lookup_bool_option(verbose, Verbose, !IO),
- maybe_write_string(Verbose, "% Compiling `", !IO),
- maybe_write_string(Verbose, MCPPFileName, !IO),
- maybe_write_string(Verbose, "':\n", !IO),
- globals.io_lookup_string_option(mcpp_compiler, MCPP, !IO),
- globals.io_lookup_accumulating_option(mcpp_flags, MCPPFlagsList, !IO),
- join_string_list(MCPPFlagsList, "", "", " ", MCPPFlags),
- globals.io_lookup_bool_option(target_debug, Debug, !IO),
- (
- Debug = yes,
- DebugOpt = "/Zi "
- ;
- Debug = no,
- DebugOpt = ""
- ),
-
- % XXX Should we introduce a `--mcpp-include-directory' option?
- globals.io_lookup_accumulating_option(c_include_directory,
- C_Incl_Dirs, !IO),
- InclOpts = string.append_list(list.condense(list.map(
- (func(C_INCL) = ["-I", C_INCL, " "]), C_Incl_Dirs))),
-
- % XXX Should we use a separate dll_directories options?
- globals.io_lookup_accumulating_option(link_library_directories,
- DLLDirs, !IO),
- DLLDirOpts = "-AIMercury/dlls " ++
- string.append_list(list.condense(list.map(
- (func(DLLDir) = ["-AI", DLLDir, " "]), DLLDirs))),
-
- string.append_list([MCPP, " -CLR ", DebugOpt, InclOpts, DLLDirOpts,
- MCPPFlags, " ", MCPPFileName, " -LD -o ", DLLFileName], Command),
- invoke_system_command(ErrorStream, cmd_verbose_commands, Command,
- Succeeded, !IO).
-
compile_csharp_file(ErrorStream, Imports, CSharpFileName0, DLLFileName,
Succeeded, !IO) :-
globals.io_lookup_bool_option(verbose, Verbose, !IO),
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.110
diff -u -u -r1.110 export.m
--- compiler/export.m 7 May 2007 05:21:29 -0000 1.110
+++ compiler/export.m 7 Jul 2007 01:34:54 -0000
@@ -143,7 +143,6 @@
ModuleInfo, ArgDecls)
;
( Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_java
; Lang = lang_il
; Lang = lang_erlang
@@ -721,7 +720,6 @@
;
( Lang = lang_csharp
; Lang = lang_java
- ; Lang = lang_managed_cplusplus
; Lang = lang_il
; Lang = lang_erlang
),
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.71
diff -u -u -r1.71 foreign.m
--- compiler/foreign.m 7 May 2007 05:21:30 -0000 1.71
+++ compiler/foreign.m 7 Jul 2007 01:35:08 -0000
@@ -259,23 +259,6 @@
(
ForeignLanguage = lang_c
;
- ( ForeignLanguage = lang_managed_cplusplus
- ; ForeignLanguage = lang_csharp
- ; ForeignLanguage = lang_il
- ; ForeignLanguage = lang_java
- ; ForeignLanguage = lang_erlang
- ),
- unimplemented_combination(TargetLanguage, ForeignLanguage)
- )
- ;
- TargetLanguage = lang_managed_cplusplus,
- (
- ( ForeignLanguage = lang_managed_cplusplus
- ; ForeignLanguage = lang_c
- )
- % Don't do anything - C and MC++ are embedded inside MC++
- % without any changes.
- ;
( ForeignLanguage = lang_csharp
; ForeignLanguage = lang_il
; ForeignLanguage = lang_java
@@ -289,7 +272,6 @@
ForeignLanguage = lang_csharp
;
( ForeignLanguage = lang_c
- ; ForeignLanguage = lang_managed_cplusplus
; ForeignLanguage = lang_il
; ForeignLanguage = lang_java
; ForeignLanguage = lang_erlang
@@ -302,7 +284,6 @@
ForeignLanguage = lang_il
;
( ForeignLanguage = lang_c
- ; ForeignLanguage = lang_managed_cplusplus
; ForeignLanguage = lang_csharp
; ForeignLanguage = lang_java
; ForeignLanguage = lang_erlang
@@ -315,7 +296,6 @@
ForeignLanguage = lang_java
;
( ForeignLanguage = lang_c
- ; ForeignLanguage = lang_managed_cplusplus
; ForeignLanguage = lang_csharp
; ForeignLanguage = lang_il
; ForeignLanguage = lang_erlang
@@ -328,7 +308,6 @@
ForeignLanguage = lang_erlang
;
( ForeignLanguage = lang_c
- ; ForeignLanguage = lang_managed_cplusplus
; ForeignLanguage = lang_csharp
; ForeignLanguage = lang_il
; ForeignLanguage = lang_java
@@ -357,9 +336,6 @@
:- func make_pred_name_rest(foreign_language, sym_name) = string.
make_pred_name_rest(lang_c, _SymName) = "some_c_name".
-make_pred_name_rest(lang_managed_cplusplus, qualified(ModuleSpec, Name)) =
- make_pred_name_rest(lang_managed_cplusplus, ModuleSpec) ++ "__" ++ Name.
-make_pred_name_rest(lang_managed_cplusplus, unqualified(Name)) = Name.
make_pred_name_rest(lang_csharp, _SymName) = "some_csharp_name".
make_pred_name_rest(lang_il, _SymName) = "some_il_name".
make_pred_name_rest(lang_java, _SymName) = "some_java_name".
@@ -672,8 +648,6 @@
).
to_type_string(lang_csharp, foreign(ForeignType, _)) =
sym_name_to_string(ForeignType).
-to_type_string(lang_managed_cplusplus, foreign(ForeignType, _)) =
- sym_name_to_string_sep(ForeignType, "::") ++ " *".
to_type_string(lang_il, foreign(ForeignType, _)) =
sym_name_to_string(ForeignType).
to_type_string(lang_java, foreign(ForeignType, _)) =
@@ -702,12 +676,6 @@
).
to_type_string(lang_csharp, mercury(_Type)) = _ :-
sorry(this_file, "to_type_string for csharp").
-to_type_string(lang_managed_cplusplus, mercury(Type)) = TypeString :-
- ( Type = type_variable(_, _) ->
- TypeString = "MR_Box"
- ;
- TypeString = to_type_string(lang_c, mercury(Type))
- ).
to_type_string(lang_il, mercury(_Type)) = _ :-
sorry(this_file, "to_type_string for il").
to_type_string(lang_java, mercury(Type)) = Result :-
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.83
diff -u -u -r1.83 globals.m
--- compiler/globals.m 7 May 2007 06:59:23 -0000 1.83
+++ compiler/globals.m 7 Jul 2007 01:35:11 -0000
@@ -55,7 +55,6 @@
---> lang_c
% ; lang_cplusplus
; lang_csharp
- ; lang_managed_cplusplus
; lang_java
; lang_il
; lang_erlang.
@@ -294,9 +293,6 @@
is semidet.
convert_foreign_language_2("c", lang_c).
-convert_foreign_language_2("mc++", lang_managed_cplusplus).
-convert_foreign_language_2("managedc++", lang_managed_cplusplus).
-convert_foreign_language_2("managed c++", lang_managed_cplusplus).
convert_foreign_language_2("c#", lang_csharp).
convert_foreign_language_2("csharp", lang_csharp).
convert_foreign_language_2("c sharp", lang_csharp).
@@ -332,15 +328,12 @@
compilation_target_string(target_erlang) = "Erlang".
foreign_language_string(lang_c) = "C".
-foreign_language_string(lang_managed_cplusplus) = "Managed C++".
foreign_language_string(lang_csharp) = "C#".
foreign_language_string(lang_il) = "IL".
foreign_language_string(lang_java) = "Java".
foreign_language_string(lang_erlang) = "Erlang".
simple_foreign_language_string(lang_c) = "c".
-simple_foreign_language_string(lang_managed_cplusplus) = "cpp".
- % XXX mcpp is better
simple_foreign_language_string(lang_csharp) = "csharp".
simple_foreign_language_string(lang_il) = "il".
simple_foreign_language_string(lang_java) = "java".
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.303
diff -u -u -r1.303 handle_options.m
--- compiler/handle_options.m 25 Jun 2007 00:58:11 -0000 1.303
+++ compiler/handle_options.m 7 Jul 2007 01:35:25 -0000
@@ -1847,7 +1847,7 @@
BackendForeignLanguages = ["c"]
;
Target = target_il,
- BackendForeignLanguages = ["il", "csharp", "mc++"],
+ BackendForeignLanguages = ["il", "csharp"],
set_option(optimize_constructor_last_call, bool(no), !Globals)
;
Target = target_asm,
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.220
diff -u -u -r1.220 intermod.m
--- compiler/intermod.m 17 May 2007 03:52:44 -0000 1.220
+++ compiler/intermod.m 7 Jul 2007 01:36:23 -0000
@@ -379,9 +379,7 @@
Target = target_il,
Lang = C ^ clause_lang,
Lang = impl_lang_foreign(ForeignLang),
- ( ForeignLang = lang_csharp
- ; ForeignLang = lang_managed_cplusplus
- ).
+ ForeignLang = lang_csharp.
clauses_contain_noninlinable_foreign_code(Target, [_ | Cs]) :-
clauses_contain_noninlinable_foreign_code(Target, Cs).
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.309
diff -u -u -r1.309 llds_out.m
--- compiler/llds_out.m 12 Jun 2007 06:06:29 -0000 1.309
+++ compiler/llds_out.m 7 Jul 2007 01:37:05 -0000
@@ -1310,7 +1310,6 @@
;
( Lang = lang_java
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_il
; Lang = lang_erlang
),
@@ -1357,7 +1356,6 @@
;
( Lang = lang_java
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_il
; Lang = lang_erlang
),
Index: compiler/make.dependencies.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.38
diff -u -u -r1.38 make.dependencies.m
--- compiler/make.dependencies.m 30 May 2007 05:15:04 -0000 1.38
+++ compiler/make.dependencies.m 7 Jul 2007 01:37:15 -0000
@@ -255,9 +255,6 @@
direct_imports),
module_target_il_asm `of`
filter_module_names(maybe_keep_std_lib_module,
foreign_imports_lang(lang_il)),
- module_target_foreign_il_asm(lang_managed_cplusplus) `of`
- filter_module_names(maybe_keep_std_lib_module,
- foreign_imports_lang(lang_managed_cplusplus)),
module_target_foreign_il_asm(lang_csharp) `of`
filter_module_names(maybe_keep_std_lib_module,
foreign_imports_lang(lang_csharp))
Index: compiler/make.module_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.55
diff -u -u -r1.55 make.module_target.m
--- compiler/make.module_target.m 30 May 2007 05:15:04 -0000 1.55
+++ compiler/make.module_target.m 7 Jul 2007 01:37:18 -0000
@@ -495,11 +495,6 @@
foreign_code_file(lang_java, JavaFile, _ClassFile), Succeeded, !IO) :-
compile_target_code.compile_java_file(ErrorStream, JavaFile,
Succeeded, !IO).
-compile_foreign_code_file(ErrorStream, _, _Imports,
- foreign_code_file(lang_managed_cplusplus, MCPPFile, DLLFile),
- Succeeded, !IO) :-
- compile_target_code.compile_managed_cplusplus_file(ErrorStream,
- MCPPFile, DLLFile, Succeeded, !IO).
compile_foreign_code_file(ErrorStream, _, Imports,
foreign_code_file(lang_csharp, CSharpFile, DLLFile),
Succeeded, !IO) :-
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.74
diff -u -u -r1.74 make.program_target.m
--- compiler/make.program_target.m 8 Jun 2007 00:47:10 -0000 1.74
+++ compiler/make.program_target.m 7 Jul 2007 01:37:23 -0000
@@ -1649,15 +1649,7 @@
make_remove_file(very_verbose, CSharpModule,
foreign_language_file_extension(lang_csharp), !Info, !IO),
make_remove_target_file(very_verbose, CSharpModule,
- module_target_foreign_il_asm(lang_csharp), !Info, !IO),
-
- McppModule = foreign_language_module_name(ModuleName,
- lang_managed_cplusplus),
- make_remove_file(very_verbose, McppModule,
- foreign_language_file_extension(lang_managed_cplusplus),
- !Info, !IO),
- make_remove_target_file(very_verbose, McppModule,
- module_target_foreign_il_asm(lang_managed_cplusplus), !Info, !IO).
+ module_target_foreign_il_asm(lang_csharp), !Info, !IO).
:- pred make_module_realclean(module_name::in, make_info::in, make_info::out,
io::di, io::uo) is det.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.443
diff -u -u -r1.443 mercury_compile.m
--- compiler/mercury_compile.m 22 Jun 2007 08:31:08 -0000 1.443
+++ compiler/mercury_compile.m 7 Jul 2007 01:37:54 -0000
@@ -4682,10 +4682,6 @@
sorry(this_file, ":- import_module not yet implemented: " ++
"`:- pragma foreign_import_module' for C#")
;
- Lang = lang_managed_cplusplus,
- sorry(this_file, ":- import_module not yet implemented: " ++
- "`:- pragma foreign_import_module' for Managed C++")
- ;
Lang = lang_il,
sorry(this_file, ":- import_module not yet implemented: " ++
"`:- pragma foreign_import_module' for IL")
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.199
diff -u -u -r1.199 ml_code_gen.m
--- compiler/ml_code_gen.m 7 May 2007 05:21:32 -0000 1.199
+++ compiler/ml_code_gen.m 7 Jul 2007 01:38:09 -0000
@@ -2404,7 +2404,7 @@
( CodeModel = model_non ->
% For IL code, we can't call continutations because there is no syntax
- % for calling managed function pointers in managed C++. Instead we have
+ % for calling managed function pointers in C#. Instead we have
% to call back into IL and make the continuation call in IL. This is
% called an "indirect" success continuation call.
%
@@ -2541,11 +2541,6 @@
PredId, ProcId, Args, ExtraArgs,
Foreign_Code, Context, Decls, Statements, !Info)
;
- Lang = lang_managed_cplusplus,
- ml_gen_ordinary_pragma_managed_proc(OrdinaryKind, Attributes,
- PredId, ProcId, Args, ExtraArgs,
- Foreign_Code, Context, Decls, Statements, !Info)
- ;
Lang = lang_csharp,
ml_gen_ordinary_pragma_managed_proc(OrdinaryKind, Attributes,
PredId, ProcId, Args, ExtraArgs,
@@ -2615,7 +2610,7 @@
; kind_semi
; kind_failure.
- % For ordinary (not model_non) pragma foreign_code in C# or MC++,
+ % For ordinary (not model_non) pragma foreign_code in C#,
% we generate a call to an out-of-line procedure that contains
% the user's code.
%
@@ -3253,9 +3248,7 @@
HighLevelData = no,
% For --no-high-level-data, we only need to use a cast is for
% polymorphic types, which are `MR_Word' in the C interface but
- % `MR_Box' in the MLDS back-end. Except for MC++, where
- % polymorphic types are MR_Box, but we get here only if Lang
- % is c or java.
+ % `MR_Box' in the MLDS back-end.
( OrigType = type_variable(_, _) ->
Cast = "(MR_Word) "
; MaybeCast = yes(CastPrime) ->
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.216
diff -u -u -r1.216 mlds_to_c.m
--- compiler/mlds_to_c.m 15 Jun 2007 12:12:30 -0000 1.216
+++ compiler/mlds_to_c.m 7 Jul 2007 01:38:26 -0000
@@ -806,7 +806,6 @@
;
( Lang = lang_java
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_il
; Lang = lang_erlang
),
@@ -850,7 +849,6 @@
;
( Lang = lang_il
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_java
; Lang = lang_erlang
),
@@ -863,9 +861,6 @@
mlds_output_c_defn(_Indent, user_foreign_code(lang_c, Code, Context), !IO) :-
output_context(mlds_make_context(Context), !IO),
io.write_string(Code, !IO).
-mlds_output_c_defn(_Indent, user_foreign_code(lang_managed_cplusplus, _, _),
- !IO) :-
- sorry(this_file, "foreign code other than C").
mlds_output_c_defn(_Indent, user_foreign_code(lang_csharp, _, _), !IO) :-
sorry(this_file, "foreign code other than C").
mlds_output_c_defn(_Indent, user_foreign_code(lang_il, _, _), !IO) :-
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.184
diff -u -u -r1.184 mlds_to_il.m
--- compiler/mlds_to_il.m 20 Jun 2007 03:15:56 -0000 1.184
+++ compiler/mlds_to_il.m 7 Jul 2007 01:38:38 -0000
@@ -53,7 +53,7 @@
% [ ] Add an option to do overflow checking.
% [ ] Should replace hard-coded of int32 with a more abstract name such
% as `mercury_int_il_type'.
-% [ ] Implement `pragma foreign_export' for C# and MC++.
+% [ ] Implement `pragma foreign_export' for C#.
%
% XXX We should rename this module to mlds_to_ilds, since that is what
% it actually does.
@@ -87,9 +87,8 @@
%-----------------------------------------------------------------------------%
% The following predicates are exported so that we can get type
- % conversions and name mangling consistent between the C# and managed
- % C++ output (currently in mlds_to_managed.m) and IL output (in
- % this file).
+ % conversions and name mangling consistent between the C# output
+ % (currently in mlds_to_managed.m) and IL output (in this file).
%
% XXX we should reduce the dependencies here to a bare minimum.
%
@@ -307,7 +306,7 @@
IlInfo0, IlInfo),
list.filter(has_foreign_code_defined(ForeignCode),
- [lang_managed_cplusplus, lang_csharp], ForeignCodeLangs),
+ [lang_csharp], ForeignCodeLangs),
ForeignLangs = IlInfo ^ file_foreign_langs `union`
set.list_to_set(ForeignCodeLangs),
@@ -1860,9 +1859,9 @@
% For commits, we use exception handling.
%
% For a do_commit instruction, we generate code equivalent
- % to the following C++/C#/Java code:
+ % to the following C#/Java code:
%
- % throw new mercury::runtime::Commit();
+ % throw new mercury.runtime.Commit();
%
% In IL the code looks like this:
%
Index: compiler/mlds_to_ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_ilasm.m,v
retrieving revision 1.37
diff -u -u -r1.37 mlds_to_ilasm.m
--- compiler/mlds_to_ilasm.m 7 May 2007 05:21:34 -0000 1.37
+++ compiler/mlds_to_ilasm.m 7 Jul 2007 01:38:38 -0000
@@ -92,9 +92,7 @@
:- pred handle_foreign_lang(foreign_language::in,
pred(mlds, io, io)::out(pred(in, di, uo) is det)) is det.
-handle_foreign_lang(lang_managed_cplusplus,
- output_managed_code(lang_managed_cplusplus)).
-handle_foreign_lang(lang_csharp, output_managed_code(lang_csharp)).
+handle_foreign_lang(lang_csharp, output_csharp_code).
handle_foreign_lang(lang_c, _) :-
sorry(this_file, "language C foreign code not supported").
handle_foreign_lang(lang_il, _) :-
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.93
diff -u -u -r1.93 mlds_to_java.m
--- compiler/mlds_to_java.m 15 Jun 2007 12:12:33 -0000 1.93
+++ compiler/mlds_to_java.m 7 Jul 2007 01:38:48 -0000
@@ -472,7 +472,6 @@
;
( Lang = lang_c
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_il
; Lang = lang_erlang
),
@@ -492,7 +491,6 @@
;
( Lang = lang_c
; Lang = lang_csharp
- ; Lang = lang_managed_cplusplus
; Lang = lang_il
; Lang = lang_erlang
),
Index: compiler/mlds_to_managed.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_managed.m,v
retrieving revision 1.41
diff -u -u -r1.41 mlds_to_managed.m
--- compiler/mlds_to_managed.m 6 Jun 2007 01:17:36 -0000 1.41
+++ compiler/mlds_to_managed.m 7 Jul 2007 01:38:50 -0000
@@ -9,27 +9,22 @@
% Module: mlds_to_managed.m.
% Main author: trd, petdr.
%
-% Generate code for the foreign language interface to C# and managed C++.
+% Generate code for the foreign language interface to C#.
%
%-----------------------------------------------------------------------------%
:- module ml_backend.mlds_to_managed.
:- interface.
-:- import_module libs.globals.
:- import_module ml_backend.mlds.
:- import_module io.
%-----------------------------------------------------------------------------%
-:- inst managed_lang == bound(lang_csharp; lang_managed_cplusplus).
-
- % Convert the MLDS to the specified foreign language and write
- % it to a file.
+ % Convert the MLDS to C# and write it to a file.
%
-:- pred output_managed_code(foreign_language::in(managed_lang), mlds::in,
- io::di, io::uo) is det.
+:- pred output_csharp_code(mlds::in, io::di, io::uo) is det.
% Print the header comments of the output module.
%
@@ -46,6 +41,7 @@
:- import_module backend_libs.c_util.
:- import_module libs.compiler_util.
+:- import_module libs.globals.
:- import_module libs.options.
:- import_module mdbcomp.prim_data.
:- import_module ml_backend.ilds.
@@ -68,12 +64,12 @@
%-----------------------------------------------------------------------------%
-output_managed_code(Lang, MLDS, !IO) :-
+output_csharp_code(MLDS, !IO) :-
MLDS = mlds(ModuleName, _ForeignCode, _Imports, _Defns,
_InitPreds, _FinalPreds),
output_src_start(ModuleName, !IO),
io.nl(!IO),
- generate_code(Lang, MLDS, !IO),
+ generate_code(MLDS, !IO),
output_src_end(ModuleName, !IO).
%-----------------------------------------------------------------------------%
@@ -97,50 +93,38 @@
%-----------------------------------------------------------------------------%
-:- pred generate_code(foreign_language::in(managed_lang), mlds::in,
- io::di, io::uo) is det.
+:- pred generate_code(mlds::in, io::di, io::uo) is det.
-generate_code(Lang, MLDS, !IO) :-
- MLDS = mlds(ModuleName, AllForeignCode, Imports, Defns,
+generate_code(MLDS, !IO) :-
+ MLDS = mlds(ModuleName, AllForeignCode, _Imports, Defns,
_InitPreds, _FinalPreds),
ClassName = class_name(mercury_module_name_to_mlds(ModuleName),
wrapper_class_name),
io.nl(!IO),
- % Output any generic header code specific to the target language.
- output_language_specific_header_code(Lang, ModuleName, Imports, !IO),
+ output_csharp_header_code(!IO),
% Get the foreign code for the required language.
- ForeignCode = map.lookup(AllForeignCode, Lang),
- generate_foreign_header_code(Lang, ModuleName, ForeignCode, !IO),
+ ForeignCode = map.lookup(AllForeignCode, lang_csharp),
+ generate_foreign_header_code(ForeignCode, !IO),
% Output the namespace.
- generate_namespace_details(Lang, ClassName, NameSpaceFmtStr, Namespace),
+ generate_namespace_details(ClassName, NameSpaceFmtStr, Namespace),
io.write_list(Namespace, "\n",
(pred(N::in, !.IO::di, !:IO::uo) is det :-
io.format(NameSpaceFmtStr, [s(N)], !IO)
), !IO),
- (
- Lang = lang_csharp,
- io.write_strings(["\npublic class " ++ wrapper_class_name, "{\n"],
- !IO)
- ;
- Lang = lang_managed_cplusplus,
- io.write_strings(["\n__gc public class " ++ wrapper_class_name,
- "{\n", "public:\n"], !IO)
- ),
+ io.write_strings(["\npublic class " ++ wrapper_class_name, "{\n"], !IO),
% Output the contents of pragma foreign_code declarations.
- generate_foreign_code(Lang,
- mercury_module_name_to_mlds(ModuleName), ForeignCode, !IO),
+ generate_foreign_code(ForeignCode, !IO),
io.nl(!IO),
% Output the contents of foreign_proc declarations.
% Put each one inside a method.
- list.foldl(generate_method_code(Lang,
- mercury_module_name_to_mlds(ModuleName)), Defns, !IO),
+ list.foldl(generate_method_code, Defns, !IO),
io.write_string("};\n", !IO),
@@ -151,12 +135,9 @@
), !IO),
io.nl(!IO).
-:- pred output_language_specific_header_code(
- foreign_language::in(managed_lang), mercury_module_name::in,
- mlds_imports::in, io::di, io::uo) is det.
+:- pred output_csharp_header_code(io::di, io::uo) is det.
-output_language_specific_header_code(lang_csharp, _ModuleName, _Imports,
- !IO) :-
+output_csharp_header_code(!IO) :-
get_il_data_rep(DataRep, !IO),
( DataRep = il_data_rep(yes, _) ->
io.write_string("#define MR_HIGHLEVEL_DATA\n", !IO)
@@ -177,164 +158,69 @@
;
SignAssembly = no
).
-output_language_specific_header_code(lang_managed_cplusplus, ModuleName,
- Imports, !IO) :-
- get_il_data_rep(DataRep, !IO),
- ( DataRep = il_data_rep(yes, _) ->
- io.write_string("#define MR_HIGHLEVEL_DATA\n", !IO)
- ;
- true
- ),
- io.write_string("#using <mscorlib.dll>\n", !IO),
-
- ( mercury_std_library_module_name(ModuleName) ->
- io.write_strings([
- "#using ""mercury_dotnet.dll""\n",
- "#using ""mercury_il.dll""\n"
- %,
- %"#using ""private_builtin.dll""\n",
- %"#using ""builtin.dll""\n"
- ], !IO)
- ;
- true
- ),
-
- list.map(
- (pred(Import::in, Result::out) is det :-
- ( Import = mercury_import(_, Name) ->
- ( is_std_lib_module(Name, StdLibName) ->
- ( mercury_std_library_module_name(StdLibName) ->
- Str = sym_name_to_string(StdLibName)
- ;
- Str = "mercury"
- )
- ;
- SymName = mlds_module_name_to_sym_name(Name),
- Str = sym_name_to_string(SymName)
- ),
- Result = [Str]
- ;
- Result = []
- )
- ), Imports, ImportListList),
- ActualImports = remove_dups(condense(ImportListList)),
-
- list.foldl((pred(I::in, !.IO::di, !:IO::uo) is det :-
- io.write_string("#using """, !IO),
- io.write_string(I, !IO),
- io.write_string(".dll""\n", !IO)
- ), ActualImports, !IO),
-
- io.write_strings([
- "#using """, sym_name_to_string(ModuleName), ".dll""\n",
- "#include ""mercury_mcpp.h""\n",
-
- % XXX We have to use the mercury namespace, as
- % llds_out still generates some of the code used
- % in the MC++ interface, and so it doesn't have
- % "mercury::" namespace qualifiers.
- "using namespace mercury;\n",
- "\n"], !IO),
-
- globals.io_lookup_bool_option(sign_assembly, SignAssembly, !IO),
- (
- SignAssembly = yes,
- io.write_string("[assembly:System::Reflection::" ++
- "AssemblyKeyFileAttribute(\"mercury.sn\")];\n", !IO)
- ;
- SignAssembly = no
- ).
-
-:- pred generate_foreign_header_code(foreign_language::in(managed_lang),
- module_name::in, mlds_foreign_code::in, io::di, io::uo) is det.
+:- pred generate_foreign_header_code(mlds_foreign_code::in,
+ io::di, io::uo) is det.
-generate_foreign_header_code(Lang, ModuleName, ForeignCode, !IO) :-
- ForeignCode = mlds_foreign_code(RevHeaderCode, RevImports,
+generate_foreign_header_code(ForeignCode, !IO) :-
+ ForeignCode = mlds_foreign_code(RevHeaderCode, _RevImports,
_RevBodyCode, _ExportDefns),
- % Only MC++ can declare which assemblies it refers to in its
- % source file. C# declares which assemblies it refers to via
- % command line arguments to the C# compiler.
- (
- Lang = lang_managed_cplusplus,
- Imports = list.reverse(RevImports),
- list.foldl(
- (pred(ForeignImport::in, !.IO::di, !:IO::uo) is det :-
- module_name_to_search_file_name(
- foreign_import_module_name_from_module(ForeignImport,
- ModuleName),
- ".dll", FileName, !IO),
- io.write_strings(["#using """, FileName, """\n"], !IO)
- ), Imports, !IO)
- ;
- Lang = lang_csharp
- ),
HeaderCode = list.reverse(RevHeaderCode),
io.write_list(HeaderCode, "\n",
% XXX Ignoring _IsLocal may not be the right thing to do.
(pred(foreign_decl_code(CodeLang, _IsLocal, Code, Context)::in,
!.IO::di, !:IO::uo) is det :-
- output_context(Lang, Context, !IO),
- ( CodeLang = Lang ->
+ output_context(Context, !IO),
+ ( CodeLang = lang_csharp ->
io.write_string(Code, !IO),
io.nl(!IO)
;
sorry(this_file, "wrong foreign code")
),
- output_reset_context(Lang, !IO)
+ output_reset_context(!IO)
), !IO).
-:- pred generate_namespace_details(foreign_language::in(managed_lang),
- ilds.class_name::in, string::out, list(string)::out) is det.
+:- pred generate_namespace_details(ilds.class_name::in, string::out,
+ list(string)::out) is det.
-generate_namespace_details(Lang, ClassName, NameSpaceFmtStr, Namespace) :-
+generate_namespace_details(ClassName, NameSpaceFmtStr, Namespace) :-
% XXX We should consider what happens if we need to mangle
% the namespace name.
- (
- Lang = lang_csharp,
- NameExt = "__csharp_code",
- NameSpaceFmtStr = "namespace @%s {"
- ;
- Lang = lang_managed_cplusplus,
- NameExt = "__cpp_code",
- NameSpaceFmtStr = "namespace %s {"
- ),
+ NameSpaceFmtStr = "namespace @%s {",
Namespace0 = get_class_namespace(ClassName),
( list.reverse(Namespace0) = [Head | Tail] ->
- Namespace = list.reverse([Head ++ NameExt | Tail])
+ Namespace = list.reverse([Head ++ "__csharp_code" | Tail])
;
Namespace = Namespace0
).
-:- pred generate_foreign_code(foreign_language::in(managed_lang),
- mlds_module_name::in, mlds_foreign_code::in, io::di, io::uo) is det.
+:- pred generate_foreign_code(mlds_foreign_code::in, io::di, io::uo) is det.
-generate_foreign_code(Lang, _ModuleName, ForeignCode, !IO) :-
+generate_foreign_code(ForeignCode, !IO) :-
ForeignCode = mlds_foreign_code(_RevHeaderCode, _RevImports,
RevBodyCode, _ExportDefns),
BodyCode = list.reverse(RevBodyCode),
io.write_list(BodyCode, "\n",
(pred(user_foreign_code(CodeLang, Code, Context)::in,
!.IO::di, !:IO::uo) is det :-
- output_context(Lang, Context, !IO),
- ( Lang = CodeLang ->
+ output_context(Context, !IO),
+ ( CodeLang = lang_csharp ->
io.write_string(Code, !IO),
io.nl(!IO)
;
sorry(this_file, "wrong foreign code")
),
- output_reset_context(Lang, !IO)
+ output_reset_context(!IO)
), !IO).
-:- pred generate_method_code(foreign_language::in(managed_lang),
- mlds_module_name::in, mlds_defn::in, io::di, io::uo) is det.
+:- pred generate_method_code(mlds_defn::in, io::di, io::uo) is det.
-generate_method_code(_, _, mlds_defn(entity_export(_), _, _, _), !IO).
-generate_method_code(_, _, mlds_defn(entity_data(_), _, _, _), !IO).
-generate_method_code(_, _, mlds_defn(entity_type(_, _), _, _, _), !IO).
-generate_method_code(Lang, _ModuleName, Defn, !IO) :-
+generate_method_code(mlds_defn(entity_export(_), _, _, _), !IO).
+generate_method_code(mlds_defn(entity_data(_), _, _, _), !IO).
+generate_method_code(mlds_defn(entity_type(_, _), _, _, _), !IO).
+generate_method_code(Defn, !IO) :-
Defn = mlds_defn(entity_function(PredLabel, ProcId, MaybeSeqNum, _PredId),
_Context, _DeclFlags, Entity),
(
@@ -342,7 +228,7 @@
Entity = mlds_function(_, Params, body_defined_here(Statement),
_Attributes, EnvVarNames),
has_foreign_languages(Statement, Langs),
- list.member(Lang, Langs)
+ list.member(lang_csharp, Langs)
->
expect(set.empty(EnvVarNames), this_file,
"generate_method_code: EnvVarNames"),
@@ -358,64 +244,58 @@
ReturnType = simple_type(SimpleType)
;
Outputs = [_, _ | _],
- % C# and MC++ don't support multiple return values
+ % C# doesn't support multiple return values
sorry(this_file, "multiple return values")
),
predlabel_to_managed_id(PredLabel, ProcId, MaybeSeqNum, Id),
- (
- Lang = lang_csharp,
- io.write_string("public static ", !IO)
- ;
- Lang = lang_managed_cplusplus,
- io.write_string("static ", !IO)
- ),
- write_il_ret_type_as_foreign_type(Lang, ReturnType, !IO),
+ io.write_string("public static ", !IO),
+ write_il_ret_type_as_foreign_type(ReturnType, !IO),
io.write_string(" ", !IO),
io.write_string(Id, !IO),
io.write_string("(", !IO),
io.write_list(Inputs, ", ",
- write_input_arg_as_foreign_type(Lang), !IO),
+ write_input_arg_as_foreign_type, !IO),
io.write_string(")", !IO),
io.nl(!IO),
io.write_string("{\n", !IO),
- write_statement(Lang, Inputs, Statement, !IO),
+ write_statement(Inputs, Statement, !IO),
io.write_string("}\n", !IO)
;
true
).
-:- pred write_statement(foreign_language::in(managed_lang),
- mlds_arguments::in, statement::in, io::di, io::uo) is det.
+:- pred write_statement(mlds_arguments::in, statement::in,
+ io::di, io::uo) is det.
-write_statement(Lang, Args, statement(Statement, Context), !IO) :-
+write_statement(Args, statement(Statement, Context), !IO) :-
(
% XXX petdr
- Statement = atomic(outline_foreign_proc(Lang, OutlineArgs,
+ Statement = atomic(outline_foreign_proc(lang_csharp, OutlineArgs,
_Lvals, Code))
->
- list.foldl(write_outline_arg_init(Lang), OutlineArgs, !IO),
- output_context(Lang, mlds_get_prog_context(Context), !IO),
+ list.foldl(write_outline_arg_init, OutlineArgs, !IO),
+ output_context(mlds_get_prog_context(Context), !IO),
io.write_string(Code, !IO),
io.nl(!IO),
- output_reset_context(Lang, !IO),
- list.foldl(write_outline_arg_final(Lang), OutlineArgs, !IO)
+ output_reset_context(!IO),
+ list.foldl(write_outline_arg_final, OutlineArgs, !IO)
;
Statement = block(Defns, Statements)
->
- io.write_list(Defns, "", write_defn_decl(Lang), !IO),
+ io.write_list(Defns, "", write_defn_decl, !IO),
io.write_string("{\n", !IO),
- io.write_list(Statements, "", write_statement(Lang, Args), !IO),
+ io.write_list(Statements, "", write_statement(Args), !IO),
io.write_string("\n}\n", !IO)
;
Statement = return(Rvals)
->
( Rvals = [Rval] ->
io.write_string("return ", !IO),
- write_rval(Lang, Rval, !IO),
+ write_rval(Rval, !IO),
io.write_string(";\n", !IO)
;
sorry(this_file, "multiple return values")
@@ -423,56 +303,48 @@
;
Statement = atomic(assign(LVal, RVal))
->
- write_lval(Lang, LVal, !IO),
+ write_lval(LVal, !IO),
io.write_string(" = ", !IO),
- write_rval(Lang, RVal, !IO),
+ write_rval(RVal, !IO),
io.write_string(";\n", !IO)
;
functor(Statement, canonicalize, SFunctor, _Arity),
sorry(this_file, "foreign code output for " ++ SFunctor)
).
-:- pred write_outline_arg_init(foreign_language::in(managed_lang),
- outline_arg::in, io::di, io::uo) is det.
+:- pred write_outline_arg_init(outline_arg::in, io::di, io::uo) is det.
-write_outline_arg_init(Lang, in(Type, VarName, Rval), !IO) :-
- write_parameter_type(Lang, Type, !IO),
+write_outline_arg_init(in(Type, VarName, Rval), !IO) :-
+ write_parameter_type(Type, !IO),
io.write_string(" ", !IO),
io.write_string(VarName, !IO),
io.write_string(" = ", !IO),
- write_rval(Lang, Rval, !IO),
+ write_rval(Rval, !IO),
io.write_string(";\n", !IO).
-write_outline_arg_init(Lang, out(Type, VarName, _Lval), !IO) :-
- write_parameter_type(Lang, Type, !IO),
+write_outline_arg_init(out(Type, VarName, _Lval), !IO) :-
+ write_parameter_type(Type, !IO),
io.write_string(" ", !IO),
io.write_string(VarName, !IO),
% In C# give output variables a default value to avoid warnings.
- (
- Lang = lang_csharp,
- io.write_string(" = ", !IO),
- write_parameter_initializer(Lang, Type, !IO)
- ;
- Lang = lang_managed_cplusplus
- ),
+ io.write_string(" = ", !IO),
+ write_parameter_initializer(Type, !IO),
io.write_string(";\n", !IO).
-write_outline_arg_init(_Lang, unused, !IO).
+write_outline_arg_init(unused, !IO).
-:- pred write_outline_arg_final(foreign_language::in(managed_lang),
- outline_arg::in, io::di, io::uo) is det.
+:- pred write_outline_arg_final(outline_arg::in, io::di, io::uo) is det.
-write_outline_arg_final(_Lang, in(_, _, _), !IO).
-write_outline_arg_final(Lang, out(_Type, VarName, Lval), !IO) :-
- write_lval(Lang, Lval, !IO),
+write_outline_arg_final(in(_, _, _), !IO).
+write_outline_arg_final(out(_Type, VarName, Lval), !IO) :-
+ write_lval(Lval, !IO),
io.write_string(" = ", !IO),
io.write_string(VarName, !IO),
io.write_string(";\n", !IO).
-write_outline_arg_final(_Lang, unused, !IO).
+write_outline_arg_final(unused, !IO).
-:- pred write_declare_and_assign_local(foreign_language::in(managed_lang),
- mlds_argument::in, io::di, io::uo) is det.
+:- pred write_declare_and_assign_local(mlds_argument::in,
+ io::di, io::uo) is det.
-write_declare_and_assign_local(Lang, mlds_argument(Name, Type, _GcCode),
- !IO) :-
+write_declare_and_assign_local(mlds_argument(Name, Type, _GcCode), !IO) :-
( Name = entity_data(var(VarName0)) ->
VarName = VarName0
;
@@ -484,22 +356,17 @@
( is_anonymous_variable(VarName) ->
true
;
- write_parameter_type(Lang, OutputType, !IO),
+ write_parameter_type(OutputType, !IO),
io.write_string(" ", !IO),
write_mlds_var_name_for_local(VarName, !IO),
% In C# give output types a default value to avoid warnings.
- (
- Lang = lang_csharp,
- io.write_string(" = ", !IO),
- write_parameter_initializer(Lang, OutputType, !IO)
- ;
- Lang = lang_managed_cplusplus
- ),
+ io.write_string(" = ", !IO),
+ write_parameter_initializer(OutputType, !IO),
io.write_string(";\n", !IO)
)
;
- write_parameter_type(Lang, Type, !IO),
+ write_parameter_type(Type, !IO),
io.write_string(" ", !IO),
write_mlds_var_name_for_local(VarName, !IO),
io.write_string(" = ", !IO),
@@ -507,10 +374,9 @@
io.write_string(";\n", !IO)
).
-:- pred write_assign_local_to_output(foreign_language::in(managed_lang),
- mlds_argument::in, io::di, io::uo) is det.
+:- pred write_assign_local_to_output(mlds_argument::in, io::di, io::uo) is det.
-write_assign_local_to_output(Lang, mlds_argument(Name, Type, _GcCode), !IO) :-
+write_assign_local_to_output(mlds_argument(Name, Type, _GcCode), !IO) :-
( Name = entity_data(var(VarName0)) ->
VarName = VarName0
;
@@ -522,12 +388,6 @@
Type = mlds_ptr_type(_OutputType),
not is_anonymous_variable(VarName)
->
- (
- Lang = lang_csharp
- ;
- Lang = lang_managed_cplusplus,
- io.write_string("*", !IO)
- ),
write_mlds_var_name_for_parameter(VarName, !IO),
io.write_string(" = ", !IO),
write_mlds_var_name_for_local(VarName, !IO),
@@ -543,159 +403,133 @@
%-----------------------------------------------------------------------------%
-:- pred output_context(foreign_language::in(managed_lang), prog_context::in,
- io::di, io::uo) is det.
+:- pred output_context(prog_context::in, io::di, io::uo) is det.
-output_context(_Lang, Context, !IO) :-
+output_context(Context, !IO) :-
term.context_file(Context, File),
term.context_line(Context, Line),
c_util.set_line_num(File, Line, !IO).
-:- pred output_reset_context(foreign_language::in(managed_lang),
- io::di, io::uo) is det.
+:- pred output_reset_context(io::di, io::uo) is det.
-output_reset_context(_i, !IO) :-
+output_reset_context(!IO) :-
c_util.reset_line_num(!IO).
-:- pred write_rval(foreign_language::in(managed_lang), mlds_rval::in,
- io::di, io::uo) is det.
+:- pred write_rval(mlds_rval::in, io::di, io::uo) is det.
-write_rval(Lang, lval(Lval), !IO) :-
- write_lval(Lang, Lval, !IO).
-write_rval(_Lang, mkword(_Tag, _Rval), !IO) :-
+write_rval(lval(Lval), !IO) :-
+ write_lval(Lval, !IO).
+write_rval(mkword(_Tag, _Rval), !IO) :-
sorry(this_file, "mkword rval").
-write_rval(Lang, const(RvalConst), !IO) :-
- write_rval_const(Lang, RvalConst, !IO).
-write_rval(Lang, unop(Unop, Rval), !IO) :-
+write_rval(const(RvalConst), !IO) :-
+ write_rval_const(RvalConst, !IO).
+write_rval(unop(Unop, Rval), !IO) :-
(
Unop = std_unop(StdUnop),
c_util.unary_prefix_op(StdUnop, UnopStr)
->
io.write_string(UnopStr, !IO),
io.write_string("(", !IO),
- write_rval(Lang, Rval, !IO),
+ write_rval(Rval, !IO),
io.write_string(")", !IO)
;
Unop = cast(Type)
->
io.write_string("(", !IO),
- write_parameter_type(Lang, Type, !IO),
+ write_parameter_type(Type, !IO),
io.write_string(") ", !IO),
- write_rval(Lang, Rval, !IO)
+ write_rval(Rval, !IO)
;
sorry(this_file, "box or unbox unop")
).
-write_rval(Lang, binop(Binop, Rval1, Rval2), !IO) :-
+write_rval(binop(Binop, Rval1, Rval2), !IO) :-
( c_util.binary_infix_op(Binop, BinopStr) ->
io.write_string("(", !IO),
- write_rval(Lang, Rval1, !IO),
+ write_rval(Rval1, !IO),
io.write_string(") ", !IO),
io.write_string(BinopStr, !IO),
io.write_string(" (", !IO),
- write_rval(Lang, Rval2, !IO),
+ write_rval(Rval2, !IO),
io.write_string(")", !IO)
;
sorry(this_file, "binop rval")
).
-write_rval(_Lang, mem_addr(_), !IO) :-
+write_rval(mem_addr(_), !IO) :-
sorry(this_file, "mem_addr rval").
-write_rval(_Lang, self(_), !IO) :-
+write_rval(self(_), !IO) :-
sorry(this_file, "self rval").
-:- pred write_rval_const(foreign_language::in(managed_lang),
- mlds_rval_const::in, io::di, io::uo) is det.
+:- pred write_rval_const(mlds_rval_const::in, io::di, io::uo) is det.
-write_rval_const(_Lang, mlconst_true, !IO) :-
+write_rval_const(mlconst_true, !IO) :-
io.write_string("1", !IO).
-write_rval_const(_Lang, mlconst_false, !IO) :-
+write_rval_const(mlconst_false, !IO) :-
io.write_string("0", !IO).
-write_rval_const(_Lang, mlconst_int(I), !IO) :-
+write_rval_const(mlconst_int(I), !IO) :-
io.write_int(I, !IO).
-write_rval_const(_Lang, mlconst_float(F), !IO) :-
+write_rval_const(mlconst_float(F), !IO) :-
io.write_float(F, !IO).
% XXX We don't quote this correctly.
-write_rval_const(_Lang, mlconst_string(S), !IO) :-
+write_rval_const(mlconst_string(S), !IO) :-
io.write_string("""", !IO),
c_util.output_quoted_string(S, !IO),
io.write_string("""", !IO).
-write_rval_const(_Lang, mlconst_multi_string(S), !IO) :-
+write_rval_const(mlconst_multi_string(S), !IO) :-
io.write_string("""", !IO),
c_util.output_quoted_multi_string(S, !IO),
io.write_string("""", !IO).
-write_rval_const(Lang, mlconst_code_addr(CodeAddrConst), !IO) :-
+write_rval_const(mlconst_code_addr(CodeAddrConst), !IO) :-
(
CodeAddrConst = code_addr_proc(ProcLabel, _FuncSignature),
mangle_mlds_proc_label(ProcLabel, no, ClassName, MangledName),
- write_class_name(Lang, ClassName, !IO),
- write_field_selector(Lang, !IO),
+ write_class_name(ClassName, !IO),
+ io.write_string(".", !IO),
io.write_string(MangledName, !IO)
;
CodeAddrConst = code_addr_internal(ProcLabel, SeqNum, _FuncSignature),
mangle_mlds_proc_label(ProcLabel, yes(SeqNum), ClassName, MangledName),
- write_class_name(Lang, ClassName, !IO),
- write_field_selector(Lang, !IO),
+ write_class_name(ClassName, !IO),
+ io.write_string(".", !IO),
io.write_string(MangledName, !IO)
).
-write_rval_const(_Lang, mlconst_data_addr(_), !IO) :-
+write_rval_const(mlconst_data_addr(_), !IO) :-
sorry(this_file, "data_addr_const rval").
-write_rval_const(Lang, mlconst_null(_), !IO) :-
- (
- Lang = lang_csharp,
- io.write_string("null", !IO)
- ;
- Lang = lang_managed_cplusplus,
- io.write_string("NULL", !IO)
- ).
+write_rval_const(mlconst_null(_), !IO) :-
+ io.write_string("null", !IO).
-:- pred write_lval(foreign_language::in(managed_lang), mlds_lval::in,
- io::di, io::uo) is det.
+:- pred write_lval(mlds_lval::in, io::di, io::uo) is det.
-write_lval(Lang, field(_, Rval, named_field(FieldId, _Type), _, _), !IO) :-
+write_lval(field(_, Rval, named_field(FieldId, _Type), _, _), !IO) :-
io.write_string("(", !IO),
- write_rval(Lang, Rval, !IO),
+ write_rval(Rval, !IO),
io.write_string(")", !IO),
- write_field_selector(Lang, !IO),
+ io.write_string(".", !IO),
FieldId = qual(_, _, FieldName),
io.write_string(FieldName, !IO).
-write_lval(Lang, field(_, Rval, offset(OffSet), _, _), !IO) :-
+write_lval(field(_, Rval, offset(OffSet), _, _), !IO) :-
io.write_string("(", !IO),
- write_rval(Lang, Rval, !IO),
+ write_rval(Rval, !IO),
io.write_string(")", !IO),
io.write_string("[", !IO),
- write_rval(Lang, OffSet, !IO),
+ write_rval(OffSet, !IO),
io.write_string("]", !IO).
-write_lval(Lang, mem_ref(Rval, _), !IO) :-
- (
- Lang = lang_managed_cplusplus,
- io.write_string("*", !IO)
- ;
- Lang = lang_csharp
- ),
- write_rval(Lang, Rval, !IO).
-write_lval(_Lang, global_var_ref(_), !IO) :-
+write_lval(mem_ref(Rval, _), !IO) :-
+ write_rval(Rval, !IO).
+write_lval(global_var_ref(_), !IO) :-
sorry(this_file, "write_lval: global_var_ref NYI").
-write_lval(_Lang, var(Var, _VarType), !IO) :-
+write_lval(var(Var, _VarType), !IO) :-
Var = qual(_, _, VarName),
write_mlds_var_name_for_parameter(VarName, !IO).
-:- pred write_field_selector(foreign_language::in(managed_lang),
- io::di, io::uo) is det.
-
-write_field_selector(lang_csharp, !IO) :-
- io.write_string(".", !IO).
-write_field_selector(lang_managed_cplusplus, !IO) :-
- io.write_string("->", !IO).
+:- pred write_defn_decl(mlds_defn::in, io::di, io::uo) is det.
-:- pred write_defn_decl(foreign_language::in(managed_lang), mlds_defn::in,
- io::di, io::uo) is det.
-
-write_defn_decl(Lang, Defn, !IO) :-
+write_defn_decl(Defn, !IO) :-
Defn = mlds_defn(Name, _Context, _Flags, DefnBody),
(
DefnBody = mlds_data(Type, _Initializer, _GCStatement),
Name = entity_data(var(VarName))
->
- write_parameter_type(Lang, Type, !IO),
+ write_parameter_type(Type, !IO),
io.write_string(" ", !IO),
write_mlds_var_name_for_parameter(VarName, !IO),
io.write_string(";\n", !IO)
@@ -704,21 +538,20 @@
sorry(this_file, "data_addr_const rval")
).
-:- pred write_parameter_type(foreign_language::in(managed_lang),
- mlds_type::in, io::di, io::uo) is det.
+:- pred write_parameter_type(mlds_type::in, io::di, io::uo) is det.
-write_parameter_type(Lang, Type, !IO) :-
+write_parameter_type(Type, !IO) :-
get_il_data_rep(DataRep, !IO),
ILType = mlds_type_to_ilds_type(DataRep, Type),
- write_il_type_as_foreign_type(Lang, ILType, !IO).
+ write_il_type_as_foreign_type(ILType, !IO).
-:- pred write_input_arg_as_foreign_type(foreign_language::in(managed_lang),
- mlds_argument::in, io::di, io::uo) is det.
+:- pred write_input_arg_as_foreign_type(mlds_argument::in,
+ io::di, io::uo) is det.
-write_input_arg_as_foreign_type(Lang, Arg, !IO) :-
+write_input_arg_as_foreign_type(Arg, !IO) :-
Arg = mlds_argument(EntityName, Type, _GCStatement),
get_il_data_rep(DataRep, !IO),
- write_il_type_as_foreign_type(Lang, mlds_type_to_ilds_type(DataRep, Type),
+ write_il_type_as_foreign_type(mlds_type_to_ilds_type(DataRep, Type),
!IO),
io.write_string(" ", !IO),
( EntityName = entity_data(var(VarName)) ->
@@ -727,102 +560,87 @@
unexpected(this_file, "found a variable in a list")
).
-:- pred write_parameter_initializer(foreign_language::in(managed_lang),
- mlds_type::in, io::di, io::uo) is det.
+:- pred write_parameter_initializer(mlds_type::in, io::di, io::uo) is det.
-write_parameter_initializer(lang_managed_cplusplus, _Type, !IO) :-
- unexpected(this_file, "initializer for MC++").
-write_parameter_initializer(lang_csharp, Type, !IO) :-
+write_parameter_initializer(Type, !IO) :-
get_il_data_rep(DataRep, !IO),
ILType = mlds_type_to_ilds_type(DataRep, Type),
ILType = il_type(_, ILSimpleType),
write_csharp_initializer(ILSimpleType, !IO).
-:- pred write_il_ret_type_as_foreign_type(foreign_language::in(managed_lang),
- ret_type::in, io::di, io::uo) is det.
+:- pred write_il_ret_type_as_foreign_type(ret_type::in, io::di, io::uo) is det.
-write_il_ret_type_as_foreign_type(_Lang, void, !IO) :-
+write_il_ret_type_as_foreign_type(void, !IO) :-
io.write_string("void", !IO).
-write_il_ret_type_as_foreign_type(Lang, simple_type(T), !IO) :-
- write_il_simple_type_as_foreign_type(Lang, T, !IO).
+write_il_ret_type_as_foreign_type(simple_type(T), !IO) :-
+ write_il_simple_type_as_foreign_type(T, !IO).
-:- pred write_il_type_as_foreign_type(foreign_language::in(managed_lang),
- il_type::in, io::di, io::uo) is det.
+:- pred write_il_type_as_foreign_type(il_type::in, io::di, io::uo) is det.
-write_il_type_as_foreign_type(Lang, il_type(Modifiers, SimpleType), !IO) :-
+write_il_type_as_foreign_type(il_type(Modifiers, SimpleType), !IO) :-
io.write_list(Modifiers, " ",
- write_il_type_modifier_as_foreign_type(Lang), !IO),
- write_il_simple_type_as_foreign_type(Lang, SimpleType, !IO).
+ write_il_type_modifier_as_foreign_type, !IO),
+ write_il_simple_type_as_foreign_type(SimpleType, !IO).
-:- pred write_il_type_modifier_as_foreign_type(
- foreign_language::in(managed_lang), ilds.type_modifier::in,
+:- pred write_il_type_modifier_as_foreign_type(ilds.type_modifier::in,
io::di, io::uo) is det.
-write_il_type_modifier_as_foreign_type(_Lang, const, !IO) :-
+write_il_type_modifier_as_foreign_type(const, !IO) :-
io.write_string("const", !IO).
-write_il_type_modifier_as_foreign_type(_Lang, readonly, !IO) :-
+write_il_type_modifier_as_foreign_type(readonly, !IO) :-
io.write_string("readonly", !IO).
-write_il_type_modifier_as_foreign_type(_Lang, volatile, !IO) :-
+write_il_type_modifier_as_foreign_type(volatile, !IO) :-
io.write_string("volatile", !IO).
% XXX Need to revisit this and choose types appropriately.
%
-:- pred write_il_simple_type_as_foreign_type(
- foreign_language::in(managed_lang),
- simple_type::in, io::di, io::uo) is det.
-
-write_il_simple_type_as_foreign_type(lang_csharp, Type, !IO) :-
- write_il_simple_type_as_foreign_type_cs(Type, !IO).
-write_il_simple_type_as_foreign_type(lang_managed_cplusplus, Type, !IO) :-
- write_il_simple_type_as_foreign_type_mcpp(Type, !IO).
-
-:- pred write_il_simple_type_as_foreign_type_cs(
- simple_type::in, io::di, io::uo) is det.
+:- pred write_il_simple_type_as_foreign_type(simple_type::in,
+ io::di, io::uo) is det.
-write_il_simple_type_as_foreign_type_cs(int8, !IO) :-
+write_il_simple_type_as_foreign_type(int8, !IO) :-
io.write_string("sbyte", !IO).
-write_il_simple_type_as_foreign_type_cs(int16, !IO) :-
+write_il_simple_type_as_foreign_type(int16, !IO) :-
io.write_string("short", !IO).
-write_il_simple_type_as_foreign_type_cs(int32, !IO) :-
+write_il_simple_type_as_foreign_type(int32, !IO) :-
io.write_string("int", !IO).
-write_il_simple_type_as_foreign_type_cs(int64, !IO) :-
+write_il_simple_type_as_foreign_type(int64, !IO) :-
io.write_string("long", !IO).
-write_il_simple_type_as_foreign_type_cs(uint8, !IO) :-
+write_il_simple_type_as_foreign_type(uint8, !IO) :-
io.write_string("byte", !IO).
-write_il_simple_type_as_foreign_type_cs(uint16, !IO) :-
+write_il_simple_type_as_foreign_type(uint16, !IO) :-
io.write_string("ushort", !IO).
-write_il_simple_type_as_foreign_type_cs(uint32, !IO) :-
+write_il_simple_type_as_foreign_type(uint32, !IO) :-
io.write_string("uint", !IO).
-write_il_simple_type_as_foreign_type_cs(uint64, !IO) :-
+write_il_simple_type_as_foreign_type(uint64, !IO) :-
io.write_string("ulong", !IO).
-write_il_simple_type_as_foreign_type_cs(native_int, !IO) :-
+write_il_simple_type_as_foreign_type(native_int, !IO) :-
io.write_string("int", !IO).
-write_il_simple_type_as_foreign_type_cs(native_uint, !IO) :-
+write_il_simple_type_as_foreign_type(native_uint, !IO) :-
io.write_string("uint", !IO).
-write_il_simple_type_as_foreign_type_cs(float32, !IO) :-
+write_il_simple_type_as_foreign_type(float32, !IO) :-
io.write_string("float", !IO).
-write_il_simple_type_as_foreign_type_cs(float64, !IO) :-
+write_il_simple_type_as_foreign_type(float64, !IO) :-
io.write_string("double", !IO).
-write_il_simple_type_as_foreign_type_cs(native_float, !IO) :-
+write_il_simple_type_as_foreign_type(native_float, !IO) :-
io.write_string("float", !IO).
-write_il_simple_type_as_foreign_type_cs(bool, !IO) :-
+write_il_simple_type_as_foreign_type(bool, !IO) :-
io.write_string("bool", !IO).
-write_il_simple_type_as_foreign_type_cs(char, !IO) :-
+write_il_simple_type_as_foreign_type(char, !IO) :-
io.write_string("char", !IO).
-write_il_simple_type_as_foreign_type_cs(string, !IO) :-
+write_il_simple_type_as_foreign_type(string, !IO) :-
io.write_string("string", !IO).
-write_il_simple_type_as_foreign_type_cs(object, !IO) :-
+write_il_simple_type_as_foreign_type(object, !IO) :-
io.write_string("object", !IO).
-write_il_simple_type_as_foreign_type_cs(refany, !IO) :-
+write_il_simple_type_as_foreign_type(refany, !IO) :-
io.write_string("mercury.MR_RefAny", !IO).
-write_il_simple_type_as_foreign_type_cs(class(ClassName), !IO) :-
- write_class_name(lang_csharp, ClassName, !IO).
-write_il_simple_type_as_foreign_type_cs(valuetype(ClassName), !IO) :-
- write_class_name(lang_csharp, ClassName, !IO).
-write_il_simple_type_as_foreign_type_cs(interface(_ClassName), !IO) :-
+write_il_simple_type_as_foreign_type(class(ClassName), !IO) :-
+ write_class_name(ClassName, !IO).
+write_il_simple_type_as_foreign_type(valuetype(ClassName), !IO) :-
+ write_class_name(ClassName, !IO).
+write_il_simple_type_as_foreign_type(interface(_ClassName), !IO) :-
sorry(this_file, "interfaces").
-write_il_simple_type_as_foreign_type_cs('[]'(Type, Bounds), !IO) :-
- write_il_type_as_foreign_type(lang_csharp, Type, !IO),
+write_il_simple_type_as_foreign_type('[]'(Type, Bounds), !IO) :-
+ write_il_type_as_foreign_type(Type, !IO),
io.write_string("[]", !IO),
(
Bounds = []
@@ -830,78 +648,12 @@
Bounds = [_ | _],
sorry(this_file, "arrays with bounds")
).
-write_il_simple_type_as_foreign_type_cs('&'(Type), !IO) :-
+write_il_simple_type_as_foreign_type('&'(Type), !IO) :-
% XXX Is this always right?
io.write_string("ref ", !IO),
- write_il_type_as_foreign_type(lang_csharp, Type, !IO).
-write_il_simple_type_as_foreign_type_cs('*'(Type), !IO) :-
- write_il_type_as_foreign_type(lang_csharp, Type, !IO),
- io.write_string(" *", !IO).
-
-:- pred write_il_simple_type_as_foreign_type_mcpp(
- simple_type::in, io::di, io::uo) is det.
-
-write_il_simple_type_as_foreign_type_mcpp(int8, !IO) :-
- io.write_string("mercury::MR_Integer8", !IO).
-write_il_simple_type_as_foreign_type_mcpp(int16, !IO) :-
- io.write_string("mercury::MR_Integer16", !IO).
-write_il_simple_type_as_foreign_type_mcpp(int32, !IO) :-
- io.write_string("mercury::MR_Integer", !IO).
-write_il_simple_type_as_foreign_type_mcpp(int64, !IO) :-
- io.write_string("mercury::MR_Integer64", !IO).
-write_il_simple_type_as_foreign_type_mcpp(uint8, !IO) :-
- io.write_string("unsigned int", !IO).
-write_il_simple_type_as_foreign_type_mcpp(uint16, !IO) :-
- io.write_string("unsigned int", !IO).
-write_il_simple_type_as_foreign_type_mcpp(uint32, !IO) :-
- io.write_string("unsigned int", !IO).
-write_il_simple_type_as_foreign_type_mcpp(uint64, !IO) :-
- io.write_string("unsigned int", !IO).
-write_il_simple_type_as_foreign_type_mcpp(native_int, !IO) :-
- io.write_string("mercury::MR_Integer", !IO).
-write_il_simple_type_as_foreign_type_mcpp(native_uint, !IO) :-
- io.write_string("unsigned int", !IO).
-write_il_simple_type_as_foreign_type_mcpp(float32, !IO) :-
- io.write_string("float", !IO).
-write_il_simple_type_as_foreign_type_mcpp(float64, !IO) :-
- io.write_string("mercury::MR_Float", !IO).
-write_il_simple_type_as_foreign_type_mcpp(native_float, !IO) :-
- io.write_string("mercury::MR_Float", !IO).
-write_il_simple_type_as_foreign_type_mcpp(bool, !IO) :-
- io.write_string("mercury::MR_Bool", !IO).
-write_il_simple_type_as_foreign_type_mcpp(char, !IO) :-
- io.write_string("mercury::MR_Char", !IO).
-write_il_simple_type_as_foreign_type_mcpp(string, !IO) :-
- io.write_string("mercury::MR_String", !IO).
-write_il_simple_type_as_foreign_type_mcpp(object, !IO) :-
- io.write_string("mercury::MR_Box", !IO).
-write_il_simple_type_as_foreign_type_mcpp(refany, !IO) :-
- io.write_string("mercury::MR_RefAny", !IO).
-write_il_simple_type_as_foreign_type_mcpp(class(ClassName), !IO) :-
- ( ClassName = il_generic_class_name ->
- io.write_string("mercury::MR_Box", !IO)
- ;
- io.write_string("public class ", !IO),
- write_class_name(lang_managed_cplusplus, ClassName, !IO),
- io.write_string(" *", !IO)
- ).
-write_il_simple_type_as_foreign_type_mcpp(valuetype(ClassName), !IO) :-
- io.write_string("__value class ", !IO),
- write_class_name(lang_managed_cplusplus, ClassName, !IO).
- % XXX this is not the right syntax
-write_il_simple_type_as_foreign_type_mcpp(interface(ClassName), !IO) :-
- io.write_string("interface ", !IO),
- write_class_name(lang_managed_cplusplus, ClassName, !IO),
- io.write_string(" *", !IO).
- % XXX this needs more work
-write_il_simple_type_as_foreign_type_mcpp('[]'(_Type, _Bounds), !IO) :-
- io.write_string("mercury::MR_Word", !IO).
-write_il_simple_type_as_foreign_type_mcpp('&'(Type), !IO) :-
- io.write_string("MR_Ref(", !IO),
- write_il_type_as_foreign_type(lang_managed_cplusplus, Type, !IO),
- io.write_string(")", !IO).
-write_il_simple_type_as_foreign_type_mcpp('*'(Type), !IO) :-
- write_il_type_as_foreign_type(lang_managed_cplusplus, Type, !IO),
+ write_il_type_as_foreign_type(Type, !IO).
+write_il_simple_type_as_foreign_type('*'(Type), !IO) :-
+ write_il_type_as_foreign_type(Type, !IO),
io.write_string(" *", !IO).
:- pred write_csharp_initializer(simple_type::in, io::di, io::uo) is det.
@@ -954,22 +706,13 @@
io.write_string("null", !IO).
write_csharp_initializer(valuetype(ClassName), !IO) :-
io.write_string("new ", !IO),
- write_class_name(lang_csharp, ClassName, !IO),
+ write_class_name(ClassName, !IO),
io.write_string("()", !IO).
-:- pred write_class_name(foreign_language::in(managed_lang),
- structured_name::in, io::di, io::uo) is det.
+:- pred write_class_name(structured_name::in, io::di, io::uo) is det.
-write_class_name(Lang, structured_name(_Asm, DottedName, NestedClasses),
- !IO) :-
- (
- Lang = lang_csharp,
- Sep = "."
- ;
- Lang = lang_managed_cplusplus,
- Sep = "::"
- ),
- io.write_list(DottedName ++ NestedClasses, Sep, io.write_string, !IO).
+write_class_name(structured_name(_Asm, DottedName, NestedClasses), !IO) :-
+ io.write_list(DottedName ++ NestedClasses, ".", io.write_string, !IO).
:- pred write_mlds_var_name_for_local(mlds_var_name::in,
io::di, io::uo) is det.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.433
diff -u -u -r1.433 modules.m
--- compiler/modules.m 15 Jun 2007 10:35:50 -0000 1.433
+++ compiler/modules.m 7 Jul 2007 01:39:52 -0000
@@ -3817,7 +3817,6 @@
io.nl(DepStream, !IO)
;
( ForeignLang = lang_c
- ; ForeignLang = lang_managed_cplusplus
; ForeignLang = lang_java
; ForeignLang = lang_il
; ForeignLang = lang_erlang
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.570
diff -u -u -r1.570 options.m
--- compiler/options.m 29 Jun 2007 10:03:13 -0000 1.570
+++ compiler/options.m 7 Jul 2007 01:40:11 -0000
@@ -688,11 +688,6 @@
; support_ms_clr
; support_rotor_clr
- % Managed C++
- ; mcpp_compiler
- ; mcpp_flags
- ; quoted_mcpp_flag
-
% C#
; csharp_compiler
; csharp_flags
@@ -1451,11 +1446,6 @@
support_ms_clr - bool(yes),
support_rotor_clr - bool(no),
- % Managed C++
- mcpp_compiler - string("cl"),
- mcpp_flags - accumulating([]),
- quoted_mcpp_flag - string_special,
-
% C#
csharp_compiler - string("csc"),
csharp_flags - accumulating([]),
@@ -2267,10 +2257,6 @@
long_option("support-ms-clr", support_ms_clr).
long_option("support-rotor-clr", support_rotor_clr).
-long_option("mcpp-compiler", mcpp_compiler).
-long_option("mcpp-flags", mcpp_flags).
-long_option("mcpp-flag", quoted_mcpp_flag).
-
long_option("csharp-compiler", csharp_compiler).
long_option("csharp-flags", csharp_flags).
long_option("csharp-flag", quoted_csharp_flag).
@@ -2577,9 +2563,6 @@
special_handler(quoted_ilasm_flag, string(Flag),
OptionTable0, ok(OptionTable)) :-
handle_quoted_flag(ilasm_flags, Flag, OptionTable0, OptionTable).
-special_handler(quoted_mcpp_flag, string(Flag),
- OptionTable0, ok(OptionTable)) :-
- handle_quoted_flag(mcpp_flags, Flag, OptionTable0, OptionTable).
special_handler(quoted_csharp_flag, string(Flag),
OptionTable0, ok(OptionTable)) :-
handle_quoted_flag(csharp_flags, Flag, OptionTable0, OptionTable).
@@ -4626,12 +4609,6 @@
"\tSpecify options to be passed to the IL assembler.",
"\t`--ilasm-flag' should be used for single words which need",
"\tto be quoted when passed to the shell.",
- "--mcpp-compiler <cl>",
- "\tSpecify the name of the Microsoft Managed C++ Compiler.",
- "--mcpp-flags <options>, --mcpp-flag <option>",
- "\tSpecify options to be passed to the Managed C++ compiler.",
- "\t`--mcpp-flag' should be used for single words which need",
- "\tto be quoted when passed to the shell.",
"--csharp-compiler <csc>",
"\tSpecify the name of the C# Compiler. The default is `csc'.",
Index: compiler/options_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options_file.m,v
retrieving revision 1.44
diff -u -u -r1.44 options_file.m
--- compiler/options_file.m 15 Jan 2007 07:47:55 -0000 1.44
+++ compiler/options_file.m 7 Jul 2007 01:40:14 -0000
@@ -874,7 +874,6 @@
; java_flags
; ilasm_flags
; csharp_flags
- ; mcpp_flags
; ml_objs
; ml_libs
; ld_flags
@@ -901,7 +900,7 @@
options_variable_types =
[grade_flags, linkage, mercury_linkage, lib_grades, lib_linkages,
stdlib_dir, config_dir, mmc_flags, c_flags, java_flags, ilasm_flags,
- csharp_flags, mcpp_flags, ml_objs, lib_dirs, ld_flags, ld_libflags,
+ csharp_flags, ml_objs, lib_dirs, ld_flags, ld_libflags,
libraries, ml_libs, c2init_args, install_prefix].
:- func options_variable_name(options_variable_type) = string.
@@ -911,7 +910,6 @@
options_variable_name(c_flags) = "CFLAGS".
options_variable_name(java_flags) = "JAVACFLAGS".
options_variable_name(ilasm_flags) = "MS_ILASM_FLAGS".
-options_variable_name(mcpp_flags) = "MS_CL_FLAGS".
options_variable_name(csharp_flags) = "MS_CSC_FLAGS".
options_variable_name(ml_objs) = "MLOBJS".
options_variable_name(ml_libs) = "MLLIBS".
@@ -935,7 +933,6 @@
options_variable_type_is_target_specific(c_flags) = yes.
options_variable_type_is_target_specific(java_flags) = yes.
options_variable_type_is_target_specific(ilasm_flags) = yes.
-options_variable_type_is_target_specific(mcpp_flags) = yes.
options_variable_type_is_target_specific(csharp_flags) = yes.
options_variable_type_is_target_specific(ml_objs) = yes.
options_variable_type_is_target_specific(ml_libs) = yes.
@@ -994,7 +991,6 @@
mmc_option_type(c_flags) = option([], "--cflag").
mmc_option_type(java_flags) = option([], "--java-flag").
mmc_option_type(ilasm_flags) = option([], "--ilasm-flag").
-mmc_option_type(mcpp_flags) = option([], "--mcpp-flag").
mmc_option_type(csharp_flags) = option([], "--csharp-flag").
mmc_option_type(ml_objs) = option([], "--link-object").
mmc_option_type(ml_libs) = mmc_flags.
Index: compiler/prog_foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_foreign.m,v
retrieving revision 1.13
diff -u -u -r1.13 prog_foreign.m
--- compiler/prog_foreign.m 7 May 2007 05:21:35 -0000 1.13
+++ compiler/prog_foreign.m 7 Jul 2007 01:40:38 -0000
@@ -101,9 +101,9 @@
% returns the module name which represents the ForeignImport.
%
% For instance for the foreign_import_module representing
- % :- foreign_import_module("MC++", module)
+ % :- foreign_import_module("C#", module)
% would return the module_name
- % unqualified("module__cpp_code")
+ % unqualified("module__csharp_code")
%
:- func foreign_import_module_name(foreign_import_module_info) = module_name.
@@ -120,7 +120,6 @@
%
:- inst lang_gen_ext_file
---> lang_c
- ; lang_managed_cplusplus
; lang_csharp.
% The module name used for this foreign language.
@@ -212,9 +211,6 @@
Lang = lang_erlang,
ModuleName = ForeignImportModule
;
- Lang = lang_managed_cplusplus,
- ModuleName = foreign_language_module_name(ForeignImportModule, Lang)
- ;
Lang = lang_csharp,
ModuleName = foreign_language_module_name(ForeignImportModule, Lang)
).
@@ -232,10 +228,6 @@
ImportedForeignCodeModuleName = handle_std_library(CurrentModule,
ImportedForeignCodeModuleName1)
;
- Lang = lang_managed_cplusplus,
- ImportedForeignCodeModuleName = handle_std_library(CurrentModule,
- ImportedForeignCodeModuleName1)
- ;
Lang = lang_csharp,
ImportedForeignCodeModuleName = handle_std_library(CurrentModule,
ImportedForeignCodeModuleName1)
@@ -283,7 +275,6 @@
%-----------------------------------------------------------------------------%
foreign_language_file_extension(lang_c) = ".c".
-foreign_language_file_extension(lang_managed_cplusplus) = ".cpp".
foreign_language_file_extension(lang_csharp) = ".cs".
foreign_language_file_extension(lang_java) = ".java".
foreign_language_file_extension(lang_il) = _ :-
@@ -312,9 +303,9 @@
).
prefer_foreign_language(_Globals, target_il, Lang1, Lang2) = Comp :-
- % Whe compiling to il, first we prefer il, then csharp, then
- % managed_cplusplus, after that we don't care.
- PreferredList = [lang_il, lang_csharp, lang_managed_cplusplus],
+ % When compiling to il, first we prefer il, then csharp.
+ % After that we don't care.
+ PreferredList = [lang_il, lang_csharp],
FindLangPriority = (func(L) = X :-
( list.nth_member_search(PreferredList, L, X0) ->
@@ -352,7 +343,6 @@
foreign_language(lang_c).
foreign_language(lang_java).
foreign_language(lang_csharp).
-foreign_language(lang_managed_cplusplus).
foreign_language(lang_il).
foreign_language(lang_erlang).
Index: compiler/prog_io_pragma.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.124
diff -u -u -r1.124 prog_io_pragma.m
--- compiler/prog_io_pragma.m 7 May 2007 05:21:35 -0000 1.124
+++ compiler/prog_io_pragma.m 7 Jul 2007 01:40:59 -0000
@@ -948,9 +948,7 @@
Result = error1(["invalid backend specification term" - InputTerm])
)
;
- ( Language = lang_managed_cplusplus
- ; Language = lang_csharp
- ),
+ Language = lang_csharp,
Msg = "unsupported language specified, unable to parse backend type",
Result = error1([Msg - InputTerm])
).
@@ -1640,7 +1638,6 @@
= maybe1(pragma_foreign_proc_attributes).
check_required_attributes(lang_c, Attrs, _Term) = ok1(Attrs).
-check_required_attributes(lang_managed_cplusplus, Attrs, _Term) = ok1(Attrs).
check_required_attributes(lang_csharp, Attrs, _Term) = ok1(Attrs).
check_required_attributes(lang_il, Attrs, Term) = Res :-
MaxStackAttrs = list.filter_map(
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.397
diff -u -u -r1.397 reference_manual.texi
--- doc/reference_manual.texi 12 Jun 2007 06:53:57 -0000 1.397
+++ doc/reference_manual.texi 7 Jul 2007 01:44:14 -0000
@@ -6645,11 +6645,6 @@
and in C modifications to mutable state are done via side effects,
rather than argument passing.)
- at c For the Managed C++ interface, the types are mapped slightly differently:
- at c Mercury variables which are polymorphically typed
- at c have type @samp{MR_Box} rather than @samp{MR_Word}.
- at c XXX We should document the Managed C++ interface somewhere.
-
Mercury lists can be manipulated by C code using the following macros,
which are defined by the Mercury implementation.
@@ -6946,7 +6941,7 @@
@samp{pragma foreign_import_module} declaration.
A cycle of @samp{pragma foreign_import_module}, where the language is
- at samp{"MC++"}, @samp{"C#"}, or @samp{"Java"}, is not permitted.
+ at samp{"C#"} or @samp{"Java"}, is not permitted.
@node Adding foreign definitions
@section Adding foreign definitions
@@ -6981,8 +6976,6 @@
* Interfacing with C# :: How to write code to interface with C#
* Interfacing with IL :: How to write code to interface with IL
* Interfacing with Java :: How to write code to interface with Java
-* Interfacing with Managed C++ :: How to write code to interface with
- Managed C++
@end menu
All Mercury implementations should support interfacing with C.
@@ -7011,11 +7004,6 @@
@item @samp{Java}
Use the string @code{"Java"} to set the foreign language to Java.
- at item @samp{Managed C++}
-Use the string @code{"MC++"} to set the foreign language to Managed C++.
-Managed C++ is C++ with Microsoft's extensions to support interfacing
-with and generating code for the .NET Common Language Runtime.
-
@end table
@c -----------------------------------------------------------------------
@@ -7412,7 +7400,7 @@
parameters whose Mercury type is @var{MercuryTypeName}.
The IL assembler syntax is used to specify type names for all the .NET CLR
-languages (IL, C# and Managed C++) supported by Mercury's
+languages (IL and C#) supported by Mercury's
@samp{foreign_proc} mechanism.
This syntax is documented in the ECMA specifications for .NET.
The .NET CLR backend supports reference and value types
@@ -7716,118 +7704,6 @@
@c ----------------------------------------------------------------------------
- at node Interfacing with Managed C++
- at subsection Interfacing with Managed C++
-
- at menu
-* Using pragma foreign_type for MC++:: Declaring MC++ types in Mercury
-* Using pragma foreign_proc for MC++:: Calling MC++ code from Mercury
-* Using pragma foreign_export for MC++:: Calling Mercury from MC++ code
-* Using pragma foreign_decl for MC++:: Including MC++ declarations in Mercury
-* Using pragma foreign_code for MC++:: Including MC++ code in Mercury
- at end menu
-
- at node Using pragma foreign_type for MC++
- at subsubsection Using pragma foreign_type for MC++
-
-There is no direct support for using MC++ types from Mercury; however, the
-types for IL are compatible with MC++, and so the foreign_type
-support for IL can be used instead.
-See the section on using pragma foreign_type for IL
-(@pxref{Using pragma foreign_type for IL}).
-
- at node Using pragma foreign_proc for MC++
- at subsubsection Using pragma foreign_proc for MC++
-
-The MC++ code from MC++ pragma foreign_proc declarations will be copied into
-static member functions of an automatically-generated MC++ class.
-Since such MC++ code will become part of a static member function,
-it must not refer to the @samp{this} keyword.
-It may however refer to static member variables or static member
-functions declared with @samp{pragma foreign_code}.
-
-The input and output variables for an MC++ @samp{pragma foreign_proc} will
-have MC++ types corresponding to their Mercury types. The exact rules
-for mapping Mercury types to MC++ types are determined by the rules
-for mapping Mercury types to IL (@pxref{IL and C# data passing conventions})
-and the rules relating IL types to MC++ types.
-
-MC++ code in a @code{pragma foreign_proc} declaration
-for any procedure whose determinism indicates that it can fail
-must assign a value of type @samp{bool} to the variable
- at samp{SUCCESS_INDICATOR}. For example:
-
- at example
-:- pred string.contains_char(string, character).
-:- mode string.contains_char(in, in) is semidet.
-
-:- pragma foreign_proc("MC++", string.contains_char(Str::in, Ch::in),
- [will_not_call_mercury, promise_pure],
- "SUCCESS_INDICATOR = (Str->IndexOf(Ch) != -1);").
- at end example
-
- at noindent
-MC++ code for procedures whose determinism indicates that they cannot fail
-should not access @code{SUCCESS_INDICATOR}.
-
-Arguments whose mode is input will have their values set by the
-Mercury implementation on entry to the MC++ code. If the procedure
-succeeds, the MC++ code must set the values of all output arguments.
-If the procedure fails, the MC++ code need only
-set @code{SUCCESS_INDICATOR} to false.
-
- at node Using pragma foreign_export for MC++
- at subsubsection Using pragma foreign_export for MC++
-
- at samp{pragma foreign_export} is not currently supported for MC++.
-
- at node Using pragma foreign_decl for MC++
- at subsubsection Using pragma foreign_decl for MC++
-
- at samp{pragma foreign_decl} declarations for MC++ can be used to provide
-any top-level MC++ declarations (e.g.@: @samp{#include} or @samp{#using})
-which are needed by code in @code{pragma foreign_proc} declarations for MC++.
-
-For example:
-
- at example
-:- pragma foreign_decl("MC++", "
- #include <stdio.h>
- #using <mscorlib.dll>
-
- #define MY_CONSTANT 42
- // ...
-").
- at end example
-
- at node Using pragma foreign_code for MC++
- at subsubsection Using pragma foreign_code for MC++
-
-The MC++ code from @samp{pragma foreign_proc} declarations for MC++ will be
-placed in the bodies of static member functions of an
-automatically-generated C# class. @samp{pragma foreign_code}
-can be used to define additional members of this automatically-generated
-class, which can then be referenced by @samp{pragma foreign_proc}
-declarations for MC++ from that module.
-
-For example:
-
- at example
-:- pragma foreign_code("MC++", "
- static int counter = 0;
-").
-
-:- impure pred incr_counter is det.
-:- pragma foreign_proc("MC++", incr_counter,
- [will_not_call_mercury], "counter++;").
-
-:- semipure func get_counter = int.
-:- pragma foreign_proc("MC++", get_counter = (Result::out),
- [will_not_call_mercury, promise_semipure], "Result = counter;").
- at end example
-
- at c -----------------------------------------------------------------------
-
@node C interface
@chapter C interface
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.531
diff -u -u -r1.531 user_guide.texi
--- doc/user_guide.texi 29 Jun 2007 10:03:18 -0000 1.531
+++ doc/user_guide.texi 7 Jul 2007 01:44:43 -0000
@@ -678,19 +678,6 @@
@vindex EXTRA_JAVACFLAGS
Options to pass to the Java compiler (if you are using it).
- at item MS_CLFLAGS and EXTRA_MS_CLFLAGS
- at vindex MS_CLFLAGS
- at vindex EXTRA_MS_CLFLAGS
-Options to pass to the Microsoft command line C++ compiler (if you are
-using it).
-
- at item MS_CL_NOASM
- at vindex MS_CL_NOASM
-The option to control whether the Microsoft command line C++ compiler
-will generate .NET assemblies from Managed C++ files. Set to
- at samp{:noAssembly} to turn off assembly generation, leave empty to turn
-on assembly generation. The default is to leave this variable empty.
-
@item ML
@vindex ML
The executable that invokes the linker.
@@ -9706,13 +9693,6 @@
Only available on backends that compile to IL.
This is the preferred foreign language for IL code generation.
- at item @samp{Managed C++}
-Microsoft Managed Extensions for C++ is a language based on C++ that
-provide support for writing .NET components, by adding extra
-keywords and syntax.
-Only available on backends that compile to IL.
-This is the third preferred foreign language for IL code generation.
-
@end table
@c ----------------------------------------------------------------------------
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.148
diff -u -u -r1.148 Mmakefile
--- library/Mmakefile 8 Jan 2007 07:07:04 -0000 1.148
+++ library/Mmakefile 7 Jul 2007 01:44:47 -0000
@@ -305,13 +305,6 @@
# We have to hardcode the names of the runtime DLL files.
RUNTIME_DLLS=mercury_dotnet.dll mercury_il.dll
- # -AI sets the assembly search path (just like -I for assemblies)
-MS_CLFLAGS = -AI`$(FIX_PATH_FOR_CL) $(RUNTIME_DIR)`
-I`$(FIX_PATH_FOR_CL) $(RUNTIME_DIR)`
-# For some reason, using /clr:noAssembly results in a link error when
-# building io__cpp_code.dll, because it doesn't link in the native library
-# needed for putenv(). So we need to use /link /noassembly instead.
-# MS_CL_NOASM=:noAssembly
-MS_CL_LIBS=/link /noassembly
MS_CSCFLAGS=/t:module
# If you do generate a new strong name, you had better update
@@ -498,10 +491,9 @@
#
# EXTRA_MS_ILASMFLAGS=/debug
# EXTRA_MS_CSCFLAGS=/debug+ /debug:full
-# EXTRA_MS_CLFLAGS=/Zi
#
# XXX Unfortunately, however, this is a problem with AL, which prohibits
-# linking debuggable C# code with IL or MC++ code. The following
+# linking debuggable C# code with IL code. The following
# horrible hack avoids that problem. After modifying Mmake.params as
# described above, invoke `mmake install_debug_library'.
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.394
diff -u -u -r1.394 io.m
--- library/io.m 22 Jun 2007 04:42:21 -0000 1.394
+++ library/io.m 7 Jul 2007 01:45:43 -0000
@@ -9546,43 +9546,6 @@
Error::out, ErrorMessage::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
- /*
- ** XXX For some reason this MC++ code below doesn't work.
- ** We get the following error message:
- ** Unhandled Exception: System.TypeInitializationException: The type
- ** initializer for ""remove_file.mercury_code"" threw an exception.
- ** ---> System.IO.FileLoadException: The dll initialization routine
- ** failed for file 'io__cpp_code.dll'.
- ** so instead we use the .NET call and ignore Dir and Prefix.
- **
- ** int result;
- ** char __nogc *dir = static_cast<char*>(
- ** System::Runtime::InteropServices::Marshal::
- ** StringToHGlobalAnsi(Dir).ToPointer());;
- ** char __nogc *prefix = static_cast<char*>(
- ** System::Runtime::InteropServices::Marshal::
- ** StringToHGlobalAnsi(Prefix).ToPointer());;
- ** char tmpFileName[MAX_PATH];
- ** System::String *msg[] = {
- ** S""Unable to create temporary file in "",
- ** Dir,
- ** S"" with prefix "",
- ** Prefix
- ** };
- **
- ** result = GetTempFileName(dir, prefix, 0, tmpFileName);
- **
- ** if (result == 0) {
- ** Error = -1;
- ** FileName = S"""";
- ** ErrorMessage = System::String::Join(S"""", msg);
- ** } else {
- ** Error = 0;
- ** FileName = tmpFileName;
- ** ErrorMessage = S"""";
- ** }
- */
-
try {
FileName = System.IO.Path.GetTempFileName();
Error = 0;
Index: library/list.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.163
diff -u -u -r1.163 list.m
--- library/list.m 13 Feb 2007 00:16:57 -0000 1.163
+++ library/list.m 7 Jul 2007 01:45:55 -0000
@@ -2388,8 +2388,8 @@
%-----------------------------------------------------------------------------%
% These functions are exported so that they can be used instead of the
-% names [|]_2 and []_0. These two names can be difficult to use from other
-% managed languages on the il backend.
+% names [|]_2 and []_0. These two names can be difficult to use from
+% C# in the il backend.
:- func empty_list = list(T).
:- pragma foreign_export("C", empty_list = out, "ML_empty_list").
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.138
diff -u -u -r1.138 Mmakefile
--- runtime/Mmakefile 13 Feb 2007 01:58:55 -0000 1.138
+++ runtime/Mmakefile 7 Jul 2007 01:47:14 -0000
@@ -140,10 +140,6 @@
machdeps/sparc_regs.h \
machdeps/x86_64_regs.h
-# MCPP_HDRS are header files in Microsoft's Managed extensions for C++
-
-MCPP_HDRS = mercury_mcpp.h
-
# keep this list in alphabetical order, please
CFILES = \
mercury.c \
@@ -344,10 +340,7 @@
else
ifeq ($(findstring il,$(GRADE)),il)
-# Managed C++ files compiled in this directory should not be put in an
-# assembly of their own. We put the runtime and library dlls into a single
-# assembly called `mercury'
-MS_CL_NOASM=:noAssembly
+# We put the runtime and library dlls into a single assembly called `mercury'
MS_CSCFLAGS=/t:module
# We need to build the following DLLs for the .NET runtime
@@ -358,7 +351,7 @@
runtime: $(DOTNET_DLLS)
-mercury_dotnet.dll: mercury_il.dll $(MCPP_HDRS)
+mercury_dotnet.dll: mercury_il.dll
# Uncomment the following rule if you want to build Mercury in a form
# that will work with ROTOR.
@@ -472,8 +465,7 @@
ifeq ($(findstring il,$(GRADE)),il)
.PHONY: install_headers
-install_headers: $(MCPP_HDRS) install_dirs
- cp `vpath_find $(MCPP_HDRS)` $(INSTALL_INC_DIR)
+install_headers:
.PHONY: install_init
install_init:
Index: runtime/mercury_il.il
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_il.il,v
retrieving revision 1.23
diff -u -u -r1.23 mercury_il.il
--- runtime/mercury_il.il 15 Nov 2003 12:57:33 -0000 1.23
+++ runtime/mercury_il.il 7 Jul 2007 01:47:48 -0000
@@ -37,10 +37,8 @@
.namespace mercury.runtime {
-// Managed C++ can't call or create function pointers.
+// C# can't call or create function pointers.
// So we have to do it in IL.
-// MC++ used to handle this, and then it stopped working, so now it's just
-// not supported at all. I hope it will make a comeback.
.class public TempHack {
@@ -364,7 +362,7 @@
// ------------------------------------------------------------------------
// This class implements some specific instances of call/N, mostly used for
-// doing unify and compare. You can't call using a function pointer in MC++
+// doing unify and compare. You can't call using a function pointer in C#
// so we have to do it in IL.
.class public GenericCall {
Index: runtime/mercury_mcpp.h
===================================================================
RCS file: runtime/mercury_mcpp.h
diff -N runtime/mercury_mcpp.h
--- runtime/mercury_mcpp.h 13 Feb 2007 01:58:57 -0000 1.35
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,287 +0,0 @@
-//
-// Copyright (C) 2000-2007 The University of Melbourne.
-// This file may only be copied under the terms of the GNU Library General
-// Public License - see the file COPYING.LIB in the Mercury distribution.
-//
-
-// mercury_mcpp.h - This file defines the system runtime types and
-// macros that are used when generating code for the .NET backend.
-// It is written using Managed Extensions for C++ (usually called Managed C++
-// or MC++).
-
-// We need a definition of NULL
-#include <stddef.h>
-
-namespace mercury {
-
-typedef int MR_Integer;
-typedef unsigned int MR_Unsigned;
-typedef System::Int32 MR_BoxedInt;
-typedef System::Boolean MR_Bool;
-typedef System::Boolean MR_bool;
-
-typedef System::Char MR_Char; // `Char' is MS's name for unicode characters
-
-typedef double MR_Float;
- // XXX using a typedef doesn't seem to work properly when we want
- // to use methods -- MR_BoxedFloat::somemethod() doesn't seem to work.
- // This might be an issue with value classes and typedefs.
-#define MR_BoxedFloat System::Double
-
-typedef System::String *MR_String;
-typedef void (*MR_Cont) (void *);
-
-// Should these be MR_ qualified?
-#define TRUE 1
-#define FALSE 0
-#define MR_TRUE 1
-#define MR_FALSE 0
-
-typedef __gc public class System::Object * MR_Word[];
-typedef __gc public class System::Object * MR_Box;
-typedef __gc public class System::Array * MR_Array;
-
-#define MR_Ref(type) type __gc *
-typedef MR_Ref(MR_Box) MR_Box_Ref;
-typedef MR_Ref(MR_Word) MR_Word_Ref;
-
-/*
-#ifdef MR_HIGHLEVEL_DATA
- typedef __gc public class mercury::private_builtin::type_info_1* MR_TypeInfo;
- typedef __gc public class
mercury::rtti_implementation::type_info_0* MR_TypeInfo_0;
- typedef __gc public class mercury::builtin::comparison_result_0
*MR_ComparisonResult;
- typedef __gc public class mercury::univ::univ_0 *MR_Univ;
-#else
-*/
- typedef __gc public class System::Object * MR_TypeInfo[];
- typedef __gc public class System::Object * MR_TypeInfo_0[];
- typedef __gc public class System::Object * MR_ComparisonResult[];
- typedef __gc public class System::Object * MR_Univ[];
-// #endif
-
-typedef __gc public class System::Object * MR_TypeCtorInfo[];
-typedef __gc public class System::Object * MR_TypeInfoParams[];
-typedef __gc public class System::Object * MR_TypeClassInfo[];
-
-// XXX This code is duplicated in mercury_type_info.h.
-// We should factor out these definitions and use a shared version.
-
-#define MR_COMPARE_EQUAL 0
-#define MR_COMPARE_LESS 1
-#define MR_COMPARE_GREATER 2
-
-#define MR_STRINGIFY(x) MR_STRINGIFY_2(x)
-#define MR_STRINGIFY_2(x) #x
-
-#define MR_PASTE2(a,b) MR_PASTE2_2(a,b)
-#define MR_PASTE2_2(a,b) a##b
-#define MR_PASTE3(a,b,c) MR_PASTE3_2(a,b,c)
-#define MR_PASTE3_2(a,b,c) a##b##c
-#define MR_PASTE4(a,b,c,d) MR_PASTE4_2(a,b,c,d)
-#define MR_PASTE4_2(a,b,c,d) a##b##c##d
-#define MR_PASTE5(a,b,c,d,e) MR_PASTE5_2(a,b,c,d,e)
-#define MR_PASTE5_2(a,b,c,d,e) a##b##c##d##e
-#define MR_PASTE6(a,b,c,d,e,f) MR_PASTE6_2(a,b,c,d,e,f)
-#define MR_PASTE6_2(a,b,c,d,e,f) a##b##c##d##e##f
-#define MR_PASTE7(a,b,c,d,e,f,g) MR_PASTE7_2(a,b,c,d,e,f,g)
-#define MR_PASTE7_2(a,b,c,d,e,f,g) a##b##c##d##e##f##g
-
-// The code to generate RTTI structures is somewhat complicated.
-// For each RTTI symbol, we generate an initializer method,
-// and a field. The initializer method returns a value for the field.
-// Since it is a static field, the initializer will be run in the class
-// constructor.
-//
-// This code is intended to be more general than the macros in
-// mercury_typeinfo.h -- by conditionally defining the appropriate
-// #defines for MR_CLASS_INIT* and MR_STRUCT_INIT* you should be able to
-// re-use this code, however this has not been done yet.
-
-// In the .NET backend, we don't need to forward declare RTTI structures.
-#define MR_Declare_entry(a)
-#define MR_Declare_struct(a)
-
-// We have to jump through a few hoops to get function pointers -- we do
-// it in IL currently. We treat function pointers as integers and have
-// to box them.
-#define MR_BOX_INT(a) __box(a)
-#define MR_MAYBE_STATIC_CODE(a) \
- MR_BOX_INT(mercury::runtime::TempHack::get_ftn_ptr_##a())
-#define MR_ENTRY(a) a
-// XXX MR_ENTRY appears to be unused
-
-// Code to handle initialization of fields.
-#define MR_STRUCT_INIT(a)
-#define MR_STRUCT_INIT_END(a)
-#define MR_CLASS_INIT(a) \
- static MR_Word a(void) { \
- System::Object *arr[] = {
-#define MR_CLASS_INIT_END(m, f, i) \
- }; \
- return arr; \
- } \
- static MR_Word f = i(); \
- static MR_Word MR_PASTE2(m, f) = i();
-
-#define MR_string_const(a, s) ((MR_String) a)
-#define MR_TYPECTOR_REP(a) MR_BOX_INT(mercury::runtime::Constants::a)
-
-// XXX This is hardcoded
-#define MR_RTTI_VERSION MR_BOX_INT(13)
-
-// XXX It is intended that we eventually define the constants in
-// private_builtin.m and mercury_mcpp.cpp in terms of these #defines
-// instead of hard-coding the values.
-#define MR_TYPECTOR_REP_ENUM_val 0
-#define MR_TYPECTOR_REP_ENUM_USEREQ_val 1
-#define MR_TYPECTOR_REP_DU_val 2
-#define MR_TYPECTOR_REP_DU_USEREQ_val 3
-#define MR_TYPECTOR_REP_NOTAG_val 4
-#define MR_TYPECTOR_REP_NOTAG_USEREQ_val 5
-#define MR_TYPECTOR_REP_EQUIV_val 6
-#define MR_TYPECTOR_REP_FUNC_val 7
-#define MR_TYPECTOR_REP_INT_val 8
-#define MR_TYPECTOR_REP_CHAR_val 9
-#define MR_TYPECTOR_REP_FLOAT_val 10
-#define MR_TYPECTOR_REP_STRING_val 11
-#define MR_TYPECTOR_REP_PRED_val 12
-#define MR_TYPECTOR_REP_SUBGOAL_val 13
-#define MR_TYPECTOR_REP_VOID_val 14
-#define MR_TYPECTOR_REP_C_POINTER_val 15
-#define MR_TYPECTOR_REP_TYPEINFO_val 16
-#define MR_TYPECTOR_REP_TYPECLASSINFO_val 17
-#define MR_TYPECTOR_REP_ARRAY_val 18
-#define MR_TYPECTOR_REP_SUCCIP_val 19
-#define MR_TYPECTOR_REP_HP_val 20
-#define MR_TYPECTOR_REP_CURFR_val 21
-#define MR_TYPECTOR_REP_MAXFR_val 22
-#define MR_TYPECTOR_REP_REDOFR_val 23
-#define MR_TYPECTOR_REP_REDOIP_val 24
-#define MR_TYPECTOR_REP_TRAIL_PTR_val 25
-#define MR_TYPECTOR_REP_TICKET_val 26
-#define MR_TYPECTOR_REP_NOTAG_GROUND_val 27
-#define MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ_val 28
-#define MR_TYPECTOR_REP_EQUIV_GROUND_val 29
-#define MR_TYPECTOR_REP_TUPLE_val 30
-#define MR_TYPECTOR_REP_RESERVED_ADDR_val 31
-#define MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ_val 32
-#define MR_TYPECTOR_REP_TYPECTORINFO_val 33
-#define MR_TYPECTOR_REP_BASETYPECLASSINFO_val 34
-#define MR_TYPECTOR_REP_TYPEDESC_val 35
-#define MR_TYPECTOR_REP_TYPECTORDESC_val 36
-#define MR_TYPECTOR_REP_FOREIGN_val 37
-#define MR_TYPECTOR_REP_REFERENCE_val 38
-#define MR_TYPECTOR_REP_STABLE_C_POINTER_val 39
-#define MR_TYPECTOR_REP_STABLE_FOREIGN_val 40
-#define MR_TYPECTOR_REP_PSEUDOTYPEDESC_val 41
-#define MR_TYPECTOR_REP_DUMMY_val 42
-#define MR_TYPECTOR_REP_BITMAP_val 43
-#define MR_TYPECTOR_REP_UNKNOWN_val 44
-
-// XXX we should integrate this macro in with the version in
-// mercury_typeinfo.h
-#define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(m, n, a, cr, u, c) \
- MR_Declare_entry(u) \
- MR_Declare_entry(c) \
- MR_Declare_struct(MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct) \
- MR_STRUCT_INIT(MR_PASTE5(mercury_data_, __type_ctor_info_, n, _,
a) = {) \
- MR_CLASS_INIT(MR_PASTE4(type_ctor_init_, n, _, a)) \
- MR_BOX_INT(a), \
- MR_RTTI_VERSION, \
- MR_BOX_INT(-1), \
- MR_TYPECTOR_REP(cr), \
- MR_MAYBE_STATIC_CODE(n##_unify), \
- MR_MAYBE_STATIC_CODE(n##_compare), \
- MR_string_const(MR_STRINGIFY(m), sizeof(MR_STRINGIFY(m))-1), \
- MR_string_const(MR_STRINGIFY(n), sizeof(MR_STRINGIFY(n))-1), \
- MR_BOX_INT(-1), \
- MR_BOX_INT(-1), \
- MR_BOX_INT(-1), \
- MR_BOX_INT(0) \
- MR_STRUCT_INIT_END(}) \
- MR_CLASS_INIT_END(m, MR_PASTE5(__, type_ctor_info_, n, _, a),
MR_PASTE4(type_ctor_init_, n, _, a))
-
-#define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(m, n, a, cr) \
- MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(m, n, a, cr, \
- MR_PASTE7(mercury::, m, ::do_unify__, n, _, a, _0), \
- MR_PASTE7(mercury::, m, ::do_compare__, n, _, a, _0))
-
-// Some definitions for writing code by hand that constructs lists.
-// Note that this is very dependent on the data representation chosen
-// by the compiler.
-
-#ifdef MR_HIGHLEVEL_DATA
- #define MR_list_nil(List) \
- List = mercury::list::mercury_code::ML_empty_list(NULL)
-
- #define MR_list_cons(List, Head, Tail) \
- List = mercury::list::mercury_code::ML_cons(NULL, Head, Tail)
-#else
- #define MR_list_cons(List, Head, Tail) \
- do { \
- MR_Word _tmp; \
- MR_newobj((_tmp), 1, 2); \
- MR_objset((_tmp), 1, (Head)); \
- MR_objset((_tmp), 2, (Tail)); \
- List = _tmp; \
- } while (0)
-
- #define MR_list_nil(List) \
- MR_newobj(List, 0, 0);
-#endif
-
-#define MR_list_is_cons(List) \
- (System::Convert::ToInt32((List)->GetValue(0)))
-
-#define MR_list_is_nil(List) \
- (System::Convert::ToInt32((List)->GetValue(0)) == 0)
-
-#define MR_list_head(List) \
- ((List)->GetValue(1))
-
-#define MR_list_tail(List) \
- (dynamic_cast<MR_Word>((List)->GetValue(2)))
-
-// Some definitions for writing code by hand that constructs any type.
-
-#define MR_newobj(Obj, Tag, Size) \
- do { \
- (Obj) = new System::Object __gc * __gc[(Size + 1)]; \
- (Obj)[0] = MR_BOX_INT(Tag); \
- } while (0)
-
-#define MR_untagged_newobj(Obj, Size) \
- do { \
- (Obj) = new System::Object __gc * __gc[(Size)]; \
- } while (0)
-
-#define MR_newobj_preboxed_tag(Obj, Tag, Size) \
- do { \
- (Obj) = new System::Object __gc * __gc[(Size + 1)]; \
- (Obj)[0] = (Tag); \
- } while (0)
-
-#define MR_objset(Obj, Offset, Element) \
- do { \
- (Obj)[(Offset)] = Element; \
- } while (0)
-
-#define MR_c_pointer_to_word(Obj, CPointer) \
- MR_newobj_preboxed_tag(Obj, CPointer, 0)
-
-#define MR_word_to_c_pointer(CPointer) \
- ( (CPointer)[0] )
-
-#define MR_newenum(Obj, Tag) \
- MR_newobj(Obj, Tag, 0)
-
-// A few macros to define some RTTI slots.
-// At the moment RTTI support in the .NET backend is very minimal.
-
-#define MR_TYPEINFO_TYPE_CTOR_INFO_SLOT 0
-
-#define MR_TYPE_CTOR_INFO_ARITY_SLOT 0
-#define MR_TYPE_CTOR_INFO_UNIFY_PRED_SLOT 5
-#define MR_TYPE_CTOR_INFO_COMPARE_PRED_SLOT 6
-
-} /* end namespace mercury */
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.125
diff -u -u -r1.125 mercury_type_info.h
--- runtime/mercury_type_info.h 13 Apr 2007 04:56:45 -0000 1.125
+++ runtime/mercury_type_info.h 7 Jul 2007 01:48:28 -0000
@@ -34,7 +34,6 @@
** library/private_builtin.m
** library/type_desc.m
** runtime/mercury_bootstrap.c
-** runtime/mercury_mcpp.h
** (for updating the hand-written RTTI
** structures)
**
@@ -46,8 +45,6 @@
** runtime/mercury_type_info.c
** library/type_desc.m
**
-** runtime/mercury_mcpp.h:
-** (for updating the MC++ backend RTTI structures)
** java/ *.java
** (for updating the Java backend RTTI structures)
*/
@@ -72,7 +69,7 @@
** structures used for RTTI.
**
** This number should be kept in sync with type_ctor_info_rtti_version in
-** compiler/type_ctor_info.m and with MR_RTTI_VERSION in mercury_mcpp.h.
+** compiler/type_ctor_info.m.
*/
#define MR_RTTI_VERSION MR_RTTI_VERSION__BITMAP
@@ -611,7 +608,7 @@
** constructor.
**
** Any changes in this definition will also require changes in
-** MR_CTOR_REP_NAMES below, in runtime/mercury_mcpp.h, in
+** MR_CTOR_REP_NAMES below, in
** library/rtti_implementation.m (definitely the list of type_ctor_reps,
** maybe the bodies of predicates), in library/private_builtin.m (in two
** places), in java/runtime/TypeCtorRep.java, in compiler/mlds_to_gcc.m,
Index: runtime/mercury_typeclass_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_typeclass_info.h,v
retrieving revision 1.5
diff -u -u -r1.5 mercury_typeclass_info.h
--- runtime/mercury_typeclass_info.h 21 Apr 2005 05:47:19 -0000 1.5
+++ runtime/mercury_typeclass_info.h 7 Jul 2007 01:48:29 -0000
@@ -191,7 +191,7 @@
** structures.
**
** This number should be kept in sync with type_class_info_rtti_version in
-** compiler/type_class_info.m and with MR_TYPECLASS_VERSION in mercury_mcpp.h.
+** compiler/type_class_info.m.
*/
#define MR_TYPECLASS_VERSION MR_TYPECLASS_VERSION_INITIAL
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.153
diff -u -u -r1.153 Mmake.rules
--- scripts/Mmake.rules 4 Dec 2006 01:33:29 -0000 1.153
+++ scripts/Mmake.rules 7 Jul 2007 01:48:53 -0000
@@ -277,16 +277,6 @@
# IL to generate a DLL if we are in a non-IL grade.
ifeq ($(findstring il,$(GRADE)),il)
-# Note that we use `-' rather than `/' as the option character for options
-# to $(MS_CL), to avoid confusion with Unix-style path names.
-# `cl' supports both variants.
-$(os_subdir)%.dll : %.cpp
- $(MS_CL) -CLR$(MS_CL_NOASM) $(ALL_MS_CLFLAGS) \
- -I`$(FIX_PATH_FOR_CL) $(MERC_C_INCL_DIR)` \
- -AI`$(FIX_PATH_FOR_CL) $(MERC_DLL_DIR)` $< \
- -LD -o $@ $(MS_CL_LIBS)
- rm -f $*.obj
-
$(os_subdir)%.dll : %.cs
$(MS_CSC) /t:library /lib:`$(FIX_PATH_FOR_CSC) $(MERC_DLL_DIR)` \
/out:$@ $(CSHARP_ASSEMBLY_REFS-$*) $(ALL_MS_CSCFLAGS) $<
@@ -378,7 +368,7 @@
# Rules for compiling IL files in the user's source directory.
# Note that we need both these rules and the ones above,
# since even if the compiler generates all of its files in subdirectories,
-# the user may have some il or cpp files of their own which need to be
+# the user may have some il or C# files of their own which need to be
# compiled.
#
# To avoid possible problems with invoking these commands unintentionally,
@@ -393,20 +383,10 @@
.il.exe:
$(MS_ILASM) $(ALL_MS_ILASMFLAGS) /quiet /OUT=$@ $<
-.cpp.dll:
- $(MS_CL) -CLR$(MS_CL_NOASM) $(ALL_MS_CLFLAGS) \
- -I`$(FIX_PATH_FOR_CL) $(MERC_C_INCL_DIR)` \
- -AI`$(FIX_PATH_FOR_CL) $(MERC_DLL_DIR)` $< \
- -LD -o $@ $(MS_CL_LIBS)
- rm -f $*.obj
-
.cs.dll:
$(MS_CSC) /t:library /lib:`$(FIX_PATH_FOR_CSC) $(MERC_DLL_DIR)` \
/out:$@ $(CSHARP_ASSEMBLY_REFS-$*) $(EXTRA_CSCFLAGS) $<
-.cpp.exe:
- $(MS_CL) -CLR$(MS_CL_NOASM) -I$(MERCURY_LIBRARY_PATH) $< -link
-entry:main $(MS_CL_LIBS) -out:$@
-
.cs.exe:
$(MS_CSC) /lib:`$(FIX_PATH_FOR_CSC) $(MERC_DLL_DIR)` /out:$@ \
$(CSHARP_ASSEMBLY_REFS-$*) $(EXTRA_CSCFLAGS) $<
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.106
diff -u -u -r1.106 Mmake.vars.in
--- scripts/Mmake.vars.in 30 Nov 2006 14:28:29 -0000 1.106
+++ scripts/Mmake.vars.in 7 Jul 2007 01:48:55 -0000
@@ -126,7 +126,6 @@
echo MCFLAGS += '$(MC_MAKE_FLAGS) $(EXTRA_MC_MAKE_FLAGS)'; \
echo CFLAGS += '$(ALL_CFLAGS)'; \
echo JAVACFLAGS += '$(ALL_JAVACFLAGS)'; \
- echo MS_CLFLAGS += '$(ALL_MS_CLFLAGS)'; \
echo MS_ILASMFLAGS += '$(ALL_MS_ILASMFLAGS)'; \
echo C2INITARGS += '$(ALL_C2INITARGS)'; \
echo MLLIBS += '$(ALL_MLLIBS)'; \
@@ -218,31 +217,8 @@
#
# Stuff for the .NET back-end
#
-
-# MS_CL is the command line version of Microsoft Visual C++, which we
-# use to compile Managed C++ code in the .NET backend.
-FIX_PATH_FOR_CL = @CYGPATH@
-MS_CL = @MS_CL@
-MS_VISUALCPP_DIR = @MS_VISUALCPP_DIR@
-ALL_MS_CLFLAGS = $(MS_CLFLAGS) $(EXTRA_MS_CLFLAGS) $(TARGET_MS_CLFLAGS) \
- $(LIB_MS_CLFLAGS)
-MS_CLFLAGS =
-EXTRA_MS_CLFLAGS =
-# The $(shell ...) here is to cause make to evaluate the command substitution
-# when the variable is expanded. This is necessary because the result
-# will be single-quoted when passed to the shell via ECHO_MERCURY_OPTIONS
-# to preserve possible double-quotes, so the command substitution won't
-# be run then.
-MS_VC_INCLUDE_DIR = $(shell $(FIX_PATH_FOR_CL) "$(MS_VISUALCPP_DIR)/include")
-MS_VC_INCLUDES = -I"$(MS_VC_INCLUDE_DIR)"
-LIB_MS_CLFLAGS = $(MS_VC_INCLUDES) $(patsubst %,-I %,$(EXTRA_C_INCL_DIRS))
-
-# MS_CL_NOASM can be used to turn off assembly generation. Use
-# MS_CL_NOASM=:noAssembly to turn it off, leave it blank to turn it on.
-MS_CL_NOASM =
MS_DOTNET_SDK_DIR=@MS_DOTNET_SDK_DIR@
# The system libraries were once needed here, but are currently unnecessary.
-MS_CL_LIBS =
# MERCURY_STDLIB_DIR should be set by the `mmake' script.
MERC_C_INCL_DIR = $(MERCURY_STDLIB_DIR)/inc
@@ -540,11 +516,6 @@
maybe-base-EXTRA_LIBGRADES- = $(EXTRA_LIBGRADES-$*)
maybe-base-EXTRA_LIBGRADES-undefined =
-TARGET_MS_CLFLAGS = \
- $(maybe-base-MS_CLFLAGS-$(findstring undefined,$(origin MS_CLFLAGS-$*)))
-maybe-base-MS_CLFLAGS- = $(MS_CLFLAGS-$*)
-maybe-base-MS_CLFLAGS-undefined =
-
TARGET_MS_CSCFLAGS = \
$(maybe-base-MS_CSCFLAGS-$(findstring undefined,$(origin MS_CSCFLAGS-$*)))
maybe-base-MS_CSCFLAGS- = $(MS_CSCFLAGS-$*)
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list