<br><br><div class="gmail_quote">On Sun, Apr 15, 2012 at 1:22 AM, Guillermo Polito <span dir="ltr"><<a href="mailto:guillermopolito@gmail.com">guillermopolito@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
b := [ |a| a:=2 ].<br>b asContext tempNames -> #('a')<br>b asContext tempNamed: 'a' -> Boom in MethodContext>>#tempAt: primitive<br><br>tempAt: in Method context uses <primitive: 210>, which is failing. Maybe there is a new primitive we are not aware of for Blocks...</blockquote>
<div><br></div><div>No, 210 is what is needed. The issue is my implementation of temporary initialization in blocks, which simply uses pushNil to allocate and initialize each temp. So if one inspects [|a|a:=2] and sends it self method symbolic you get:</div>
<div><br></div><div><div>13 <8F 00 00 05> closureNumCopied: 0 numArgs: 0 bytes 17 to 21</div><div>17 <span class="Apple-tab-span" style="white-space:pre">        </span><73> pushConstant: nil</div><div>18 <span class="Apple-tab-span" style="white-space:pre">        </span><77> pushConstant: 2</div>
<div>19 <span class="Apple-tab-span" style="white-space:pre">        </span><81 40> storeIntoTemp: 0</div><div>21 <span class="Apple-tab-span" style="white-space:pre">        </span><7D> blockReturn</div><div>22 <7C> returnTop</div>
</div><div><br></div><div>And when you say self asContext pc you get 17, which is *before* the nil is pushed. So you'll want to modify tempNamed: to compare the index of the temporary with the stack pointer and answer nil if the index is beyond the stack pointer.</div>
<div><br></div><div>The same bug exists in Squeak, e.g. the below gave an error until I fixed DebuggerMethodMap>>namedTempAt:in:</div><div><br></div><div><div><br></div><div>| b |</div><div>b := [ |a| a:=2 ].</div><div>
{ b asContext tempNames. b method debuggerMap tempsAndValuesForContext: b asContext }</div><div>#(#('b' 'a') 'b: <span class="Apple-tab-span" style="white-space:pre">        </span>[closure] in UndefinedObject>>DoIt</div>
<div>a: <span class="Apple-tab-span" style="white-space:pre">        </span>nil</div><div>')</div></div><div><br></div><div><br></div><div>Why did I use pushNil to allocate temps? It was not a good choice; it means for example that to determine how many temps a block has one has to parse all the bytecodes and see where the stack pointer is at the end (since initial pushNils are ambiguous; an initial pushNil might be producing a parameter or result or initializing a temp). But not using pushNil would have meant a more complex bytecode for closure creation plus another inst var in BlockClosure. I made another similar misstep in not storing the method in a BlockClosure, hence preventing simple implementation of clean blocks (one needs to synthesize an outerContext also). We live and learn.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br><div class="gmail_quote">On Sat, Apr 14, 2012 at 1:09 PM, Stéphane Ducasse <span dir="ltr"><<a href="mailto:stephane.ducasse@inria.fr" target="_blank">stephane.ducasse@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm taking some times to go back the block closure chapter and I was wondering how I can get access to block temporaries<br>
<br>
[ |a | a :=2. a]<br>
<br>
for example I tried<br>
<br>
[ |a | a :=2. a]<br>
<br>
outerContext contextForLocalVariables tempAt: 1 and variations but none worked.<br>
<br>
Stef<br>
<br>
<br>
<br>
</blockquote></div><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>