help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Current line number


From: Gwenaël Casaccio
Subject: Re: [Help-smalltalk] Current line number
Date: Mon, 21 Oct 2013 10:54:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0

On 19/10/2013 12:47, Holger Hans Peter Freyther wrote:
On Fri, Oct 18, 2013 at 09:21:28AM +0200, Gwenaël Casaccio wrote:

Dear Gwenaël,

      sourceCodeMap [
-       "Answer an array which maps bytecode indices to source code
-        line numbers.  0 values represent invalid instruction
-        pointer indices."
-
-       <category: 'testing accesses'>
-       | map line first |
-       map := ByteArray new: self size.
-       line := 1.
-       first := true.
-       self allByteCodeIndicesDo:
-               [:each :byte :operand |
-               (self class bytecodeInfoTable at: byte * 4 + 4) >= 128
-                   ifTrue:
-                       [first ifFalse: [line := operand].
-                       first := false.
-                       operand > 255 ifTrue: [map := map asArray]].
-               map at: each put: line].
-       ^map
+        "Answer an array which maps bytecode indices to source code
+         line numbers.  0 values represent invalid instruction
+         pointer indices."
+
+        <category: 'testing accesses'>
+        | map line first next |
+        map := ByteArray new: self size.
+        next := -1.
+        line := 1.
+        first := true.
+        self allByteCodeIndicesDo:
+            [ :each :byte :operand |
+                (self class bytecodeInfoTable at: byte * 4 + 4) >= 128
+                    ifTrue:
+                        [ first ifFalse: [ next := operand ].
+                          first := false.
+                          operand > 255 ifTrue: [ map := map asArray ] ].
+                map at: each put: line.
+                next = -1 ifFalse: [ line := next.
+                                     next := -1. ] ].
+        ^ map
I hope you agree that this is very difficult to read to actually find the
few lines that have changed. It would be nice if you could continue to use
tabs in sourcecode that is already using tabs or separate the part that is
changing the code to spaces from the semantic change.


I agree and will do that the next time!

+        res := self method sourceCodeMap at: self ip + 1.
+        ^ res = 0 ifTrue: [ self error: 'IP is not correct' ]
For text messages it is always nice to have the actual number inside.
E.g. IP(%1) is not correct. I am merging the patch like this right now
but I would be happy to receive a follow up patch.

thanks!

        holger

Gwen

Attachment: 0001-Print-IP-value-in-the-error-message.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]