[m-rev.] for review: semidet C# code
Tyson Dowd
trd at cs.mu.OZ.AU
Fri Oct 12 15:10:32 AEST 2001
Relative diff:
--- /home/pgrad/trd/zzreview.semidet Fri Oct 12 13:15:54 2001
+++ zzlog.semidet2 Fri Oct 12 14:55:54 2001
@@ -1,8 +1,3 @@
-Hi,
-
-
-===================================================================
-
Estimated hours taken: 10
Branches: main
@@ -20,6 +15,9 @@
implemented in MC++ -- but it won't catch cases where
IL's bool type is returned, but that should not be a such a problem.
+compiler/ilasm.m:
+ Handle the output of boolean integer constants.
+
compiler/ml_code_gen.m:
Add SUCCESS_INDICATOR to the locals of the MLDS for semidet C# code,
copy SUCCESS_INDICATOR into succeeded after the execution of the
@@ -36,6 +34,7 @@
Represent native_bool_type as bool, not int32.
Check for MC++ functions returning bool (not int32).
+ Output true and false as boolean constants for 1 and 0.
compiler/mlds_to_mcpp.m:
Map bool to MR_Bool, not MR_Integer.
@@ -53,324 +52,4 @@
library/std_util.m:
Add some missing assignments to SUCCESS_INDICATOR.
diff -u compiler/mlds_to_il.m compiler/mlds_to_il.m
--- compiler/mlds_to_il.m
+++ compiler/mlds_to_il.m
@@ -51,7 +51,6 @@
% we should (this can occur in nondet C code).
% [ ] ml_gen_call_current_success_cont_indirectly should be merged with
% similar code for doing copy-in/copy-out.
-% [ ] Try to use the IL bool type for the true/false rvals.
% [ ] Add an option to do overflow checking.
% [ ] Should replace hard-coded of int32 with a more abstract name such
% as `mercury_int_il_type'.
@@ -2170,12 +2169,11 @@
% characters, etc.
load(const(Const), Instrs) -->
DataRep =^ il_data_rep,
- % XXX is there a better way to handle true and false
- % using IL's bool type?
+ % true and false are just the integers 1 and 0
{ Const = true,
- Instrs = instr_node(ldc(int32, i(1)))
+ Instrs = instr_node(ldc(bool, i(1)))
; Const = false,
- Instrs = instr_node(ldc(int32, i(0)))
+ Instrs = instr_node(ldc(bool, i(0)))
; Const = string_const(Str),
Instrs = instr_node(ldstr(Str))
; Const = int_const(Int),
diff -u library/int.m library/int.m
--- library/int.m
+++ library/int.m
@@ -477,6 +477,16 @@
#define ML_BITS_PER_INT (sizeof(MR_Integer) * CHAR_BIT)
").
+:- pragma foreign_decl("MC++", "
+ #include <limits.h>
+
+ // XXX this should work, but it would be nice to have a more robust
+ // technique that used the fact we map to System.Int32 in the compiler.
+
+ #define ML_BITS_PER_INT (sizeof(MR_Integer) * CHAR_BIT)
+
+").
+
:- pragma foreign_proc("C", int__max_int(Max::out),
[will_not_call_mercury, thread_safe], "
if (sizeof(MR_Integer) == sizeof(int))
@@ -530,20 +540,17 @@
:- pragma foreign_proc("MC++", int__bits_per_int(Bits::out),
[will_not_call_mercury, thread_safe], "
- Bits = 32;
+ Bits = ML_BITS_PER_INT;
").
int__quot_bits_per_int(Int::in) = (Result::out) :-
- int__bits_per_int(Bits),
- Result = Int // Bits.
+ Result = Int // int__bits_per_int.
int__times_bits_per_int(Int::in) = (Result::out) :-
- int__bits_per_int(Bits),
- Result = Int * Bits.
+ Result = Int * int__bits_per_int.
int__rem_bits_per_int(Int::in) = (Result::out) :-
- int__bits_per_int(Bits),
- Result = Int rem Bits.
+ Result = Int rem int__bits_per_int.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
only in patch2:
--- compiler/ilasm.m 24 Aug 2001 16:19:17 -0000 1.23
+++ compiler/ilasm.m 12 Oct 2001 04:43:54 -0000
@@ -1044,7 +1044,7 @@
% Lots of short forms for loading integer.
% XXX Should probably put the magic numbers in functions.
output_instr(ldc(Type, Const), I, I) -->
- ( { Type = int32, Const = i(IntConst) } ->
+ ( { ( Type = int32 ; Type = bool ), Const = i(IntConst) } ->
( { IntConst < 8, IntConst >= 0 } ->
io__write_string("ldc.i4."),
io__write_int(IntConst)
--
Tyson Dowd #
# Surreal humour isn't everyone's cup of fur.
trd at cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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