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
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; tim@rowledge.org; http://www.rowledge.org/tim Useful Latin Phrases:- Te precor dulcissime supplex! = Pretty please with a cherry on top!
----- Original Message ----- From: "tim Rowledge" tim@rowledge.org To: "Squeak Virtual Machine Development Discussion" vm-dev@lists.squeakfoundation.org 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
vm-dev@lists.squeakfoundation.org