[m-rev.] for review: MC++ in browser/*.m

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jun 18 15:07:00 AEST 2001


The following changes are necessary, but not sufficient,
to compile the browser directory in IL grades, which we'll
need to do before we can bootstrap the compiler in IL grades.

They are not sufficient for two reasons:

	- I didn't change browser/dl.m yet
	  (since we don't want to use `foreign_proc' in the extras
	  directories yet, and dl.m gets copied into extras/dynamic_linking.)

	- the compiler crashes when compiling declarative_debugger.m in IL
	  grades, with the following error message:

	    Software Error: mlds_to_il.m: Unexpected: get_ilds_type_class_name:
	    type not a class

----------

Estimated hours taken: 1
Branches: main

browser/*.m:
	Change `pragma c_code(...)' to `pragma foreign_proc("C", ...)',
	and add `pragma foreign_proc("MC++", ...)' versions.
	These are needed for IL grades (i.e. the .NET back-end).

browser/.cvsignore:
	Add `*__c_code.cpp'.

browser/Mmakefile:
	Add `ils' target (for interactive use).

cvs server: Diffing .
Index: .cvsignore
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/.cvsignore,v
retrieving revision 1.15
diff -u -d -u -r1.15 .cvsignore
--- .cvsignore	2000/09/29 12:19:21	1.15
+++ .cvsignore	2001/06/18 04:57:23
@@ -22,4 +22,5 @@
 mdb.init
 *.ilk
 *.pdb
+*__c_code.cpp
 libmer_browser.lib
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.16
diff -u -d -u -r1.16 Mmakefile
--- Mmakefile	2001/05/18 14:23:49	1.16
+++ Mmakefile	2001/06/18 04:57:23
@@ -119,6 +119,7 @@
 os: $(mdb.os)
 cs: $(mdb.cs)
 ss: $(mdb.ss)
+ils: $(mdb.ils)
 
 #-----------------------------------------------------------------------------#
 
Index: collect_lib.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/collect_lib.m,v
retrieving revision 1.5
diff -u -d -u -r1.5 collect_lib.m
--- collect_lib.m	2000/10/16 01:33:22	1.5
+++ collect_lib.m	2001/06/18 04:57:23
@@ -118,9 +118,12 @@
 	).
 
 :- pred set_to_null_pointer(c_pointer::out) is det.
-:- pragma c_code(set_to_null_pointer(Pointer::out),
+:- pragma foreign_proc("C", set_to_null_pointer(Pointer::out),
 		[will_not_call_mercury, thread_safe],
-		"(Pointer = (MR_Word) NULL)").
+		"Pointer = (MR_Word) NULL").
+:- pragma foreign_proc("MC++", set_to_null_pointer(Pointer::out),
+		[will_not_call_mercury, thread_safe],
+		"Pointer = NULL").
  
 %------------------------------------------------------------------------------%
 
Index: declarative_execution.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_execution.m,v
retrieving revision 1.15
diff -u -d -u -r1.15 declarative_execution.m
--- declarative_execution.m	2001/01/16 15:44:17	1.15
+++ declarative_execution.m	2001/06/18 04:57:23
@@ -490,7 +490,7 @@
 		trace_node(trace_node_id)).
 :- mode search_trace_node_store(in, in, out) is semidet.
 
-:- pragma c_code(
+:- pragma foreign_proc("C",
 	search_trace_node_store(_Store::in, Id::in, Node::out),
 	[will_not_call_mercury, thread_safe],
 	"
@@ -498,6 +498,14 @@
 		SUCCESS_INDICATOR = (Id != (MR_Word) NULL);
 	"
 ).
+:- pragma foreign_proc("MC++",
+	search_trace_node_store(_Store::in, _Id::in, _Node::out),
+	[will_not_call_mercury, thread_safe],
+	"
+		mercury::runtime::Errors::SORRY(""search_trace_node_store"");
+	"
+).
+
 
 	%
 	% Following are some predicates that are useful for
@@ -859,13 +867,19 @@
 :- pred null_trace_node_id(trace_node_id).
 :- mode null_trace_node_id(out) is det.
 
-:- pragma c_code(
+:- pragma foreign_proc("C",
 	null_trace_node_id(Id::out),
 	[will_not_call_mercury, thread_safe],
 	"Id = (MR_Word) NULL;"
 ).
+:- pragma foreign_proc("MC++",
+	null_trace_node_id(Id::out),
+	[will_not_call_mercury, thread_safe],
+	"Id = NULL;"
+).
 
 
+
 :- func construct_trace_atom(pred_or_func, string, int) = trace_atom.
 :- pragma export(construct_trace_atom(in, in, in) = out,
 		"MR_DD_construct_trace_atom").
@@ -962,14 +976,21 @@
 :- pred node_id_to_key(trace_node_id, trace_node_key).
 :- mode node_id_to_key(in, out) is det.
 
-:- pragma c_code(node_id_to_key(Id::in, Key::out),
+:- pragma foreign_proc("C", node_id_to_key(Id::in, Key::out),
 		[will_not_call_mercury, thread_safe],
 		"Key = (MR_Integer) Id;").
+:- pragma foreign_proc("MC++", node_id_to_key(_Id::in, _Key::out),
+		[will_not_call_mercury, thread_safe],
+		"mercury::runtime::Errors::SORRY(""node_id_to_key"");"
+		).
 
 :- pred convert_node(trace_node(trace_node_id), trace_node(trace_node_key)).
 :- mode convert_node(in, out) is det.
 
-:- pragma c_code(convert_node(N1::in, N2::out),
+:- pragma foreign_proc("C", convert_node(N1::in, N2::out),
+		[will_not_call_mercury, thread_safe],
+		"N2 = N1;").
+:- pragma foreign_proc("MC++", convert_node(N1::in, N2::out),
 		[will_not_call_mercury, thread_safe],
 		"N2 = N1;").
 
Index: interactive_query.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/interactive_query.m,v
retrieving revision 1.10
diff -u -d -u -r1.10 interactive_query.m
--- interactive_query.m	2001/02/13 12:27:40	1.10
+++ interactive_query.m	2001/06/18 04:57:23
@@ -456,9 +456,12 @@
 	#include ""mercury_grade.h""
 	#include ""mercury_string.h""
 ").
-:- pragma c_code(grade_option = (GradeOpt::out),
+:- pragma foreign_proc("C", grade_option = (GradeOpt::out),
 	[thread_safe, will_not_call_mercury],
 	"MR_make_aligned_string(GradeOpt, (MR_String) MR_GRADE_OPT);").
+:- pragma foreign_proc("MC++", grade_option = (GradeOpt::out),
+	[thread_safe, will_not_call_mercury],
+	"GradeOpt = MR_GRADE_OPT;").
 
 :- func verbose = bool.
 verbose = no.
@@ -553,7 +556,9 @@
 :- func inst_cast(io_pred) = io_pred.
 :- mode inst_cast(in) = out(io_pred) is det.
 
-:- pragma c_code(inst_cast(X::in) = (Y::out(io_pred)),
+:- pragma foreign_proc("C", inst_cast(X::in) = (Y::out(io_pred)),
+	[will_not_call_mercury, thread_safe], "Y = X").
+:- pragma foreign_proc("MC++", inst_cast(X::in) = (Y::out(io_pred)),
 	[will_not_call_mercury, thread_safe], "Y = X").
 
 %-----------------------------------------------------------------------------%
Index: mdb.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/mdb.m,v
retrieving revision 1.5
diff -u -d -u -r1.5 mdb.m
--- mdb.m	2001/02/23 04:14:41	1.5
+++ mdb.m	2001/06/18 04:57:23
@@ -29,7 +29,7 @@
 
 % See library/library.m for why we implement this predicate this way.
 
-:- pragma c_code(mdb__version(Version::out),
+:- pragma foreign_proc("C", mdb__version(Version::out),
 		will_not_call_mercury, "
 	MR_ConstString version_string = 
 		MR_VERSION "", configured for "" MR_FULLARCH;
@@ -38,6 +38,11 @@
 	** with type MR_String rather than MR_ConstString.
 	*/
 	Version = (MR_String) (MR_Word) version_string;
