[Pharo-project] Problem with InstructionPrinter?
Hi All, InstructionPrinter printInstructionsOn: doesnt print anything for variable accessor methods. Is this correct and expected? I have a class with an instance variable called 'first' and I have a method called 'first' which simply answers the instance variable. first ^ first When I dump the bytecode for this I get nothing. However, when I add the following to the method the result is as expect, ie: the instance variable is answered. first |x| x := 1. ^ first 13 <76> pushConstant: 1 14 <68> popIntoTemp: 0 15 <00> pushRcvr: 0 16 <7C> returnTop Why is there no bytecode for the simpler case? Rgs, James.
On Tue, 3 Aug 2010, James Ladd wrote:
Hi All,
InstructionPrinter printInstructionsOn: doesnt print anything for variable accessor methods. Is this correct and expected?
I have a class with an instance variable called 'first' and I have a method called 'first' which simply answers the instance variable.
first ^ first
When I dump the bytecode for this I get nothing.
However, when I add the following to the method the result is as expect, ie: the instance variable is answered.
first |x| x := 1. ^ first
13 <76> pushConstant: 1
14 <68> popIntoTemp: 0 15 <00> pushRcvr: 0
16 <7C> returnTop
Why is there no bytecode for the simpler case?
Because there are special primitives for that. Try this: String streamContents: [ :stream | (YourClass >> #first) longPrintOn: stream indent: 0 ]. Levente
Rgs, James.
participants (2)
-
James Ladd -
Levente Uzonyi