Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusDenker committed Sep 26, 2019
1 parent 2a43632 commit 2ab8a81
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions src/OpalCompiler-Core/Context.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,10 @@ Context >> isReturnAt: aPC [
^method encoderClass isReturnAt: aPC in: method.
]

{ #category : #'*OpalCompiler-Core' }
Context >> neighborPCWithCorrectMapping [
"Answer a pc inside the enclosing block or mathod that is correctly mapped to an AST node"
"This is an ugly and temporary fix for Pharo 3.
Must be removed as soon as mappings are fixed"
| neighborPC |
neighborPC := self isDead
ifTrue: [ self startpc ]
ifFalse: [ pc ].
"There is a pushLiteral: nil bytecode for each temps in a block.
There is a 'pushTemp:' bytecode for each copied value of a block.
These bytecodes are not mapped to any IR.
We skip both"
[ self isPushLiteralNil: neighborPC ] whileTrue: [ neighborPC := neighborPC + 1 ].
[ self isPushTemp: neighborPC ] whileTrue: [ neighborPC := neighborPC + 1 ].
"The block return ir instruction is mapped to the block instead of the sequence AST node. So we go just before it"
(self isBlockReturn: neighborPC) ifTrue: [ neighborPC := neighborPC - 1 ].
^ neighborPC
]

{ #category : #'*OpalCompiler-Core' }
Context >> sourceNode [
"Return the source node of the method or the block corresponding to the receiver"
^ (method sourceNodeForPC: self neighborPCWithCorrectMapping) enclosingMethodOrBlockNode
"Uncomment the following once the pc->AST mapping is fixed"
"^ (method sourceNodeForPC: (pc ifNil: [ self startpc ])) enclosingMethodOrBlockNode"
"Return the source node of the method or the block of this context"
^ self sourceNodeExecuted enclosingMethodOrBlockNode
]

{ #category : #'*OpalCompiler-Core' }
Expand Down

0 comments on commit 2ab8a81

Please sign in to comment.