[m-dev.] diff: MLDS backend: support builtins

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Sep 18 02:19:58 AEST 1999


Estimated hours taken: 2

Add support for generation of builtins to the MLDS backend.

compiler/ml_code_gen.m:
	Add support for generating builtins (mostly copied
	from call_gen.m and code_util.m, but with a few
	changes).

compiler/code_util.m:
	Add a comment warning about the code duplication.

compiler/c_util.m:
compiler/llds_out.m:
compiler/mlds_to_c.m:
	Move (most of) the code from llds_out__binary_op_to_string
	into a new routine c_util__binary_infix_op/2, and change
	llds_out.m and mlds_to_c.m to use it.

compiler/mlds_to_c.m:
	(An unrelated change:)
	Don't output any comments for "public" access,
	since such comments end up being just noise.

Workspace: /d-drive/home/hg/fjh/mercury
Index: compiler/c_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/c_util.m,v
retrieving revision 1.1
diff -u -r1.1 c_util.m
--- compiler/c_util.m	1999/08/05 11:57:33	1.1
+++ compiler/c_util.m	1999/09/17 16:01:06
@@ -90,6 +90,12 @@
 :- pred c_util__unary_prefix_op(unary_op, string).
 :- mode c_util__unary_prefix_op(in, out) is det.
 
+	% The operator returned with be an infix operator.
+	% The arguments should be integer or booleans
+	% and the result will be an integer or a boolean.
+:- pred c_util__binary_infix_op(binary_op, string).
+:- mode c_util__binary_infix_op(in, out) is semidet.
+
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -222,5 +228,26 @@
 c_util__float_compare_op(float_ge, ">=").
 c_util__float_compare_op(float_lt, "<").
 c_util__float_compare_op(float_gt, ">").
+
+%-----------------------------------------------------------------------------%
+
+c_util__binary_infix_op(+, "+").
+c_util__binary_infix_op(-, "-").
+c_util__binary_infix_op(*, "*").
+c_util__binary_infix_op(/, "/").
+c_util__binary_infix_op(<<, "<<").
+c_util__binary_infix_op(>>, ">>").
+c_util__binary_infix_op(&, "&").
+c_util__binary_infix_op('|', "|").
+c_util__binary_infix_op(^, "^").
+c_util__binary_infix_op(mod, "%").
+c_util__binary_infix_op(eq, "==").
+c_util__binary_infix_op(ne, "!=").
+c_util__binary_infix_op(and, "&&").
+c_util__binary_infix_op(or, "||").
+c_util__binary_infix_op(<, "<").
+c_util__binary_infix_op(>, ">").
+c_util__binary_infix_op(<=, "<=").
+c_util__binary_infix_op(>=, ">=").
 
 %-----------------------------------------------------------------------------%
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.121
diff -u -r1.121 llds_out.m
--- compiler/llds_out.m	1999/09/17 05:24:52	1.121
+++ compiler/llds_out.m	1999/09/17 16:07:22
@@ -3877,46 +3877,20 @@
 :- mode output_binary_op(in, di, uo) is det.
 
 output_binary_op(Op) -->
-	{ llds_out__binary_op_to_string(Op, String) },
-	io__write_string(String).
+	( { c_util__binary_infix_op(Op, String) } ->
+		io__write_string(String)
+	;
+		{ error("llds_out.m: invalid binary operator") }
+	).
 
