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: Holger Hans Peter Freyther
Subject: Re: [Help-smalltalk] Current line number
Date: Sat, 19 Oct 2013 12:47:59 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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.


> +        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



reply via email to

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