Fixes package/category method change reading jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 02 Aug 2012 21:53:18 +0100
branchjv
changeset 3076 e08f5ff96f75
parent 3075 e65e624f5cb5
child 3077 0bbafcfa19c1
Fixes package/category method change reading
ChangeSet.st
--- a/ChangeSet.st	Wed Aug 01 19:34:07 2012 +0100
+++ b/ChangeSet.st	Thu Aug 02 21:53:18 2012 +0100
@@ -2084,6 +2084,29 @@
     "Modified: / 24-01-2012 / 17:07:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+extractMethodsClassAndSelectorFromReceiver
+    "helper for all changes which are of the form:
+        (className compiledMethodAt:#methodSelector) something: ...
+    "
+
+    (receiver isMessage
+    and:[receiverSelector == #'compiledMethodAt:']) ifFalse:[
+        self error:'unexpected change' mayProceed:true.
+        ^ false.
+    ].
+    className := self classNameOf:receiverReceiver.
+    self assert:className notNil.
+
+"/  nameSpace ~~ Smalltalk ifTrue:[
+"/      className := nameSpace name , '::' , className
+"/  ].
+    methodSelector := (receiver arguments at:1) evaluate.
+    self assert:methodSelector notNil.
+    ^ true.
+
+    "Created: / 27-07-2012 / 21:33:47 / cg"
+!
+
 receiversClassName
     ^ self classNameOf:receiver
 !
@@ -2391,6 +2414,25 @@
     "Created: / 24-01-2012 / 16:52:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+handleMethodPackageChange
+    |change|
+
+    self extractMethodsClassAndSelectorFromReceiver ifFalse:[
+        ^ false.
+    ].
+
+    change := MethodPackageChange new.
+    change 
+        className:className
+        selector:methodSelector
+        package:(arguments at:1) evaluate.
+
+    self addChange:change.
+    ^ true
+
+    "Created: / 27-07-2012 / 21:31:25 / cg"
+!
+
 handleMethodPrivacyChange
     |change|
 
@@ -2453,6 +2495,39 @@
     ^ true
 !
 
+handlePrimitiveChange: sourceOrNil
+    "if sourceOrNil is nil, the def has not been read and must be read from
+     the next chunk. Otherwise, it has been already read as argument."
+
+    |change primSource|
+
+    className := self receiversClassName.
+"/        nameSpace ~~ Smalltalk ifTrue:[
+"/            className := nameSpace name , '::' , className
+"/        ].
+    sourceOrNil notNil ifTrue:[
+        primSource := sourceOrNil
+    ] ifFalse:[
+        inputStream skipSeparators.
+        primSource := inputStream nextChunk.
+    ].
+
+    (selector == #'primitiveDefinitions' or:[ selector == #'primitiveDefinitions:' ]) ifTrue:[
+        change := ClassPrimitiveDefinitionsChange new
+    ] ifFalse:[
+        (selector == #'primitiveFunctions' or:[ selector == #'primitiveFunctions:' ]) ifTrue:[
+            change := ClassPrimitiveFunctionsChange new
+        ] ifFalse:[
+            change := ClassPrimitiveVariablesChange new
+        ]
+    ].
+    change className:className source:primSource.
+    self addChange:change.
+    ^ true
+
+    "Created: / 27-07-2012 / 21:39:55 / cg"
+!
+
 handleRemoveClassChange
     |change|
 
@@ -2683,6 +2758,14 @@
     ^ self handleNameSpaceCreationChange.
 !
 
+process_package_
+    "'package:' chunk (ST/X)"
+
+    ^ self handleMethodPackageChange.
+
+    "Created: / 27-07-2012 / 21:36:30 / cg"
+!
+
 process_primitiveDefinitions
     "'primitiveDefinitions' chunk (ST/X)"
 
@@ -2691,6 +2774,14 @@
     "Modified: / 27-07-2012 / 21:40:33 / cg"
 !
 
+process_primitiveDefinitions_
+    "'primitiveDefinitions:' chunk (ST/X)"
+
+    ^ self handlePrimitiveChange: (arguments at:1) evaluate.
+
+    "Created: / 27-07-2012 / 21:42:03 / cg"
+!
+
 process_primitiveFunctions
     "'primitiveFunctions' chunk (ST/X)"
 
@@ -2699,6 +2790,14 @@
     "Modified: / 27-07-2012 / 21:40:23 / cg"
 !
 
+process_primitiveFunctions_
+    "'primitiveFunctions:' chunk (ST/X)"
+
+    ^ self handlePrimitiveChange: (arguments at:1) evaluate.
+
+    "Created: / 27-07-2012 / 21:37:21 / cg"
+!
+
 process_primitiveVariables
     "'primitiveVariables' chunk (ST/X)"
 
@@ -2707,6 +2806,14 @@
     "Modified: / 27-07-2012 / 21:40:35 / cg"
 !
 
+process_primitiveVariables_
+    "'primitiveVariables:' chunk (ST/X)"
+
+    ^ self handlePrimitiveChange: (arguments at:1) evaluate.
+
+    "Created: / 27-07-2012 / 21:41:49 / cg"
+!
+
 process_privacy_
     "'privacy:' chunk (ST/X)"
 
@@ -3966,7 +4073,7 @@
 !ChangeSet class methodsFor:'documentation'!
 
 version
-    ^ '$Id: ChangeSet.st 1953 2012-08-01 18:34:07Z vranyj1 $'
+    ^ '$Id: ChangeSet.st 1954 2012-08-02 20:53:18Z vranyj1 $'
 !
 
 version_CVS
@@ -3974,5 +4081,5 @@
 !
 
 version_SVN
-    ^ '$Id: ChangeSet.st 1953 2012-08-01 18:34:07Z vranyj1 $'
+    ^ '$Id: ChangeSet.st 1954 2012-08-02 20:53:18Z vranyj1 $'
 ! !