executing a specified compiled method

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

executing a specified compiled method

Rob Withers
 
I am trying to write a primitive that will execute a compiled method, one of
the arguments.  Does anything nasty jump out at you from this code?


primitiveExecuteCompiledMethodOnReceiverWithArgs

    | argumentArray newReceiver methodToBeExecuted arrayArgumentCount
cntxSize index |
    self export: true.

    self success: (argumentCount = 3).
    successFlag ifFalse: [^ successFlag].
    argumentArray := self popStack.
    newReceiver := self popStack.
    methodToBeExecuted := self popStack.

    self popStack.    "Pop the old receiver"
    self push: newReceiver.  "Push the new receiver"
    receiverClass := lkupClass := self fetchClassOf: newReceiver.
    newMethod := methodToBeExecuted.
    methodClass := receiverClass.
    index := 1.
    [index <= arrayArgumentCount]
        whileTrue:
            [self push: (self fetchPointer: index - 1 ofObject:
argumentArray).
            index := index + 1].
    argumentCount := arrayArgumentCount.

    self executeNewMethod.
    successFlag := true.

It is crashing my vm, when I call it.

many thanks,
Rob

Reply | Threaded
Open this post in threaded view
|

Re: executing a specified compiled method

timrowledge
 

On 1-Nov-07, at 6:52 AM, Rob Withers wrote:

> I am trying to write a primitive that will execute a compiled  
> method, one of the arguments.  Does anything nasty jump out at you  
> from this code?
>
How about using what is already there?
Object>withArgs:executeMethod: and friends.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful Latin Phrases:- Te precor dulcissime supplex! = Pretty please  
with a cherry on top!


Reply | Threaded
Open this post in threaded view
|

Re: executing a specified compiled method

Rob Withers
 

----- Original Message -----
From: "tim Rowledge" <[hidden email]>
To: "Squeak Virtual Machine Development Discussion"
<[hidden email]>
Sent: Thursday, November 01, 2007 8:03 AM
Subject: Re: [Vm-dev] executing a specified compiled method


>
>
> On 1-Nov-07, at 6:52 AM, Rob Withers wrote:
>
>> I am trying to write a primitive that will execute a compiled  method,
>> one of the arguments.  Does anything nasty jump out at you  from this
>> code?
>>
> How about using what is already there?
> Object>withArgs:executeMethod: and friends.

:-D   Squeak never ceases to amaze me.  Thanks, Tim.

Rob