[m-rev.] diff: fix for dummy_var bug
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Feb 14 19:42:40 AEDT 2003
Estimated hours taken: 1
Branches: main
Fix a bug where the MLDS back-end was generating references to `dummy_var',
for calls to builtins such as unsafe_promise_unique and unsafe_type_cast
with dummy types such as `io__state'. Referencing a dummy variable is OK for
`--low-level-data', but it doesn't work with `--high-level-data' (e.g. for
the .NET back-end), because we'd need different dummy variables for each
different type. It's better to avoid generating such assignments in the
first place.
compiler/ml_code_gen.m:
Avoiding generating references to dummy_var for calls to
unsafe_type_cast.
compiler/ml_call_gen.m:
Avoiding generating references to dummy_var for calls to other
builtins, such as unsafe_promise_unique.
Index: ml_call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_call_gen.m,v
retrieving revision 1.36
diff -u -d -u -r1.36 ml_call_gen.m
--- ml_call_gen.m 27 Jan 2003 09:20:48 -0000 1.36
+++ ml_call_gen.m 13 Feb 2003 19:12:35 -0000
@@ -968,9 +960,22 @@
(
{ SimpleCode = assign(Lval, SimpleExpr) }
->
- { Rval = ml_gen_simple_expr(SimpleExpr) },
- { MLDS_Statement = ml_gen_assign(Lval, Rval,
- Context) }
+ (
+ % we need to avoid generating assignments to
+ % dummy variables introduced for types such
+ % as io__state
+ { Lval = var(_VarName, VarType) },
+ { VarType = mercury_type(ProgDataType, _, _) },
+ { type_util__is_dummy_argument_type(
+ ProgDataType) }
+ ->
+ { MLDS_Statements = [] }
+ ;
+ { Rval = ml_gen_simple_expr(SimpleExpr) },
+ { MLDS_Statement = ml_gen_assign(Lval, Rval,
+ Context) },
+ { MLDS_Statements = [MLDS_Statement] }
+ )
;
{ error("Malformed det builtin predicate") }
)
@@ -980,7 +985,8 @@
{ SimpleCode = test(SimpleTest) }
->
{ TestRval = ml_gen_simple_expr(SimpleTest) },
- ml_gen_set_success(TestRval, Context, MLDS_Statement)
+ ml_gen_set_success(TestRval, Context, MLDS_Statement),
+ { MLDS_Statements = [MLDS_Statement] }
;
{ error("Malformed semi builtin predicate") }
)
@@ -988,7 +994,6 @@
{ CodeModel = model_non },
{ error("Nondet builtin predicate") }
),
- { MLDS_Statements = [MLDS_Statement] },
{ MLDS_Decls = [] }.
:- func ml_gen_simple_expr(simple_expr(mlds__lval)) = mlds__rval.
Index: ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.123
diff -u -d -u -r1.123 ml_code_gen.m
--- ml_code_gen.m 11 Feb 2003 02:14:27 -0000 1.123
+++ ml_code_gen.m 14 Feb 2003 07:42:44 -0000
@@ -2073,11 +2101,15 @@
{ ArgLvals = [SrcLval, DestLval] },
{ ArgTypes = [SrcType, DestType] }
->
- ml_gen_box_or_unbox_rval(SrcType, DestType,
- lval(SrcLval), CastRval),
- { Assign = ml_gen_assign(DestLval, CastRval,
- Context) },
- { MLDS_Statements = [Assign] },
+ ( { type_util__is_dummy_argument_type(DestType) } ->
+ { MLDS_Statements = [] }
+ ;
+ ml_gen_box_or_unbox_rval(SrcType, DestType,
+ lval(SrcLval), CastRval),
+ { Assign = ml_gen_assign(DestLval, CastRval,
+ Context) },
+ { MLDS_Statements = [Assign] }
+ ),
{ MLDS_Decls = [] }
;
{ error("wrong number of args for unsafe_type_cast") }
--
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