-llds_out__binary_op_to_string(+, "+").
-llds_out__binary_op_to_string(-, "-").
-llds_out__binary_op_to_string(*, "*").
-llds_out__binary_op_to_string(/, "/").
-llds_out__binary_op_to_string(<<, "<<").
-llds_out__binary_op_to_string(>>, ">>").
-llds_out__binary_op_to_string(&, "&").
-llds_out__binary_op_to_string('|', "|").
-llds_out__binary_op_to_string(^, "^").
-llds_out__binary_op_to_string(mod, "%").
-llds_out__binary_op_to_string(eq, "==").
-llds_out__binary_op_to_string(ne, "!=").
-llds_out__binary_op_to_string(and, "&&").
-llds_out__binary_op_to_string(or, "||").
-llds_out__binary_op_to_string(<, "<").
-llds_out__binary_op_to_string(>, ">").
-llds_out__binary_op_to_string(<=, "<=").
-llds_out__binary_op_to_string(>=, ">=").
-	% The following is just for debugging purposes -
-	% string operators are not output as `str_eq', etc.
-llds_out__binary_op_to_string(array_index, "array_index").
-llds_out__binary_op_to_string(str_eq, "str_eq").
-llds_out__binary_op_to_string(str_ne, "str_ne").
-llds_out__binary_op_to_string(str_lt, "str_lt").
-llds_out__binary_op_to_string(str_gt, "str_gt").
-llds_out__binary_op_to_string(str_le, "str_le").
-llds_out__binary_op_to_string(str_ge, "str_ge").
-llds_out__binary_op_to_string(float_eq, "float_eq").
-llds_out__binary_op_to_string(float_ne, "float_ne").
-llds_out__binary_op_to_string(float_lt, "float_lt").
-llds_out__binary_op_to_string(float_gt, "float_gt").
-llds_out__binary_op_to_string(float_le, "float_le").
-llds_out__binary_op_to_string(float_ge, "float_ge").
-llds_out__binary_op_to_string(float_plus, "float_plus").
-llds_out__binary_op_to_string(float_minus, "float_minus").
-llds_out__binary_op_to_string(float_times, "float_times").
-llds_out__binary_op_to_string(float_divide, "float_divide").
+llds_out__binary_op_to_string(Op, Name) :-
+	( c_util__binary_infix_op(Op, Name0) ->
+		Name = Name0
+	;
+		% The following is just for debugging purposes -
+		% string operators are not output as `str_eq', etc.
+		functor(Op, Name, _)
+	).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.3
diff -u -r1.3 ml_code_gen.m
--- compiler/ml_code_gen.m	1999/09/17 14:18:30	1.3
+++ compiler/ml_code_gen.m	1999/09/17 16:07:30
@@ -889,10 +889,17 @@
 	% XXX not yet implemented
 	{ sorry("higher-order and class-method calls") }.
 
-ml_gen_goal_expr(call(PredId, ProcId, ArgVars, _, _, _PredName), CodeModel,
-		Context, MLDS_Decls, MLDS_Statements) -->
-	ml_gen_call(PredId, ProcId, ArgVars, CodeModel, Context,
-		MLDS_Decls, MLDS_Statements).
+ml_gen_goal_expr(call(PredId, ProcId, ArgVars, BuiltinState, _, _PredName),
+		CodeModel, Context, MLDS_Decls, MLDS_Statements) -->
+	(
+		{ BuiltinState = not_builtin }
+	->
+		ml_gen_call(PredId, ProcId, ArgVars, CodeModel, Context,
+			MLDS_Decls, MLDS_Statements)
+	;
+		ml_gen_builtin(PredId, ProcId, ArgVars, CodeModel, Context,
+			MLDS_Decls, MLDS_Statements)
+	).
 
 ml_gen_goal_expr(unify(_A, _B, _, Unification, _), CodeModel, Context,
 		MLDS_Decls, MLDS_Statements) -->
@@ -1015,6 +1022,270 @@
 
 %-----------------------------------------------------------------------------%
 %
