Method.st
changeset 14251 c0d549a59039
parent 14237 2e7bbfbda700
child 14253 28ef0472cf2f
equal deleted inserted replaced
14250:6ac82bdbffbc 14251:c0d549a59039
  2986     ].
  2986     ].
  2987     ^ parser primitiveResources.
  2987     ^ parser primitiveResources.
  2988 !
  2988 !
  2989 
  2989 
  2990 previousVersion
  2990 previousVersion
  2991     "return the receivers previous versions source code"
  2991     "return the receivers previous version's source code"
  2992 
  2992 
  2993     |sel cls previous|
  2993     |previous|
  2994 
  2994 
  2995     sel := self selector.
  2995     previous := self previousVersions:2.
  2996     sel isNil ifTrue:[ ^ nil ].
  2996     previous isEmptyOrNil ifTrue:[^ nil].
  2997 
  2997     ^ previous first.
  2998     cls := self mclass.
  2998 
  2999     cls isNil ifTrue:[ ^ nil ].
  2999 "/    |sel cls previous|
  3000 
  3000 "/
  3001     ChangeSet current reverseDo:[:change |
  3001 "/    sel := self selector.
  3002         (change isMethodChange
  3002 "/    sel isNil ifTrue:[ ^ nil ].
  3003         and:[ (change selector == sel)
  3003 "/
  3004         and:[ change changeClass == cls ]])
  3004 "/    cls := self mclass.
  3005         ifTrue:[
  3005 "/    cls isNil ifTrue:[ ^ nil ].
  3006             previous := change previousVersion.
  3006 "/
  3007             previous notNil ifTrue:[
  3007 "/    ChangeSet current reverseDo:[:change |
  3008                 ^ previous
  3008 "/        (change isMethodChange
  3009             ]
  3009 "/            and:[ (change selector == sel)
  3010         ]
  3010 "/            and:[ change changeClass == cls ]])
  3011     ].
  3011 "/        ifTrue:[
  3012     ^ nil.
  3012 "/            previous := change previousVersion.
       
  3013 "/            previous notNil ifTrue:[
       
  3014 "/                ^ previous
       
  3015 "/            ]
       
  3016 "/        ]
       
  3017 "/    ].
       
  3018 "/    ^ nil.
  3013 
  3019 
  3014 "/    history := Class methodHistory.
  3020 "/    history := Class methodHistory.
  3015 "/    history isNil ifTrue:[^ nil].
  3021 "/    history isNil ifTrue:[^ nil].
  3016 "/
  3022 "/
  3017 "/    entry := history detect:[:entry | |type old new|
  3023 "/    entry := history detect:[:entry | |type old new|
  3027 "/                     ifNone:nil.
  3033 "/                     ifNone:nil.
  3028 "/    entry isNil ifTrue:[^nil].
  3034 "/    entry isNil ifTrue:[^nil].
  3029 "/    ^ entry second.
  3035 "/    ^ entry second.
  3030 "/    ^ history at:self ifAbsent:nil
  3036 "/    ^ history at:self ifAbsent:nil
  3031 
  3037 
  3032     "Modified: 7.11.1996 / 19:06:22 / cg"
  3038     "Modified: / 26-07-2012 / 13:16:34 / cg"
  3033 !
  3039 !
  3034 
  3040 
  3035 previousVersionCode
  3041 previousVersionCode
  3036     "return the receivers previous versions source code"
  3042     "return the receivers previous versions source code"
  3037 
  3043 
  3042 
  3048 
  3043     ^ previous source
  3049     ^ previous source
  3044 !
  3050 !
  3045 
  3051 
  3046 previousVersions
  3052 previousVersions
  3047     "return a collection of the receivers previous versions (sources)"
  3053     "return a collection of the receiver's previous versions (sources)"
       
  3054 
       
  3055     ^ self previousVersions:nil
       
  3056 
       
  3057     "Modified (comment): / 26-07-2012 / 12:04:15 / cg"
       
  3058 !
       
  3059 
       
  3060 previousVersions:count
       
  3061     "return a collection of the receiver's count previous versions (sources).
       
  3062      A nil count will retrieve all versions"
  3048 
  3063 
  3049     |sel cls versions lastChange firstSrc last|
  3064     |sel cls versions lastChange firstSrc last|
  3050 
  3065 
  3051     sel := self selector.
  3066     sel := self selector.
  3052     sel isNil ifTrue:[^ #()].
  3067     sel isNil ifTrue:[^ #()].
  3055     cls isNil ifTrue:[^ #()].
  3070     cls isNil ifTrue:[^ #()].
  3056 
  3071 
  3057     versions := OrderedCollection new.
  3072     versions := OrderedCollection new.
  3058 
  3073 
  3059     ChangeSet current reverseDo:[:change |
  3074     ChangeSet current reverseDo:[:change |
  3060          (change isMethodChange
  3075         (change isMethodChange
  3061         and:[ (change selector == sel)
  3076             and:[ (change selector == sel)
  3062         and:[ change changeClass == cls ]])
  3077             and:[ change changeClass == cls ]])
  3063         ifTrue:[
  3078         ifTrue:[
  3064             versions addFirst:change.
  3079             versions addFirst:change.
  3065             lastChange := change.
  3080             lastChange := change.
       
  3081             (count notNil and:[versions size == count]) ifTrue:[
       
  3082                 ^ versions
       
  3083             ]
  3066         ]
  3084         ]
  3067     ].
  3085     ].
  3068 
  3086 
  3069     lastChange notNil ifTrue:[
  3087     lastChange notNil ifTrue:[
  3070         last := lastChange previousVersion.
  3088         last := lastChange previousVersion.
  3079                                     category:lastChange category).
  3097                                     category:lastChange category).
  3080             ]
  3098             ]
  3081         ]
  3099         ]
  3082     ].
  3100     ].
  3083     ^ versions
  3101     ^ versions
       
  3102 
       
  3103     "
       
  3104      (Method compiledMethodAt:#previousVersions:) previousVersions:nil
       
  3105     "
       
  3106 
       
  3107     "Created: / 26-07-2012 / 11:59:57 / cg"
  3084 !
  3108 !
  3085 
  3109 
  3086 readsField:instVarIndex
  3110 readsField:instVarIndex
  3087     "return true, if the instvar at instVarIndex is read by the receiver.
  3111     "return true, if the instvar at instVarIndex is read by the receiver.
  3088      Uses parser (for now); could look at bytecode as well here..."
  3112      Uses parser (for now); could look at bytecode as well here..."
  3663 ! !
  3687 ! !
  3664 
  3688 
  3665 !Method class methodsFor:'documentation'!
  3689 !Method class methodsFor:'documentation'!
  3666 
  3690 
  3667 version
  3691 version
  3668     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.388 2012-07-23 09:17:47 cg Exp $'
  3692     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.389 2012-07-26 11:21:51 cg Exp $'
  3669 !
  3693 !
  3670 
  3694 
  3671 version_CVS
  3695 version_CVS
  3672     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.388 2012-07-23 09:17:47 cg Exp $'
  3696     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.389 2012-07-26 11:21:51 cg Exp $'
  3673 !
  3697 !
  3674 
  3698 
  3675 version_SVN
  3699 version_SVN
  3676     ^ '§ Id: Method.st 10648 2011-06-23 15:55:10Z vranyj1 §'
  3700     ^ '§ Id: Method.st 10648 2011-06-23 15:55:10Z vranyj1 §'
  3677 ! !
  3701 ! !