[BC][FIX] Re: [BUG] ClosureCompiler
Anthony Hannan
ajh18 at cornell.edu
Wed Feb 5 17:26:18 UTC 2003
Avi Bryant <avi at beta4.com> wrote:
> Try compiling the following method in any class:
>
> foo
> 1 = 1 ifTrue: [2]
>
> I get the error 'positive if jumps only'.
File-in the following method to fix this problem.
Cheers,
Anthony
!JumpIfInstr methodsFor: 'as yet unclassified' stamp: 'ajh 2/5/2003 12:08'!
jumpBytecodes: sequenceOrder
| from to distance continue stream bytes |
from _ sequenceOrder identityIndexOf: owningSequence.
to _ sequenceOrder identityIndexOf: destinationSequence.
from < to ifFalse: [self errorConditionalJumpBackwards].
continue _ sequenceOrder identityIndexOf: otherwiseSequence.
from + 1 = continue ifFalse: [self errorFallThroughSequenceNotNext].
stream _ Compiler bytecodeWriteStream on: (ByteArray new: 4).
to = continue ifTrue: [
"jumps to fall-through branch, condition irrelevant. Eg. x ifTrue: []."
stream popTop.
] ifFalse: [
distance _ (from + 1 to: to - 1) inject: 0 into: [:size :i |
size + (sequenceOrder at: i) bytecodesSize].
stream jump: distance if: jumpCondition.
].
bytes _ stream contents.
localBytecodeRange _ owningSequence bytecodesWithoutJump size + 1
extend: bytes size.
^ bytes
! !
More information about the Squeak-dev
mailing list
|