From 56c1a235844508800a23568f29dc199c0aaccdd1 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Sat, 19 Oct 2024 12:33:45 +0200 Subject: [PATCH] Added proxified selector to the hidden selector to fake the selector. --- src/MethodProxies/MpHiddenSelector.class.st | 29 +++++++++++++++++++++ src/MethodProxies/MpMethodProxy.class.st | 4 ++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/MethodProxies/MpHiddenSelector.class.st b/src/MethodProxies/MpHiddenSelector.class.st index 9664131..23a25c3 100644 --- a/src/MethodProxies/MpHiddenSelector.class.st +++ b/src/MethodProxies/MpHiddenSelector.class.st @@ -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." ] + +{ #category : 'faking selector' } +MpHiddenSelector >> proxifiedSelector [ + + ^ proxifiedSelector +] + +{ #category : 'faking selector' } +MpHiddenSelector >> proxifiedSelector: anObject [ + + proxifiedSelector := anObject +] diff --git a/src/MethodProxies/MpMethodProxy.class.st b/src/MethodProxies/MpMethodProxy.class.st index 4449150..e29cca2 100644 --- a/src/MethodProxies/MpMethodProxy.class.st +++ b/src/MethodProxies/MpMethodProxy.class.st @@ -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.