So, I have a SpriteMorph.prototype.blockForSelector("xPosition", true). How do I run it in the context of the sprite being ran in?
I have a Process as this (don't ask) and this Process has a receiver. It's usually a SpriteMorph for me.
So, to make this clearer, I want to execute the BlockMorphSpriteMorph.prototype.blockForSelector("xPosition", true) (yes, I realise this could have custom definition blocks, I'll handle the output from the execution) in the vision of this.receiver.
Process.prototype.evaluateBlock is what usually does it but trying to use it or parts of it in this situation directly is almost certainly a bad idea. if you're getting a block by the selector like that, it could be any primitive and many of those have special handling that changes between snap updates. i assume you don't want your project to break whenever the new thing comes out.
if you want to just get the x position of the sprite in the way the sprite does it regardless of what's in the x position block (which could be anything, and would change what receivers do and don't work with it), then use receiver.xPosition() (where reciever is your sprite).
if you really want to run the block that happens to be called x position but could do anything, you probably want to just make a ring and CALL it. if you need to do this from javascript, do something like:
let ring = this.reifyReporter(block, new List()) // x position block, no parameters
let result = this.evaluate(ring);
EDIT: this.evaluateing the ring didn't work, however using the global invoke function on the ring perfectly works! (ring is a Context object, which is perfect for the invoke function)