Hi guys, I am new in this list.I have a question related to the sourceRanges 
dictionary in Encoder class. I can see every compiled method has each 
corresponding methodNode, which is an instance of a ParseNode child class. 
Every methodNode is formed by different parts represented by other classes also 
children of ParseNode, like AssignmentNode or MessageNode. when you decompile 
the method into the MethodNode, the Encoder instance saves the intervals 
corresponding to each of these parts. It not saves all the parts, just the 
AssignmentNode, MessageNode and ReturnNode. (other intervals like the ones 
corresponding to TempVariableNodes for instance are not saved). The weird thing 
is that it saves the intervals for the MessageNodes but for some reason they do 
not corresponds to the positions in the sourceText method (property of 
MethodNode). I read that this sourceRanges is used for debugging purposes, and 
I hadn't issues debugging my code. I do not know if it is a bug or I do not 
understand well the Parser class.I am using Pharo 2.0 and this code is also in 
squeak and cuis versions as well.Example:
I have created an example class with the following 
method:ExampleClass>>#method1:method1        | a |   a := 1 + (2 * 3).       ^ a
--- So if i inspect the rawSourceRanges:.. (ExampleClass>>#method1) methodNode 
rawSourceRanges, I have a dictionary with the following keys:    a := 1 + (2 * 
3). (AssignmentNode) --> 19 to 30 (so if i extract the characters from 19 to 30 
in the sourceText I obtain the AssignmentNode text)        1 + (2 * 3) 
(MessageNode) --> 24 to 30        2 * 3 - (MessageNode) --> 28 to 29 ( it is 
not logic to have an interval for 2 characters if 2*3 (without spaces) has 3 
characters.        ^ a  (ReturnNode) --> 34 to 35.

So the ASsignmentNode and ReturnNode have their corresponding sourceText 
interval but from MessageNodes, I cannot see the same. Can anyone of you 
explain me why or if it is a bug? If you would like to watch a little more, the 
sourceRanges is filled in the Encoder class, when the Parser is parsing a 
method.
thanks


                                          

Reply via email to