So, as i understood , a code like:
someMethod
| temp1 temp2 |
^ self send: temp1+temp2 with: temp2.
could be represented by following: (we need 5 temps on stack: )
1. temp1 2. temp2 3. receiver 4. - first arg for send 5. - second arg
bytecode:
1.storeSelf: 3 2. storeTemp: 1 to: 4 3. storeTemp: 2 to: 5 4. send #+ to: 4 5. storeTemp: 2 to: 5 6. send #send:with: to: 3 7. return: 3 Exactly. You will probably need to say how many arguments you want to pass to +, for validation purposes. And yes, as you automatically did, you would get the return value back as the location of the first argument. This has as an advantage that a "return self" does not not to do anything at all; it was already the first "argument" of the send anyway.
There are even more optimizations that could be done; such as knowing that the receiver is actually at location -1 if this is in the context of the method; thus not even needing to copy any values ... You could just apply the first send in 2, and the second one in -1 :) But obviously in that case I expect a lot of knowledge of what you do, and this might not always be possible. cheers, Toon