[M3devel] type of count to m3cg.copy_n is signed?

Jay K jay.krell at cornell.edu
Sun Sep 23 02:13:58 CEST 2012


I'm just rereading M3C.m3, cleaning stuff up.
I'm looking at copy_n.
It takes a type to copy and a count of that type, on the stack.I have to multiply by the byte size of the type and call memcpy or memmove.

I'm curious how to handle the count, and converting it for the multiplication and pass of to memcpy/memmove.I would rather like to assume it is always Target.Word.cg_type.
The only pass the frontend calls copy_n is here:    cg.copy_n (Target.Integer.cg_type, t, overlap);

Is that really intended?

Am I supposed to output a runtime check that the value is positive?

Similarly nearby in the frontend, in Copy_n:      cg.div (Target.Integer.cg_type, Sign.Positive, Sign.Positive);

Might as well that be Target.Word.cg_type?

(My meta-point is I still believe signed types over used, both in a lot of C code and definitely in Modula-3.And CARDINAL doesn't really cut it -- unsigned types shouldn't have their range cut in half..)


 - Jay 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120923/1ecd255f/attachment-0001.html>


More information about the M3devel mailing list