[m-dev.] diff: unbreak Aditi query shell

Simon Taylor stayl at cs.mu.OZ.AU
Sat Aug 19 22:32:55 AEST 2000


Estimated hours taken: 0.5

The recent change to report errors for exported predicates
or functions for which there is a `:- mode' declaration
but no `:- pred' or `:- func' declaration broke the
Aditi query shell. Users do not have to write down types
for their queries -- the shell extracts the type information
required to call the RL bytecode for the query from
the generated `<module>.derived_schema' file.

compiler/make_hlds.m:
	Don't report errors for this case if `--aditi-only' is set.

tests/valid/Mmakefile:
tests/valid/aditi_query.m:
	Test case.


Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.342
diff -u -u -r1.342 make_hlds.m
--- compiler/make_hlds.m	2000/08/16 08:54:00	1.342
+++ compiler/make_hlds.m	2000/08/19 12:23:29
@@ -7427,17 +7427,31 @@
 % and the `--infer-types' option was specified,
 % then we just add an implicit declaration for that predicate or
 % function, marking it as one whose type will be inferred.
+%
+% If this module is for a query generated by the Aditi dbsh
+% (--aditi-only is set), allow mode declarations for exported
+% predicates with no `:- pred' or `:- func' declaration.
+% The predicate will never be called from a compiled Mercury
+% procedure. The RL bytecode for the predicate will be called
+% directly using information from the generated
+% `<module>.derived_schema' file to work out the argument
+% types of the output relation.
 
 maybe_undefined_pred_error(Name, Arity, PredOrFunc, Status, IsClassMethod,
 		Context, Description) -->
 	{ status_defined_in_this_module(Status, DefinedInThisModule) },
 	{ status_is_exported(Status, IsExported) },
 	globals__io_lookup_bool_option(infer_types, InferTypes),
+	globals__io_lookup_bool_option(aditi_only, AditiOnly),
 	(
-		{ DefinedInThisModule = yes },
-		{ IsExported = no },
-		{ IsClassMethod = no },
-		{ InferTypes = yes }
+		{
+			DefinedInThisModule = yes,
+			IsExported = no,
+			IsClassMethod = no,
+			InferTypes = yes
+		;
+			AditiOnly = yes
+		}		
 	->
 		[]
 	;
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.68
diff -u -u -r1.68 Mmakefile
--- tests/valid/Mmakefile	2000/08/16 07:35:03	1.68
+++ tests/valid/Mmakefile	2000/08/19 12:07:13
@@ -28,6 +28,7 @@
 
 ADITI_SOURCES= \
 	aditi_error_bug.m \
+	aditi_query.m \
 	aditi_update.m \
 	base_relation.m \
 	base_relation2.m \
@@ -202,6 +203,7 @@
 MCFLAGS-aditi_error_bug		= --aditi
 MCFLAGS-aditi_error_bug2	= --aditi
 MCFLAGS-aditi_error_bug3	= --aditi
+MCFLAGS-aditi_query		= --aditi-only
 MCFLAGS-aditi_update		= --aditi
 MCFLAGS-base_relation		= --aditi
 MCFLAGS-base_relation2		= --aditi
Index: tests/valid/aditi_query.m
===================================================================
RCS file: aditi_query.m
diff -N aditi_query.m
--- /dev/null	Sat Aug 19 22:07:40 2000
+++ aditi_query.m	Sat Aug 19 22:14:04 2000
@@ -0,0 +1,24 @@
+:- module aditi_query.
+
+:- interface.
+
+:- import_module aditi.
+:- mode query(aditi:aditi_mui ,out) is nondet.
+:- pragma aditi(query/2).
+
+:- implementation.
+
+:- pragma aditi_no_memo(query/2).
+
+:- import_module int.
+:- import_module float.
+:- import_module list.
+
+query(DB,X) :-
+	p(DB, X).
+
+:- pred p(aditi__state, int).
+:- mode p(aditi_mui, out) is nondet.
+
+:- pragma base_relation(p/2).
+
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list