Hi,
how can I rewrite a(n instance) variable to a symbol? E.g. [IN] something: aSomething something := aSomething [OUT] something: aSomething self write: aSomething into: #something I can capute the input just fine... ``@var := ``@arg but I have no idea how to convert the var into a symbol (or string). Thanks, Peter |
Hi Peter,
Hi Peter, you should try {:node :dic | ... } to handle that. Something like: RBParseTreeRewriter new replace: '`@var `{:node :dic | dic at: #varName put: node name} := `@arg' with: 'self write: `@arg into: `{:dic | RBParser parseExpression: ''#'', (dic at: #varName) }'. You need to adjust, I haven't checked if this is correct ;). Thierry Le 11/11/2017 à 17:17, Peter Uhnák a écrit : > Hi, > > how can I rewrite a(n instance) variable to a symbol? > > E.g. > > [IN] > something: aSomething > something := aSomething > > [OUT] > something: aSomething > self write: aSomething into: #something > > > I can capute the input just fine... ``@var := ``@arg > but I have no idea how to convert the var into a symbol (or string). > > Thanks, > Peter > |
In reply to this post by Peter Uhnak
Hi Peter,
i assume from your question "RewriteTool maintained?" that you want to make a RBTransformationRule, right? if yes, i once had a similar problem and overwrote only #checkMethod: checkMethod: aMethod | arg | arg := aMethod argumentNames first asString. self initialize. self rewriteRule replace: '| ``@temporaries1 | `.@Statement' with: ('| ``@temporaries1 | {1} blahblah ifTrue: [ ^ {1} adaptToNumber: self andSend: #{2}]. `.@Statement' format: {arg. aMethod selector}). ^ super checkMethod: aMethod not too elegant, but it works. you could strip ":" from the method selector and do something similar. werner On 11/11/2017 05:17 PM, Peter Uhnák wrote: > Hi, > > how can I rewrite a(n instance) variable to a symbol? > > E.g. > > [IN] > something: aSomething > something := aSomething > > [OUT] > something: aSomething > self write: aSomething into: #something > > > I can capute the input just fine... ``@var := ``@arg > but I have no idea how to convert the var into a symbol (or string). > > Thanks, > Peter > |
Thanks Thierry, I'll try it out! re werner: ... the other question was about the tool, because it was a very nice tool to write and tweak rewrite rules On Sat, Nov 11, 2017 at 7:32 PM, werner kassens <[hidden email]> wrote: Hi Peter, |
Free forum by Nabble | Edit this page |