[m-rev.] for review: allow execution of incomplete programs
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Feb 21 11:55:26 AEDT 2003
On 21-Feb-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
>
> Use hlds_goal__make_string_const_construction.
>
> Use goal_util__generate_simple_call.
Good idea, thanks!
> > Index: compiler/unused_args.m
>
> You'll also need to make unused_args assume all the arguments of stubs are
> used in unused_args__setup_local_var_usage to avoid spurious warnings in
> callers. Just handle them as for builtins.
Done. I've also added some stuff to tests/hard_coded/warn_stub.m to
test for this.
> > Index: tests/hard_coded/allow_stubs.exp
...
> > Index: tests/hard_coded/allow_stubs.m
>
> Does the expected output match the test case here?
No - I modified the test and forgot to update the expected output.
Thanks for the excellent review comments.
Here's a relative diff. I'll go ahead and commit this now.
diff -u compiler/typecheck.m compiler/typecheck.m
--- compiler/typecheck.m 20 Feb 2003 18:46:10 -0000
+++ compiler/typecheck.m 21 Feb 2003 00:53:07 -0000
@@ -652,12 +652,7 @@
% Generate `PredName = "<PredName>"'
%
varset__new_named_var(VarSet0, "PredName", PredNameVar, VarSet),
- pred_info_context(PredInfo, Context),
- create_atomic_unification(PredNameVar,
- functor(string_const(PredName), no, []),
- Context, explicit, [], Unify - UnifyGoalInfo0),
- goal_info_set_nonlocals(UnifyGoalInfo0,
- set__make_singleton_set(PredNameVar), UnifyGoalInfo),
+ make_string_const_construction(PredNameVar, PredName, UnifyGoal),
%
% Generate `private_builtin.no_clauses(PredName)'
% or `private_builtin.sorry(PredName)'
@@ -669,27 +664,14 @@
;
CalleeName = "no_clauses"
),
- CalleeSymName = qualified(PrivateBuiltin, CalleeName),
- module_info_get_predicate_table(ModuleInfo, PredicateTable),
- (
- predicate_table_search_pred_m_n_a(PredicateTable,
- PrivateBuiltin, CalleeName, 1, [CalleePredId0])
- ->
- CalleePredId = CalleePredId0
- ;
- error("generate_stub_clauses: cannot find private_builtin."
- ++ CalleeName ++ "/1")
- ),
- hlds_pred__initial_proc_id(CalleeProcId),
- Call = call(CalleePredId, CalleeProcId, [PredNameVar],
- not_builtin, no, CalleeSymName),
- goal_info_init(Context, GoalInfo),
- goal_info_set_nonlocals(GoalInfo,
- set__make_singleton_set(PredNameVar), CallGoalInfo),
+ pred_info_context(PredInfo, Context),
+ generate_simple_call(PrivateBuiltin, CalleeName, [PredNameVar],
+ only_mode, det, no, [], ModuleInfo, Context, CallGoal),
%
% Combine the unification and call into a conjunction
%
- Body = conj([Unify - UnifyGoalInfo, Call - CallGoalInfo]) - GoalInfo,
+ goal_info_init(Context, GoalInfo),
+ Body = conj([UnifyGoal, CallGoal]) - GoalInfo,
StubClause = clause([], Body, mercury, Context).
:- pred rename_instance_method_constraints(map(tvar, tvar),
diff -u compiler/unused_args.m compiler/unused_args.m
--- compiler/unused_args.m 20 Feb 2003 17:52:54 -0000
+++ compiler/unused_args.m 21 Feb 2003 00:46:08 -0000
@@ -252,8 +252,19 @@
setup_local_var_usage([PredId | PredIds], UnusedArgInfo,
!VarUsage, !PredProcList, !OptProcs, !ModuleInfo, !IO) :-
module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
+ (
% The builtins use all their arguments.
- ( code_util__predinfo_is_builtin(PredInfo) ->
+ % We also want to treat stub procedures
+ % (those which originally had no clauses)
+ % as if they use all of their arguments,
+ % to avoid spurious warnings in their callers.
+ (
+ code_util__predinfo_is_builtin(PredInfo)
+ ;
+ pred_info_get_markers(PredInfo, Markers),
+ check_marker(Markers, stub)
+ )
+ ->
setup_local_var_usage(PredIds, UnusedArgInfo, !VarUsage,
!PredProcList, !OptProcs, !ModuleInfo, !IO)
;
diff -u tests/hard_coded/allow_stubs.exp tests/hard_coded/allow_stubs.exp
--- tests/hard_coded/allow_stubs.exp 20 Feb 2003 19:32:58 -0000
+++ tests/hard_coded/allow_stubs.exp 21 Feb 2003 00:53:52 -0000
@@ -2 +2,3 @@
-going goodbye
+[caught exception: software_error("no clauses for predicate `allow_stubs.how_are_you/2\'")]
+going [caught exception: software_error("no clauses for predicate `allow_stubs.today/2\'")]
+goodbye
diff -u tests/warnings/warn_stubs.exp tests/warnings/warn_stubs.exp
--- tests/warnings/warn_stubs.exp 20 Feb 2003 19:37:28 -0000
+++ tests/warnings/warn_stubs.exp 21 Feb 2003 00:45:55 -0000
@@ -3,0 +3 @@
+warn_stubs.m:008: Warning: no clauses for predicate `warn_stubs.main2/2'.
diff -u tests/warnings/warn_stubs.m tests/warnings/warn_stubs.m
--- tests/warnings/warn_stubs.m 20 Feb 2003 19:37:12 -0000
+++ tests/warnings/warn_stubs.m 21 Feb 2003 00:45:13 -0000
@@ -6,0 +6,4 @@
+:- implementation.
+:- pred main1(io::di, io::uo) is det.
+:- pred main2(io::di, io::uo) is det.
+main1 --> main2.
--
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