How to convert a Byte to an integer in VMMaker

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to convert a Byte to an integer in VMMaker

Mathieu SUEN
 
Hi.

I am in VMMaker and I want to convert the current bytecode to the  
corresponding integer.
How could I do that?

For the time being I have write the following instruction:

        self fetchNextBytecode.
        closSize := self positive32BitIntegerFor: currentBytecode.
        self fetchNextBytecode.
        "The following may cause GC!"
        self success: (self sufficientSpaceToInstantiate:  (self splObj:  
ClosureEnvObject) indexableSize: closSize).
        successFlag ifTrue: [
                self storePointer: 4
                        ofObject: activeContext
                        withValue:(self instantiateClass: (self splObj: ClosureEnvObject)  
indexableSize: closSize)]]

But it don't seems to work
Thanks for helping


        Mth



Reply | Threaded
Open this post in threaded view
|

Re: How to convert a Byte to an integer in VMMaker

Klaus D. Witzel

Hi Math,

IIRC #positive32BitIntegerFor: returns a boxed instance of  
LargePositiveInteger and it looks like that is not what you want to pass  
to #sufficientSpaceToInstantiate: and to #instantiateClass:

I suggest to have a look at the implementor of #experimentalBytecode, that  
one reads bytes from the current IP and makes use of them.

/Klaus

On Wed, 15 Aug 2007 14:17:58 +0200, Mathieu Suen wrote:

>  Hi.
>
> I am in VMMaker and I want to convert the current bytecode to the  
> corresponding integer.
> How could I do that?
>
> For the time being I have write the following instruction:
>
> self fetchNextBytecode.
> closSize := self positive32BitIntegerFor: currentBytecode.
> self fetchNextBytecode.
> "The following may cause GC!"
> self success: (self sufficientSpaceToInstantiate:  (self splObj:  
> ClosureEnvObject) indexableSize: closSize).
> successFlag ifTrue: [
> self storePointer: 4
> ofObject: activeContext
> withValue:(self instantiateClass: (self splObj: ClosureEnvObject)  
> indexableSize: closSize)]]
>
> But it don't seems to work
> Thanks for helping
>
>
> Mth
>
>
>