[m-rev.] diff: implementation-defined literals in lambdas

Peter Wang novalazy at gmail.com
Fri Jun 27 17:26:09 AEST 2008


Estimated hours taken: 0.2
Branches: main

Implementation-defined literals were not being substituted inside lambda
expressions.  This fixes Mantis bug #64.

compiler/implementation_defined_literals.m:
	Perform substitutions in lambda goals.

tests/hard_coded/impl_def_literal.exp:
tests/hard_coded/impl_def_literal.m:
	Update test case.

Index: compiler/implementation_defined_literals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/implementation_defined_literals.m,v
retrieving revision 1.1
diff -u -p -r1.1 implementation_defined_literals.m
--- compiler/implementation_defined_literals.m	3 Apr 2008 05:26:43 -0000	1.1
+++ compiler/implementation_defined_literals.m	27 Jun 2008 06:40:06 -0000
@@ -89,9 +89,9 @@ subst_literals_in_clause(Info, Clause0, 
 subst_literals_in_goal(Info, Goal0, Goal) :-
     Goal0 = hlds_goal(GoalExpr0, GoalInfo0),
     (
-        GoalExpr0 = unify(Var, RHS, _, _, _),
+        GoalExpr0 = unify(Var, RHS0, Mode, Kind, UnifyContext),
         (
-            RHS = rhs_functor(ConsId, _, _),
+            RHS0 = rhs_functor(ConsId, _, _),
             (
                 ConsId = implementation_defined_const(Name),
                 Context = goal_info_get_context(GoalInfo0),
@@ -116,9 +116,17 @@ subst_literals_in_goal(Info, Goal0, Goal
                 Goal = Goal0
             )
         ;
-            ( RHS = rhs_var(_)
-            ; RHS = rhs_lambda_goal(_, _, _, _, _, _, _, _, _)
-            ),
+            RHS0 = rhs_lambda_goal(LambdaPurity, Groundness, PredOrFunc,
+                EvalMethod, LambdaNonLocals, LambdaQuantVars,
+                LambdaModes, LambdaDetism, LambdaGoal0),
+            subst_literals_in_goal(Info, LambdaGoal0, LambdaGoal),
+            RHS = rhs_lambda_goal(LambdaPurity, Groundness, PredOrFunc,
+                EvalMethod, LambdaNonLocals, LambdaQuantVars,
+                LambdaModes, LambdaDetism, LambdaGoal),
+            GoalExpr = unify(Var, RHS, Mode, Kind, UnifyContext),
+            Goal = hlds_goal(GoalExpr, GoalInfo0)
+        ;
+            RHS0 = rhs_var(_),
             Goal = Goal0
         )
     ;

Index: tests/hard_coded/impl_def_literal.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/impl_def_literal.exp,v
retrieving revision 1.2
diff -u -p -r1.2 impl_def_literal.exp
--- tests/hard_coded/impl_def_literal.exp	7 Apr 2008 02:32:52 -0000	1.2
+++ tests/hard_coded/impl_def_literal.exp	27 Jun 2008 06:40:07 -0000
@@ -3,6 +3,7 @@ impl_def_literal.m
 impl_def_literal
 predicate `impl_def_literal.main'/2
 function `impl_def_literal.a_function'/0
+predicate `impl_def_literal.a_lambda'/1
 fun_with_lines: unequal
 fun_with_lines_2: equal
 have $grade
Index: tests/hard_coded/impl_def_literal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/impl_def_literal.m,v
retrieving revision 1.2
diff -u -p -r1.2 impl_def_literal.m
--- tests/hard_coded/impl_def_literal.m	7 Apr 2008 02:32:52 -0000	1.2
+++ tests/hard_coded/impl_def_literal.m	27 Jun 2008 06:40:07 -0000
@@ -26,6 +26,9 @@ main(!IO) :-
     io.nl(!IO),
     io.write_string(a_function, !IO),
     io.nl(!IO),
+    a_lambda(FromLambda),
+    io.write_string(FromLambda, !IO),
+    io.nl(!IO),
 
     fun_with_lines(!IO),
     fun_with_lines_2(!IO),
@@ -57,6 +60,12 @@ main(!IO) :-
 
 a_function = $pred.
 
+:- pred a_lambda(string::out) is det.
+
+a_lambda(String) :-
+    Pred = (pred($pred::out) is det),
+    Pred(String).
+
 :- pred fun_with_lines(io::di, io::uo) is det.
 
 fun_with_lines(!IO) :-


--------------------------------------------------------------------------
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