Saving morphs to file
Marcus Denker
denker at iam.unibe.ch
Tue Jul 18 08:50:54 UTC 2006
On 18.07.2006, at 06:11, Chris Muller wrote:
What I personally don't like is that blocks in Squeak mix the static
with the dynamic.
For methods, we have the static (dead) description of a method:
CompiledMethod.
When it is run, a MethodContext is allocated. For blocks, we only
have the
dynamic structure: BlockContext, even for the static structure of "a
Block".
This is much nicer done in Anthony's design of blocks for the
ClosureCompiler.
Marcus
> BlockContextStorage captures nargs, startpc, and home (a
> MethodContextStorage). MethodContextStorage captures the 'method' (a
> CompiledMethodStorage). CompiledMethodStorage captures 'header
> literals startPc endPc byteCodes sourcePointer className'.
> Restoration
> works backward, first the CompiledMethod:
>
> asCompiledMethod
> | answer |
> answer _
> CompiledMethod
> newMethod: endPc - startPc + 1 + 4
> header: header.
> literals withIndexDo:
> [ : each : index |
> answer
> literalAt: index
> put: each ].
> " answer setSourcePointer: sourcePointer." "<-- don't restore it, it
> could be wrong."
> "In fact..."
> sourcePointer > 0 ifTrue: [ answer zapSourcePointer ].
> answer
> replaceFrom: startPc
> to: endPc
> with: byteCodes
> startingAt: 1.
> self restoreLiterals: answer.
> ^ answer
>
> then the MethodContext:
>
> asMethodContext
> | cm |
> ^ (MethodContext newForMethod: (cm _ method asCompiledMethod))
> privRefreshWith: cm ;
> yourself
>
> and, finally, the BlockContext:
>
> asBlockContext
> | methodContext |
> methodContext _ home asMethodContext.
> ^ (BlockContext newForMethod: methodContext method)
> home: methodContext
> startpc: startpc
> nargs: nargs
>
> Whew! Sorry for this deluge, but if anyone has any suggestions for
> improving this I would be grateful.
>
> - Chris
>
>
>
> --- Andreas Raab <andreas.raab at gmx.de> wrote:
>
>> Chris Muller wrote:
>>> Hi Noury, if you are in 3.7 or 3.8 you can use Magma to transfer a
>>> project containing Connected Morphs to another image. Blocks and
>>> CompiledMethods are no problem.
>>
>> Out of curiosity, how does Magma deal with a situation where you
>> serialize a block referring to an iVar and the shape of that class
>> changes? Can you detect it?
>>
>> Cheers,
>> - Andreas
>>
>>
>>
>
>
More information about the Squeak-dev
mailing list
|