diff: enable term_to_type/2

Tyson Richard DOWD trd at cs.mu.oz.au
Tue May 13 18:51:51 AEST 1997


Hi,
	Fergus, can you check this is ok?

	It seems the old term_to_type was still being used, so
	any attempt to use it ended in "not implemented" messages.

	It seems to be a bug that you can have an external(...)
	declaration on a predicate, then a normal definition, and
	not get a warning message about redefinitions or anything.

===================================================================

Estimated hours taken: 0.75

Enable the new implementation of term_to_type/2.

library/mercury_builtin.m:
	Remove the external(term_to_type/2) declaration.

runtime/call.mod:
	Remove the code for term_to_type/2.

Index: library/mercury_builtin.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/mercury_builtin.m,v
retrieving revision 1.72
diff -u -r1.72 mercury_builtin.m
--- mercury_builtin.m	1997/04/30 07:54:45	1.72
+++ mercury_builtin.m	1997/05/13 08:32:16
@@ -323,7 +323,6 @@
 :- external(unify/2).
 :- external(index/2).
 :- external(compare/3).
-:- external(term_to_type/2).
 :- external(type_to_term/2).
 
 
Index: runtime/call.mod
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/call.mod,v
retrieving revision 1.27
diff -u -r1.27 call.mod
--- call.mod	1997/03/04 04:22:42	1.27
+++ call.mod	1997/05/13 08:37:28
@@ -493,121 +493,6 @@
 }
 
 /*
-** mercury__term_to_type_2_0 is called as `term_to_type(TypeInfo, Term, X)'
-** in the mode `term_to_type(in, in, out) is semidet'.
-**
-** With the simple parameter convention, the inputs are in r2 and r3,
-** the success/failure indication in r1, and the output in r4.
-**
-** With the compact parameter convention, the inputs are in r1 and r2,
-** the success/failure indication in r1, and the output in r2.
-**
-** We call the type-specific term_to_type routine as
-** `TermToTypePred(...ArgTypeInfos..., Term, X)' is semidet.
-**
-** With the simple parameter convention, the inputs are in r2, ... rN+2,
-** the success/failure indication in r1, and the output in rN+3.
-**
-** With the compact parameter convention, the inputs are in r1, ... rN+1,
-** the success/failure indication in r1, and the output in r2.
-**
-** With the compact convention, we can make the call to the type-specific
-** routine a tail call, and we do so. With the simple convention, we can't.
-*/
-
-mercury__term_to_type_2_0:
-{
-#ifndef USE_TYPE_TO_TERM
-	fatal_error("type_to_term/2 and term_to_type/2 not implemented");
-#else
-
-	Code	*term_to_type_pred;	/* address of the term_to_type pred */
-					/* for this type */
-	int	type_arity;	/* number of type_info args */
-	Word	args_base;	/* the address of the word before the first */
-				/* type_info argument */
-	Word	term;
-	int	i;
-
-  #ifdef ONE_OR_TWO_CELL_TYPE_INFO
-	Word	base_type_info;
-
-	term = mercury__term_to_type__term;
-
-	base_type_info = field(0, mercury__term_to_type__typeinfo, 0);
-	if (base_type_info == 0) {
-		type_arity = 0;
-		term_to_type_pred = (Code *) field(0,
-				mercury__term_to_type__typeinfo,
-				OFFSET_FOR_TERM_TO_TYPE_PRED);
-		/* args_base will not be needed */
-	} else {
-		type_arity = field(0, base_type_info, OFFSET_FOR_COUNT);
-		term_to_type_pred = (Code *) field(0, base_type_info,
-				OFFSET_FOR_TERM_TO_TYPE_PRED);
-		args_base = mercury__term_to_type__typeinfo;
-	}
-  #else /* not ONE_OR_TWO_CELL_TYPE_INFO */
-	term = mercury__term_to_type__term;
-
-	type_arity = field(0, mercury__term_to_type__typeinfo,
-			OFFSET_FOR_COUNT);
-	term_to_type_pred = (Code *) field(0,
-			mercury__term_to_type__typeinfo,
-			OFFSET_FOR_TERM_TO_TYPE_PRED);
-	args_base = (Word) ((Word *) mercury__term_to_type__typeinfo
-			- 1 + OFFSET_FOR_ARG_TYPE_INFOS);
-  #endif /* not ONE_OR_TWO_CELL_TYPE_INFO */
-
-	save_registers();
-
-	/* we call 'TermToTypePred(...ArgTypeInfos..., Term, X)' */
-	for (i = 1; i <= type_arity; i++) {
-		virtual_reg(i + mercury__term_to_type__offset) =
-			field(0, args_base, i);
-	}
-	virtual_reg(type_arity + mercury__term_to_type__offset + 1) = term;
-
-	restore_registers();
-
-  #ifdef COMPACT_ARGS
-	tailcall(term_to_type_pred, LABEL(mercury__term_to_type_2_0));
-  #else
-	push(succip);
-	push(type_arity);
-	call(term_to_type_pred, LABEL(mercury__term_to_type_2_0_i1),
-		LABEL(mercury__term_to_type_2_0));
-  #endif /* not COMPACT_ARGS */
-#endif /* USE_TYPE_TO_TERM */
-}
-/*
-** Since mod2c declares this label, we must define it,
-** even though it is not needed with COMPACT_ARGS.
-*/
-mercury__term_to_type_2_0_i1:
-{
-#ifndef USE_TYPE_TO_TERM
-	fatal_error("type_to_term/2 and term_to_type/2 not implemented");
-#else
-  #ifdef COMPACT_ARGS
-	fatal_error("mercury__term_to_type_2_0_i1 reached in "
-		"COMPACT_ARGS mode");
-  #else
-	/* r1 already contains the truth result of the semidet pred */
-	/* mercury__term_to_type_2_0 so r1 does not have to be updated. */
-
-	int	type_arity;
-	
-	type_arity = pop();
-	succip = pop();
-	save_registers();
-	r4 = virtual_reg(type_arity + 3);
-	proceed();
-  #endif /* not COMPACT_ARGS */
-#endif /* USE_TYPE_TO_TERM */
-}
-
-/*
 ** mercury__type_to_term_2_0 is called as `type_to_term(TypeInfo, X, Term)'
 ** in the mode `type_to_term(in, in, out) is det'.
 **
-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of
     trd at cs.mu.oz.au        #  fur.
http://www.cs.mu.oz.au/~trd #



More information about the developers mailing list