+").
+
+:- pragma foreign_proc("MC++", mdb__version(Version::out),
+		will_not_call_mercury, "
+	Version MR_VERSION "", configured for "" MR_FULLARCH;
 ").
 
 %---------------------------------------------------------------------------%
Index: name_mangle.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/name_mangle.m,v
retrieving revision 1.4
diff -u -d -u -r1.4 name_mangle.m
--- name_mangle.m	2001/01/11 05:59:31	1.4
+++ name_mangle.m	2001/06/18 04:57:23
@@ -248,7 +248,16 @@
 	).
 
 :- pred use_asm_labels is semidet.
-:- pragma c_code(use_asm_labels, [will_not_call_mercury, thread_safe], "
+:- pragma foreign_proc("C", use_asm_labels,
+	[will_not_call_mercury, thread_safe], "
+#ifdef USE_ASM_LABELS
+	SUCCESS_INDICATOR = TRUE;
+#else
+	SUCCESS_INDICATOR = FALSE;
+#endif
+").
+:- pragma foreign_proc("MC++", use_asm_labels,
+	[will_not_call_mercury, thread_safe], "
 #ifdef USE_ASM_LABELS
 	SUCCESS_INDICATOR = TRUE;
 #else
@@ -257,7 +266,16 @@
 ").
 
 :- pred high_level_code is semidet.
-:- pragma c_code(high_level_code, [will_not_call_mercury, thread_safe], "
+:- pragma foreign_proc("C", high_level_code,
+	[will_not_call_mercury, thread_safe], "
+#ifdef MR_HIGHLEVEL_CODE
+	SUCCESS_INDICATOR = TRUE;
+#else
+	SUCCESS_INDICATOR = FALSE;
+#endif
+").
+:- pragma foreign_proc("MC++", high_level_code,
+	[will_not_call_mercury, thread_safe], "
 #ifdef MR_HIGHLEVEL_CODE
 	SUCCESS_INDICATOR = TRUE;
 #else
Index: util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/util.m,v
retrieving revision 1.12
diff -u -d -u -r1.12 util.m
--- util.m	2001/01/29 06:47:12	1.12
+++ util.m	2001/06/18 04:57:23
@@ -104,8 +104,8 @@
 	#include ""mercury_library_types.h""
 ").
 
-:- pragma c_code(call_trace_getline(MdbIn::in, MdbOut::in, Prompt::in,
-			Line::out),
+:- pragma foreign_proc("C",
+	call_trace_getline(MdbIn::in, MdbOut::in, Prompt::in, Line::out),
 	[will_not_call_mercury],
 	"
 		char		*line;
@@ -129,13 +129,19 @@
 		}
 	"
 ).
+:- pragma foreign_proc("MC++",
+	call_trace_getline(_MdbIn::in, _MdbOut::in, _Prompt::in, _Line::out),
+	[will_not_call_mercury],
+	"mercury::runtime::Errors::SORRY(""call_trace_getline"");"
+).
 
 util__trace_get_command(Prompt, Result) -->
 	io__input_stream(MdbIn),
 	io__output_stream(MdbOut),
 	util__trace_get_command(Prompt, Result, MdbIn, MdbOut).
 
-:- pragma c_code(util__trace_get_command(Prompt::in, Line::out, MdbIn::in,
+:- pragma foreign_proc("C",
+	util__trace_get_command(Prompt::in, Line::out, MdbIn::in,
 			MdbOut::in, State0::di, State::uo),
 	[will_not_call_mercury],
 	"
@@ -157,6 +163,12 @@
 
 		State = State0;
 	"
+).
+:- pragma foreign_proc("MC++",
+	util__trace_get_command(_Prompt::in, _Line::out, _MdbIn::in,
+			_MdbOut::in, _State0::di, _State::uo),
+	[will_not_call_mercury],
+	"mercury::runtime::Errors::SORRY(""trace_get_command"");"
 ).
 
 util__zip_with(Pred, XXs, YYs, Zipped) :-

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list