[squeak-dev] Let C Code generator generate repeat loops (was The Trunk: Sound-nice.28.mcz)

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon Apr 11 17:01:54 UTC 2011


I have no commit right to VMMaker and plenty of local modifications,
so please see attachment


---------- Forwarded message ----------
From: Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>
Date: 2011/4/11
Subject: Re: [squeak-dev] The Trunk: Sound-nice.28.mcz
To: The general-purpose Squeak developers list
<squeak-dev at lists.squeakfoundation.org>


2011/4/11 Levente Uzonyi <leves at elte.hu>:
> On Mon, 11 Apr 2011, commits at source.squeak.org wrote:
>
>> Nicolas Cellier uploaded a new version of Sound to project The Trunk:
>> http://source.squeak.org/trunk/Sound-nice.28.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Sound-nice.28
>> Author: nice
>> Time: 11 April 2011, 4:49:01.623 pm
>> UUID: 3de2013e-36c1-bd46-a5db-a56a85de109a
>> Ancestors: Sound-nice.27
>>
>> Use #repeat instead of [true] whileTrue
>
> Can VMMaker compile #repeat to C? According to
> http://wiki.squeak.org/squeak/2267 it can't, but the wiki page may not be up
> to date.
>
>
> Levente
>

Right, it sounds like CCodeGenerator>>initializeCTranslationDictionary
does not have #repeat translation.
Though it does not sound difficult to add:

generateRepeat: msgNode on: aStream indent: level
       "Generate do {stmtList} while(true)"

       | stmts testStmt |
       stmts := msgNode receiver statements.
       testStmt := TConstantNode new setValue: true.
       msgNode receiver setStatements: stmts.
       aStream nextPutAll: 'do {'; cr.
       msgNode receiver emitCCodeOn: aStream level: level + 1 generator: self.
       level timesRepeat: [ aStream tab ].
       aStream nextPutAll: '} while('.
       testStmt emitCCodeOn: aStream level: 0 generator: self.
       aStream nextPutAll: ')'.

Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Generate_repeat.st
Type: application/octet-stream
Size: 5722 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110411/e3348377/Generate_repeat.obj


More information about the Squeak-dev mailing list