Skip to content

Commit

Permalink
Merge pull request #26 from jecisc/fix-method-trailer-change
Browse files Browse the repository at this point in the history
Fix method trailer problem in Pharo 12
  • Loading branch information
tesonep authored Oct 17, 2023
2 parents 5fb90ed + 7f4511b commit 9ce69c5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Hermes/HEInstaller.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -206,32 +206,32 @@ HEInstaller >> messageMethod: aHEMethod alreadyExistsIn: aClass [

{ #category : 'installing methods' }
HEInstaller >> rebuildMethod: aMethod into: aClass [

| newMethod literalSpace extendedEnvironment |

(self shouldBuildMethod: aMethod in: aClass) ifFalse: [ ^ self ].
(self shouldBuildMethod: aMethod in: aClass) ifFalse: [ ^ self ].

extendedEnvironment := HEExtendedEnvironment new.
extendedEnvironment inner: environment.
extendedEnvironment newClass: aClass.
extendedEnvironment newSelector: aMethod name.

newMethod := CompiledMethod newMethod: aMethod bytecode size header: (aMethod headerFor: extendedEnvironment).
self flag: #pharo11. "If Pharo12 the management of the method trailer changed and the way to create a new method changed too."
newMethod := CompiledMethod
newMethod: (SystemVersion current major >= 12
ifTrue: [ aMethod bytecode size + CompiledMethod trailerSize ]
ifFalse: [ aMethod bytecode size ])
header: (aMethod headerFor: extendedEnvironment).

extendedEnvironment newMethod: newMethod.

aMethod literals
doWithIndex:
[ :literal :idx | newMethod literalAt: idx put: (literal asLiteralIn: extendedEnvironment) ].
aMethod literals doWithIndex: [ :literal :idx | newMethod literalAt: idx put: (literal asLiteralIn: extendedEnvironment) ].

newMethod classBinding: aClass binding.
literalSpace := (aMethod literals size + 1) * Smalltalk wordSize.
literalSpace := aMethod literals size + 1 * Smalltalk wordSize.

aMethod bytecode doWithIndex: [ :e :idx | newMethod at: idx + literalSpace put: e ].

aClass
addAndClassifySelector: aMethod name
withMethod: newMethod
inProtocol: aMethod protocol
aClass addAndClassifySelector: aMethod name withMethod: newMethod inProtocol: aMethod protocol
]

{ #category : 'reporting undeclared' }
Expand Down

0 comments on commit 9ce69c5

Please sign in to comment.