Smalltalk code generation
Mariano Montone
mariano_montone at yahoo.com.ar
Thu Sep 29 17:22:55 UTC 2005
Hello,
I need to do some Smalltalk code generation from Smalltalk. So
I have implemented a library (although it may be seen as an embedded
language). One important thing is that I need to compose generated code
from other generated code.
A usage example:
cb := self commandBuilder
m := cb methodNamed: #conditionMethod withFormalArgs: #() comment:
'Condition method'.
m send: #ifTrue:ifFalse: to: (cb send: #isNil to: cb nil) with: (cb
block: [:blk | blk return: (cb literal:'true')])
with: (cb block: [:blk | blk return: (cb literal: 'false')]).
The "pretty" printing of the generated method m would be:
conditionMethod
"Condition method"
nil isNil ifTrue:[^true] ifFalse:[^false]
I want to do something like this, so I cant work on plain strings or do
some preprocessing:
ASTVisitor>>visitAnd: node
^cb send: #and: to: (node exp1 accept: self) with: (cb block:[:blk |
node exp2 accept: self])
And the question is: Is there a better/easier/trivial/standard way of
doing this that I am missing?
Please don't doubt to criticize it, I want to learn :-) .
Thank you very much for your time
Marian
___________________________________________________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar
More information about the Squeak-dev
mailing list
|