Smalltalk type inference: implemented heuristics based on naming convention
e.g., `aString` denotes a parameter of type `String`.
--- a/SmallSense__SmalltalkInferencer.st Sun May 28 21:14:55 2017 +0100
+++ b/SmallSense__SmalltalkInferencer.st Fri Jul 07 11:29:55 2017 +0200
@@ -223,12 +223,13 @@
infer
Phase1 process:tree in:class manager:manager.
Phase2 process:tree in:class manager:manager.
+ Phase3 process:tree in:class manager:manager.
"
(SmallSenseParseNodeInspector new node: tree source: source) open"
"Created: / 26-11-2011 / 12:51:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 21-08-2015 / 15:45:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 06-07-2017 / 16:21:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
parse
@@ -710,6 +711,31 @@
"
! !
+!SmalltalkInferencer::Phase3 methodsFor:'visiting'!
+
+visitVariableNode:anObject
+ | name className |
+
+ name := anObject name.
+ (name size > 1 and:[name first == $a]) ifTrue:[
+ (name second == $n and:[ name third isUppercase ]) ifTrue:[
+ className := (name copyFrom: 3) asSymbolIfInterned.
+ ] ifFalse:[ name second isUppercase ifTrue:[
+ className := (name copyFrom: 2) asSymbolIfInterned.
+ ]].
+ className notNil ifTrue:[
+ | cls |
+ cls := Smalltalk at: className.
+ cls notNil ifTrue:[
+ anObject inferedType type: (Type withClass: cls) type
+ ].
+ ].
+
+ ].
+
+ "Created: / 06-07-2017 / 16:15:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!SmalltalkInferencer class methodsFor:'documentation'!
version_HG