+% Code for builtins
+%
+
+:- pred ml_gen_builtin(pred_id, proc_id, list(prog_var), code_model,
+		prog_context, mlds__defns, mlds__statements,
+		ml_gen_info, ml_gen_info).
+:- mode ml_gen_builtin(in, in, in, in, in, out, out, in, out) is det.
+
+ml_gen_builtin(PredId, ProcId, ArgVars, CodeModel, Context,
+		MLDS_Decls, MLDS_Statements) -->
+	
+	ml_gen_var_list(ArgVars, ArgLvals),
+
+	=(Info),
+	{ ml_gen_info_get_module_info(Info, ModuleInfo) },
+	{ predicate_module(ModuleInfo, PredId, ModuleName) },
+	{ predicate_name(ModuleInfo, PredId, PredName) },
+	{
+		ml_translate_builtin(ModuleName, PredName,
+			ProcId, ArgLvals, MaybeTest0, MaybeAssign0)
+	->
+		MaybeTest = MaybeTest0,
+		MaybeAssign = MaybeAssign0
+	;
+		error("ml_gen_builtin: unknown builtin predicate")
+	},
+	(
+		{ CodeModel = model_det },
+		(
+			{ MaybeTest = no },
+			{ MaybeAssign = yes(Lval - Rval) }
+		->
+			{ MLDS_Statement = ml_gen_assign(Lval, Rval,
+				Context) }
+		;
+			{ error("Malformed det builtin predicate") }
+		)
+	;
+		{ CodeModel = model_semi },
+		(
+			{ MaybeTest = yes(Test) },
+			{ MaybeAssign = no }
+		->
+			ml_gen_set_success(Test, Context, MLDS_Statement)
+		;
+			{ error("Malformed semi builtin predicate") }
+		)
+	;
+		{ CodeModel = model_non },
+		{ error("Nondet builtin predicate") }
+	),
+	{ MLDS_Statements = [MLDS_Statement] },
+	{ MLDS_Decls = [] }.
+
+	% Given a module name, a predicate name, a proc_id and a list of
+	% the lvals for the arguments, find out if that procedure of that
+	% predicate is an inline builtin. If yes, the last two arguments
+	% return two things:
+	%
+	% - an rval to execute as a test if the builtin is semidet; or
+	%
+	% - an rval to assign to an lval if the builtin is det.
+	%
+	% Exactly one of these will be present.
+	%
+	% XXX this is not great interface design -
+	% better to return a discriminated union than
+	% returning two maybes.  But I kept it this way so that
+	% the code stays similar to code_util__translate_builtin.
+
+:- pred ml_translate_builtin(module_name, string, proc_id, list(mlds__lval),
+		maybe(mlds__rval), maybe(pair(mlds__lval, mlds__rval))).
+:- mode ml_translate_builtin(in, in, in, in, out, out) is semidet.
+
+ml_translate_builtin(FullyQualifiedModule, PredName, ProcId, Args,
+		TestOp, AssignmentOp) :-
+	proc_id_to_int(ProcId, ProcInt),
+	% -- not yet:
+	% FullyQualifiedModule = qualified(unqualified("std"), ModuleName),
+	FullyQualifiedModule = unqualified(ModuleName),
+	ml_translate_builtin_2(ModuleName, PredName, ProcInt, Args,
+		TestOp, AssignmentOp).
+
+:- pred ml_translate_builtin_2(string, string, int, list(mlds__lval),
+	maybe(mlds__rval), maybe(pair(mlds__lval, mlds__rval))).
+:- mode ml_translate_builtin_2(in, in, in, in, out, out) is semidet.
+
+% WARNING: any changes here may need to be duplicated in
+% code_util__translate_builtin_2 and vice versa.
+
+ml_translate_builtin_2("private_builtin", "unsafe_type_cast", 0,
+		[X, Y], no, yes(Y - lval(X))).
+ml_translate_builtin_2("builtin", "unsafe_promise_unique", 0,
+		[X, Y], no, yes(Y - lval(X))).
+
+ml_translate_builtin_2("private_builtin", "builtin_int_gt", 0, [X, Y],
+	yes(binop((>), lval(X), lval(Y))), no).
+ml_translate_builtin_2("private_builtin", "builtin_int_lt", 0, [X, Y],
+	yes(binop((<), lval(X), lval(Y))), no).
+
+ml_translate_builtin_2("int", "builtin_plus", 0, [X, Y, Z],
+	no, yes(Z - binop((+), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_plus", 1, [X, Y, Z],
+	no, yes(X - binop((-), lval(Z), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_plus", 2, [X, Y, Z],
+	no, yes(Y - binop((-), lval(Z), lval(X)))).
+ml_translate_builtin_2("int", "+", 0, [X, Y, Z],
+	no, yes(Z - binop((+), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "+", 1, [X, Y, Z],
+	no, yes(X - binop((-), lval(Z), lval(Y)))).
+ml_translate_builtin_2("int", "+", 2, [X, Y, Z],
+	no, yes(Y - binop((-), lval(Z), lval(X)))).
+ml_translate_builtin_2("int", "builtin_minus", 0, [X, Y, Z],
+	no, yes(Z - binop((-), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_minus", 1, [X, Y, Z],
+	no, yes(X - binop((+), lval(Y), lval(Z)))).
+ml_translate_builtin_2("int", "builtin_minus", 2, [X, Y, Z],
+	no, yes(Y - binop((-), lval(X), lval(Z)))).
+ml_translate_builtin_2("int", "-", 0, [X, Y, Z],
+	no, yes(Z - binop((-), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "-", 1, [X, Y, Z],
+	no, yes(X - binop((+), lval(Y), lval(Z)))).
+ml_translate_builtin_2("int", "-", 2, [X, Y, Z],
+	no, yes(Y - binop((-), lval(X), lval(Z)))).
+ml_translate_builtin_2("int", "builtin_times", 0, [X, Y, Z],
+	no, yes(Z - binop((*), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_times", 1, [X, Y, Z],
+	no, yes(X - binop((/), lval(Z), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_times", 2, [X, Y, Z],
+	no, yes(Y - binop((/), lval(Z), lval(X)))).
+ml_translate_builtin_2("int", "*", 0, [X, Y, Z],
+	no, yes(Z - binop((*), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "*", 1, [X, Y, Z],
+	no, yes(X - binop((/), lval(Z), lval(Y)))).
+ml_translate_builtin_2("int", "*", 2, [X, Y, Z],
+	no, yes(Y - binop((/), lval(Z), lval(X)))).
+ml_translate_builtin_2("int", "builtin_div", 0, [X, Y, Z],
+	no, yes(Z - binop((/), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_div", 1, [X, Y, Z],
+	no, yes(X - binop((*), lval(Y), lval(Z)))).
+ml_translate_builtin_2("int", "builtin_div", 2, [X, Y, Z],
+	no, yes(Y - binop((/), lval(X), lval(Z)))).
+ml_translate_builtin_2("int", "//", 0, [X, Y, Z],
+	no, yes(Z - binop((/), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "//", 1, [X, Y, Z],
+	no, yes(X - binop((*), lval(Y), lval(Z)))).
+ml_translate_builtin_2("int", "//", 2, [X, Y, Z],
+	no, yes(Y - binop((/), lval(X), lval(Z)))).
+ml_translate_builtin_2("int", "builtin_mod", 0, [X, Y, Z],
+	no, yes(Z - binop((mod), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "rem", 0, [X, Y, Z],
+	no, yes(Z - binop((mod), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_left_shift", 0, [X, Y, Z],
+	no, yes(Z - binop((<<), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "unchecked_left_shift", 0, [X, Y, Z],
+	no, yes(Z - binop((<<), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_right_shift", 0, [X, Y, Z],
+	no, yes(Z - binop((>>), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "unchecked_right_shift", 0, [X, Y, Z],
+	no, yes(Z - binop((>>), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_bit_and", 0, [X, Y, Z],
+	no, yes(Z - binop((&), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "/\\", 0, [X, Y, Z],
+	no, yes(Z - binop((&), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_bit_or", 0, [X, Y, Z],
+	no, yes(Z - binop(('|'), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "\\/", 0, [X, Y, Z],
+	no, yes(Z - binop(('|'), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_bit_xor", 0, [X, Y, Z],
+	no, yes(Z - binop((^), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "^", 0, [X, Y, Z],
+	no, yes(Z - binop((^), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "builtin_unary_plus", 0, [X, Y],
+	no, yes(Y - lval(X))).
+ml_translate_builtin_2("int", "+", 0, [X, Y],
+	no, yes(Y - lval(X))).
+ml_translate_builtin_2("int", "builtin_unary_minus", 0, [X, Y],
+	no, yes(Y - binop((-), const(int_const(0)), lval(X)))).
+ml_translate_builtin_2("int", "-", 0, [X, Y],
+	no, yes(Y - binop((-), const(int_const(0)), lval(X)))).
+ml_translate_builtin_2("int", "builtin_bit_neg", 0, [X, Y],
+	no, yes(Y - unop(bitwise_complement, lval(X)))).
+ml_translate_builtin_2("int", "\\", 0, [X, Y],
+	no, yes(Y - unop(bitwise_complement, lval(X)))).
+ml_translate_builtin_2("int", ">", 0, [X, Y],
+	yes(binop((>), lval(X), lval(Y))), no).
+ml_translate_builtin_2("int", "<", 0, [X, Y],
+	yes(binop((<), lval(X), lval(Y))), no).
+ml_translate_builtin_2("int", ">=", 0, [X, Y],
+	yes(binop((>=), lval(X), lval(Y))), no).
+ml_translate_builtin_2("int", "=<", 0, [X, Y],
+	yes(binop((<=), lval(X), lval(Y))), no).
+
+ml_translate_builtin_2("float", "builtin_float_plus", 0, [X, Y, Z],
+	no, yes(Z - binop(float_plus, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "builtin_float_plus", 1, [X, Y, Z],
+	no, yes(X - binop(float_minus, lval(Z), lval(Y)))).
+ml_translate_builtin_2("float", "builtin_float_plus", 2, [X, Y, Z],
+	no, yes(Y - binop(float_minus, lval(Z), lval(X)))).
+ml_translate_builtin_2("float", "+", 0, [X, Y, Z],
+	no, yes(Z - binop(float_plus, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "+", 1, [X, Y, Z],
+	no, yes(X - binop(float_minus, lval(Z), lval(Y)))).
+ml_translate_builtin_2("float", "+", 2, [X, Y, Z],
+	no, yes(Y - binop(float_minus, lval(Z), lval(X)))).
+ml_translate_builtin_2("float", "builtin_float_minus", 0, [X, Y, Z],
+	no, yes(Z - binop(float_minus, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "builtin_float_minus", 1, [X, Y, Z],
+	no, yes(X - binop(float_plus, lval(Y), lval(Z)))).
+ml_translate_builtin_2("float", "builtin_float_minus", 2, [X, Y, Z],
+	no, yes(Y - binop(float_minus, lval(X), lval(Z)))).
+ml_translate_builtin_2("float", "-", 0, [X, Y, Z],
+	no, yes(Z - binop(float_minus, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "-", 1, [X, Y, Z],
+	no, yes(X - binop(float_plus, lval(Y), lval(Z)))).
+ml_translate_builtin_2("float", "-", 2, [X, Y, Z],
+	no, yes(Y - binop(float_minus, lval(X), lval(Z)))).
+ml_translate_builtin_2("float", "builtin_float_times", 0, [X, Y, Z],
+	no, yes(Z - binop(float_times, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "builtin_float_times", 1, [X, Y, Z],
+	no, yes(X - binop(float_divide, lval(Z), lval(Y)))).
+ml_translate_builtin_2("float", "builtin_float_times", 2, [X, Y, Z],
+	no, yes(Y - binop(float_divide, lval(Z), lval(X)))).
+ml_translate_builtin_2("float", "*", 0, [X, Y, Z],
+	no, yes(Z - binop(float_times, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "*", 1, [X, Y, Z],
+	no, yes(X - binop(float_divide, lval(Z), lval(Y)))).
+ml_translate_builtin_2("float", "*", 2, [X, Y, Z],
+	no, yes(Y - binop(float_divide, lval(Z), lval(X)))).
+ml_translate_builtin_2("float", "builtin_float_divide", 0, [X, Y, Z],
+	no, yes(Z - binop(float_divide, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "builtin_float_divide", 1, [X, Y, Z],
+	no, yes(X - binop(float_times, lval(Y), lval(Z)))).
+ml_translate_builtin_2("float", "builtin_float_divide", 2, [X, Y, Z],
+	no, yes(Y - binop(float_divide, lval(X), lval(Z)))).
+ml_translate_builtin_2("float", "/", 0, [X, Y, Z],
+	no, yes(Z - binop(float_divide, lval(X), lval(Y)))).
+ml_translate_builtin_2("float", "/", 1, [X, Y, Z],
+	no, yes(X - binop(float_times, lval(Y), lval(Z)))).
+ml_translate_builtin_2("float", "/", 2, [X, Y, Z],
+	no, yes(Y - binop(float_divide, lval(X), lval(Z)))).
+ml_translate_builtin_2("float", "+", 0, [X, Y],
+	no, yes(Y - lval(X))).
+ml_translate_builtin_2("float", "-", 0, [X, Y],
+	no, yes(Y - binop(float_minus, const(float_const(0.0)), lval(X)))).
+ml_translate_builtin_2("float", "builtin_float_gt", 0, [X, Y],
+	yes(binop(float_gt, lval(X), lval(Y))), no).
+ml_translate_builtin_2("float", ">", 0, [X, Y],
+	yes(binop(float_gt, lval(X), lval(Y))), no).
+ml_translate_builtin_2("float", "builtin_float_lt", 0, [X, Y],
+	yes(binop(float_lt, lval(X), lval(Y))), no).
+ml_translate_builtin_2("float", "<", 0, [X, Y],
+	yes(binop(float_lt, lval(X), lval(Y))), no).
+ml_translate_builtin_2("float", "builtin_float_ge", 0, [X, Y],
+	yes(binop(float_ge, lval(X), lval(Y))), no).
+ml_translate_builtin_2("float", ">=", 0, [X, Y],
+	yes(binop(float_ge, lval(X), lval(Y))), no).
+ml_translate_builtin_2("float", "builtin_float_le", 0, [X, Y],
+	yes(binop(float_le, lval(X), lval(Y))), no).
+ml_translate_builtin_2("float", "=<", 0, [X, Y],
+	yes(binop(float_le, lval(X), lval(Y))), no).
+
+%-----------------------------------------------------------------------------%
+%
 % Code for switches
 %
 
@@ -2491,6 +2762,18 @@
 			mlds__make_context(Context))
 	).
 		
+	% Generate a list of the mlds__lvals corresponding to a
+	% given list of prog_vars.
+	%
+:- pred ml_gen_var_list(list(prog_var), list(mlds__lval),
+		ml_gen_info, ml_gen_info).
+:- mode ml_gen_var_list(in, out, in, out) is det.
+
+ml_gen_var_list([], []) --> [].
+ml_gen_var_list([Var | Vars], [Lval | Lvals]) -->
+	ml_gen_var(Var, Lval),
+	ml_gen_var_list(Vars, Lvals).
+
 	% Generate the mlds__lval corresponding to a given prog_var.
 	%
 :- pred ml_gen_var(prog_var, mlds__lval, ml_gen_info, ml_gen_info).
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.4
diff -u -r1.4 mlds_to_c.m
--- compiler/mlds_to_c.m	1999/09/17 14:18:31	1.4
+++ compiler/mlds_to_c.m	1999/09/17 16:07:31
@@ -585,10 +585,10 @@
 :- pred mlds_output_access(access, io__state, io__state).
 :- mode mlds_output_access(in, di, uo) is det.
 
-mlds_output_access(public)    --> io__write_string("/* public: */ ").
+mlds_output_access(public)    --> [].
 mlds_output_access(private)   --> io__write_string("/* private: */ ").
 mlds_output_access(protected) --> io__write_string("/* protected: */ ").
-mlds_output_access(default)   --> [].
+mlds_output_access(default)   --> io__write_string("/* default access */ ").
 
 :- pred mlds_output_per_instance(per_instance, io__state, io__state).
 :- mode mlds_output_per_instance(in, di, uo) is det.
@@ -1063,13 +1063,14 @@
 	).
 
 :- pred mlds_output_binary_op(binary_op, io__state, io__state).
-:- mode mlds_output_binary_op(in, di, uo) is erroneous.
+:- mode mlds_output_binary_op(in, di, uo) is det.
 
-mlds_output_binary_op(_Op) -->
-	{ error("NYI 7") }.
-	% XXX
-	% { c_util__binary_op(Op, OpStr) },
-	% io__write_string(OpStr).
+mlds_output_binary_op(Op) -->
+	( { c_util__binary_infix_op(Op, OpStr) } ->
+		io__write_string(OpStr)
+	;
+		{ error("mlds_output_binary_op: invalid binary operator") }
+	).
 
 :- pred mlds_output_rval_const(mlds__rval_const, io__state, io__state).
 :- mode mlds_output_rval_const(in, di, uo) is det.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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