[M3devel] m3front/TInt/TFloat should maintain "textual expressions" for constants?

Jay K jay.krell at cornell.edu
Sun Aug 19 09:11:30 CEST 2012


I propose the following changed to m3front, TInt, TFloat.
It does kind of "infact" the front/middle end with the "intent" of a specific backend.
 When a TInt or TFloat is initialized from text, that text is remembered.
When such a TInt/TFloat is added/subtracted/multiplied/divided by another,
the obvious text is built up in the target. 
Initialization of TInt with constants could/should also maintain the textual representation.  The implication is multi part:
 1) init_float in a C-or-such backend can just output the textual expression.
No need to worry about roundtripping it.  2) Longer term, TInt "constant expressions" could contain like "sizeof(INTEGER)"
(preceded by a typedef for INTEGER in the larger context)..thereby factoring
out the target from the generated C.  3) This provides some hypothetical portability when host/target
don't use the "same" sort of floating point. Ignoring rounding details however.
And TFloat does seem to round correctly at compile-time, assuming host/target
are about the same -- and they all are.
(What does the language definition say here anyway? I'll have to check..)  Reasonable?  For now I'll probably punt.
 I can just use TFloat.ToChars and munge it slightly.
But this is probably a good direction.
In the short term I'm trying hard to make do w/o m3front/m3middle changes.  You know..implementing another backend, you tend to visit more of the system,
gradually understand it..think of what you how one might prefer it to be..esp.
for the task at hand. :)  Obviously this is somewhat of a hack, in that...what should the syntax of the expressions be?If/when I make the change, I'll probably use C. It will be almost identical to Modula-3 anyway.   - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120819/4b9ad76c/attachment-0001.html>


More information about the M3devel mailing list