Skip to content

Commit

Permalink
Added proxified selector to the hidden selector to fake the selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanmontt committed Oct 19, 2024
1 parent 50923dd commit 56c1a23
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/MethodProxies/MpHiddenSelector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,46 @@ I'm not a string, so I cannot be typed, avoiding potential conflicts.
I'm used as key of the original method wrapped by proxies, to ensure this wrapped method can be called using myself as selector.
Check my usages during proxy installation.
As a put myself instead of the selector of the roxy method, I now the selector of the proxified method. I need this as someone mmay ask for the selector of the method, for example the code completion engine.
"
Class {
#name : 'MpHiddenSelector',
#superclass : 'Object',
#instVars : [
'proxifiedSelector'
],
#category : 'MethodProxies',
#package : 'MethodProxies'
}

{ #category : 'faking selector' }
MpHiddenSelector >> asSymbol [

^ self proxifiedSelector
]

{ #category : 'faking selector' }
MpHiddenSelector >> beginsWith: aString [

^ proxifiedSelector beginsWith: aString
]

{ #category : 'private' }
MpHiddenSelector >> flushCache [
"Tell the virtual machine to remove all entries with this symbol as a selector from its method lookup caches, if it has any. This must be done whenever a method is added, redefined or removed, so that message lookups reflect the revised organization. c.f. Behavior>>flushCache & CompiledMethod>>flushCache. Essential. See MethodDictionary class comment."

<primitive: 119>
]

{ #category : 'faking selector' }
MpHiddenSelector >> proxifiedSelector [

^ proxifiedSelector
]

{ #category : 'faking selector' }
MpHiddenSelector >> proxifiedSelector: anObject [

proxifiedSelector := anObject
]
4 changes: 3 additions & 1 deletion src/MethodProxies/MpMethodProxy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,9 @@ MpMethodProxy >> install [
newTrap selector: proxifiedMethod selector.
newTrap methodClass: proxifiedMethod methodClass.

hiddenSelector := MpHiddenSelector new.
hiddenSelector := MpHiddenSelector new
proxifiedSelector: proxifiedMethod selector;
yourself.

index := newTrap literals indexOf: trapSelector.
newTrap literalAt: index put: hiddenSelector.
Expand Down

0 comments on commit 56c1a23

Please sign in to comment.