LargePositiveInteger into a plugin

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

LargePositiveInteger into a plugin

Luca Bruno aka Lethalman
Hello,
i've a SmartSyntaxInterpreterPlugin with this method:

primitiveName
        self primitive: 'primitiveName' parameters: #(SmallInteger)

But i need to pass a LargePositiveInteger not a SmallInteger, i really  
don't know how to do it. If i put parameters: #(LargePositiveInteger) i  
think it's not the right way since the primitive fails.
Any suggestion?

Thanks.

--
www.lethalman.net - Thoughts about internet technologies

Reply | Threaded
Open this post in threaded view
|

Re: LargePositiveInteger into a plugin

johnmci
We do this all the time for the file system since it supports 64 bit  
pointers.
Mind does the operating system file system support 64 bit offsets,  
but that is a different question.

Trick is to pass the oop as an oops, then convert to a longlong  or  
long as needed.

longlongThing := interpreterProxy  signed64BitValueOf: oop

on return convert the longlong to an oops

oop := interpreterProxy positive64BitIntegerFor: size
or if it's a long
oop = interpreterProxy positive32BitIntegerFor: size

beware that asking for a positive64BitIntegerFor: might cause a VM  
memory allocation and swizzle earlier allocated oops, if you don't
understand that please review usage's of pushRemappableOop:/
popRemappableOop: to understand the dangers.

Note there is signed converters too

signed64BitIntegerFor:

Lastly I'm sure I recall earlier this year someone pointed out  
converting a large negative integer did the wrong thing, so which VM  
you use
and when it was compiled with which version of VMMaker may play a  
role here.

I recall having a hand in writing the original code, but my Sunits  
for checking the passing of longlong to the file system only
considered positive integers, thus missing the conversion error for  
negative longlong.



On 9-Aug-06, at 1:41 PM, Bruno Luca wrote:

> Hello,
> i've a SmartSyntaxInterpreterPlugin with this method:
>
> primitiveName
> self primitive: 'primitiveName' parameters: #(SmallInteger)
>
> But i need to pass a LargePositiveInteger not a SmallInteger, i  
> really don't know how to do it. If i put parameters: #
> (LargePositiveInteger) i think it's not the right way since the  
> primitive fails.
> Any suggestion?
>
> Thanks.
>
> --
> www.lethalman.net - Thoughts about internet technologies
>

--
========================================================================
===
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===