modification of ContextPart?

Klaus D. Witzel klaus.witzel at cobss.com
Sat Nov 12 21:23:54 UTC 2005


Sure, your change to Parser>>#method:context:encoder: has the same result  
(at another position) as I mentioned in "I think one must recompile for to  
be sure and, that there is most likely no other approach for safely  
increasing nTemps by one more than a source method declares" with which I  
meant to emphasize "must recompile".

Both solutions only have to take care of BlockNode>>#isQuick for to be  
general and for not making false assumptions on what is wanted in the  
resulting CompiledMethod.

/Klaus

On Sat, 12 Nov 2005 22:00:47 +0100, Andreas Raab <andreas.raab at gmx.de>  
wrote:

> Klaus D. Witzel wrote:
>> after increasing nTemps of a CompiledMethod by 1, you wouldn't be able  
>> to  see that you have already done so (in case you  
>> change+run+change+run  incrementally, I mean) and soon run out of temp  
>> space :(
>
> Oh, yes, you absolutely can, because you'd always use "number of temps  
> described by source code + 1" instead of "number of temps in existing  
> method + 1" (where the former is constant).
>
> However, there is an even simpler solution which is why not just  
> allocate an extra temp that is never used? E.g., in  
> Parser>>method:context:encoder: all it takes is to do something like:
>
>    "Parse method header"
>    sap := self pattern: doit inContext: ctxt.
>    "sap={selector, arguments, precedence}"
>    (sap at: 2) do: [:argNode | argNode isArg: true].
>    "Parse temps"
>    temps := self temporariesIn: (sap at: 1).
>
> and change this to
>
>    "Parse method header"
>    sap := self pattern: doit inContext: ctxt.
>    "sap={selector, arguments, precedence}"
>    (sap at: 2) do: [:argNode | argNode isArg: true].
>    "--> Add invisible temp <--"
>    (encoder bindTemp: 'invisiTemp') nowHasDef nowHasRef.
>    "Parse temps"
>    temps := self temporariesIn: (sap at: 1).
>
>
> (the call to nowHasDef nowHasRef is just to shut up the parser). Once  
> you've recompiled the entire system (Smalltalk allClassesDo:[:cls| cls  
> compileAll]) you can access this variable as:
>
> MethodContext>>invisiTemp
>    "Answer the receiver's invisiTemp"
>    ^self tempAt: self method numArgs+1
>
> MethodContext>>invisiTemp: anObject
>    "Set the receiver's invisiTemp"
>    ^self tempAt: self method numArgs+1 put: anObject
>
> Cheers,
>    - Andreas
>
>





More information about the Squeak-dev mailing list