[Q] literals of a methods
Tim Olson
tim at io.com
Tue Mar 4 01:31:03 UTC 2003
Alexandre Bergel <bergel at iam.unibe.ch> wrote:
| Hello,
|
| I am wondering why the following expression is false.
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| nil class compile: 'foobar Object new asMorph'.
| (nil class >> #foobar) literals includesAllOf: #(new asMorph)
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
If you browse UndefinedObject>>foobar and view the bytecodes, you will
see:
13 <41> pushLit: Object
14 <CC> send: new
15 <D0> send: asMorph
16 <87> pop
17 <78> returnSelf
If you then look at Interpreter class >> initializeBytecodeTable, you
will find that 16rCC (204) is the bytecode for:
(204 bytecodePrimNew)
sending "new" is common enough that it has its own bytecode, so there is
no need for a literal reference. If you decode the "asMorph" send,
though, you will see 16rD0 (208) translates to
(208 255 sendLiteralSelectorBytecode)
-- tim
More information about the Squeak-dev
mailing list
|