The Trunk: Compiler-eem.452.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compiler-eem.452.mcz

commits-2
Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.452.mcz

==================== Summary ====================

Name: Compiler-eem.452
Author: eem
Time: 2 December 2020, 9:41:04.063795 pm
UUID: 4799ba54-ed87-4188-a653-e36499d92994
Ancestors: Compiler-eem.451

Provide an acceptably accurate means to test if a SYmbol is probably a message selector, Scanner class>>isMessageSelector:.

=============== Diff against Compiler-eem.451 ===============

Item was added:
+ ----- Method: Scanner class>>isMessageSelector: (in category 'testing') -----
+ isMessageSelector: aSymbol
+ "Answer if the argument is a valid message selector.
+ This is optimized for fast filtering."
+ | first last sz type |
+ (sz := aSymbol size) = 0 ifTrue: [^false].
+ first := aSymbol at: 1.
+ last := aSymbol at: sz.
+ type := TypeTable at: first asciiValue.
+
+ type == #xLetter ifTrue:
+ ["Alas some people (myself included) do create selectors with an initial capital.
+  But this is unusual, and it is even rarer for these to be unary selectors, so I think
+  it is better to exclude class names than include the few exceptions."
+ (first isUppercase and: [last ~~ $:]) ifTrue:
+ [^false].
+ "Could be unary or keyword, may include underscores if AllowUnderscoreSelectors.
+  It is possible to be more agressive here, filtering out two successive colons, but I'm lazy"
+ ^aSymbol allSatisfy: (AllowUnderscoreSelectors
+ ifTrue:
+ [last == $:
+ ifTrue: [[:c| c == $: or: [c == $_ or: [c isAlphaNumeric]]]]
+ ifFalse: [[:c| c ~~ $: and: [c == $_ or: [c isAlphaNumeric]]]]]
+ ifFalse:
+ [last == $:
+ ifTrue: [[:c| c == $: or: [c isAlphaNumeric]]]
+ ifFalse: [[:c| c ~~ $: and: [c isAlphaNumeric]]]])].
+
+ type == #xBinary ifTrue:
+ [^aSymbol allSatisfy: [:c| c == $| or: [(TypeTable at: c asciiValue) == #xBinary]]].
+
+ ^type == #xUnderscore
+ and: [AllowUnderscoreSelectors
+ and: [self isMessageSelector: aSymbol allButFirst]]
+
+ "| implemented |
+ implemented := Set new.
+ self systemNavigation allSelect: [:m| implemented add: m selector. false].
+ ^Symbol allSubInstances select: [:s| (implemented includes: s) not and: [self isMessageSelector: s]]"
+
+ "| implemented |
+ implemented := Set new.
+ self systemNavigation allSelect: [:m| implemented add: m selector. false].
+ ^implemented reject: [:s| self isMessageSelector: s]"!