The Trunk: Environments-cwp.28.mcz

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

The Trunk: Environments-cwp.28.mcz

commits-2
Colin Putney uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-cwp.28.mcz

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

Name: Environments-cwp.28
Author: cwp
Time: 26 May 2013, 7:40:34.424 pm
UUID: d20adb01-2cd2-4303-a5d8-fdb68924eb99
Ancestors: Environments-cwp.27

Environment refactoring, part 2 of 3: migrate data to new instance variables, change methods to use the new instance variables.

=============== Diff against Environments-cwp.27 ===============

Item was added:
+ (PackageInfo named: 'Environments') preamble: '"below, add code to be run before the loading of this package"
+
+ Environment allInstancesDo: [:ea | ea migrate].
+ '!

Item was changed:
  ----- Method: Environment>>allClassesAndTraitsDo: (in category 'classes and traits') -----
  allClassesAndTraitsDo: aBlock
+ declarations keysAndValuesDo:
- contents keysAndValuesDo:
  [:key :value |
  ((value isBehavior) and: [key == value name]) ifTrue:
  [aBlock value: value]]!

Item was changed:
  ----- Method: Environment>>associationAt: (in category 'emulating') -----
  associationAt: aSymbol
  "Senders of this should probably be using #bindingOf:"
 
  self flag: #review.
+ ^ declarations associationAt: aSymbol!
- ^ contents associationAt: aSymbol!

Item was changed:
  ----- Method: Environment>>associationAt:ifAbsent: (in category 'emulating') -----
  associationAt: aSymbol ifAbsent: aBlock
  "Senders of this should probably be using #bindingOf:"
 
  self flag: #review.
+ ^ declarations associationAt: aSymbol ifAbsent: aBlock!
- ^ contents associationAt: aSymbol ifAbsent: aBlock!

Item was changed:
  ----- Method: Environment>>associationOrUndeclaredAt: (in category 'emulating') -----
  associationOrUndeclaredAt: key
+ ^ references associationAt: key ifAbsent:
- ^ bindings associationAt: key ifAbsent:
  [undeclared at: key put: nil.
  undeclared associationAt: key]
  !

Item was changed:
  ----- Method: Environment>>at: (in category 'emulating') -----
  at: aSymbol
+ ^ declarations at: aSymbol!
- ^ contents at: aSymbol!

Item was changed:
  ----- Method: Environment>>at:ifAbsent: (in category 'emulating') -----
  at: aSymbol ifAbsent: aBlock
+ ^ declarations at: aSymbol ifAbsent: aBlock!
- ^ contents at: aSymbol ifAbsent: aBlock!

Item was changed:
  ----- Method: Environment>>at:ifAbsentPut: (in category 'emulating') -----
  at: aSymbol ifAbsentPut: aBlock
+ ^ declarations
- ^ contents
  at: aSymbol
  ifAbsentPut: aBlock!

Item was changed:
  ----- Method: Environment>>at:ifPresent: (in category 'emulating') -----
  at: aSymbol ifPresent: aBlock
+ ^ declarations at: aSymbol ifPresent: aBlock!
- ^ contents at: aSymbol ifPresent: aBlock!

Item was changed:
  ----- Method: Environment>>at:ifPresent:ifAbsent: (in category 'emulating') -----
  at: aSymbol ifPresent: presentBlock ifAbsent: absentBlock
+ ^ declarations
- ^ contents
  at: aSymbol
  ifPresent: presentBlock
  ifAbsent: absentBlock.!

Item was changed:
  ----- Method: Environment>>at:ifPresentAndInMemory: (in category 'emulating') -----
  at: key ifPresentAndInMemory: aBlock
+ ^ declarations
- ^ contents
  at: key
  ifPresent:
  [:v |
  v isInMemory ifTrue:
  [aBlock value: v]]!

Item was changed:
  ----- Method: Environment>>at:put: (in category 'emulating') -----
  at: aSymbol put: anObject
  | binding |
+ (declarations includesKey: aSymbol)
+ ifTrue: [declarations at: aSymbol put: anObject]
- (contents includesKey: aSymbol)
- ifTrue: [contents at: aSymbol put: anObject]
  ifFalse:
  [(undeclared includesKey: aSymbol)
  ifTrue:
+ [declarations declare: aSymbol from: undeclared.
+ declarations at: aSymbol put: anObject]
- [contents declare: aSymbol from: undeclared.
- contents at: aSymbol put: anObject]
  ifFalse:
  [binding := aSymbol => anObject.
+ declarations add: binding.
- contents add: binding.
  exports bind: binding]].
  ^ anObject
  !

Item was changed:
  ----- Method: Environment>>bindingOf:ifAbsent: (in category 'binding') -----
  bindingOf: aSymbol ifAbsent: aBlock
+ ^ references associationAt: aSymbol ifAbsent:
- ^ bindings associationAt: aSymbol ifAbsent:
  [(imports bindingOf: aSymbol)
  ifNil: aBlock
+ ifNotNil: [:foreign | references add: (foreign asBinding: aSymbol)]]!
- ifNotNil: [:foreign | bindings add: (foreign asBinding: aSymbol)]]!

Item was changed:
  ----- Method: Environment>>classOrTraitNamed: (in category 'classes and traits') -----
  classOrTraitNamed: aString
  "aString is either a class or trait name or a class or trait name followed by ' class' or 'classTrait' respectively.
  Answer the class or metaclass it names."
 
  | meta baseName |
  (aString endsWith: ' class')
  ifTrue: [meta := true.
  baseName := aString copyFrom: 1 to: aString size - 6]
  ifFalse: [
  (aString endsWith: ' classTrait')
  ifTrue: [
  meta := true.
  baseName := aString copyFrom: 1 to: aString size - 11]
  ifFalse: [
  meta := false.
  baseName := aString]].
 
+ ^declarations at: baseName asSymbol ifPresent:
- ^contents at: baseName asSymbol ifPresent:
  [ :global |
    global isBehavior ifTrue:
  [ meta
  ifFalse: [ global ]
  ifTrue: [ global classSide ]]]!

Item was changed:
  ----- Method: Environment>>do: (in category 'emulating') -----
  do: aBlock
  "Evaluate aBlock for each of the receiver's values."
 
+ declarations valuesDo: aBlock!
- contents valuesDo: aBlock!

Item was changed:
  ----- Method: Environment>>forgetClass:logged: (in category 'classes and traits') -----
  forgetClass: aClass logged: aBool
  aBool ifTrue:
  [SystemChangeNotifier uniqueInstance
  classRemoved: aClass fromCategory: aClass category].
  self organization removeElement: aClass name.
  Smalltalk removeFromStartUpList: aClass.
  Smalltalk removeFromShutDownList: aClass.
 
+ undeclared declare: aClass name from: declarations.
- undeclared declare: aClass name from: contents.
 
  imports forgetName: aClass name.
  exports forgetName: aClass name.
+ declarations removeKey: aClass name ifAbsent: [].
+ references removeKey: aClass name ifAbsent: [].
- contents removeKey: aClass name ifAbsent: [].
- bindings removeKey: aClass name ifAbsent: [].
 
  [undeclared at: aClass name put: nil]
  on: AttemptToWriteReadOnlyGlobal
  do: [:n | n resume: true].
  !

Item was changed:
  ----- Method: Environment>>hasBindingThatBeginsWith: (in category 'binding') -----
  hasBindingThatBeginsWith: aString
+ references associationsDo:
- bindings associationsDo:
  [:ea | (ea key beginsWith: aString) ifTrue: [^ true]].
  ^ false
 
  !

Item was changed:
  ----- Method: Environment>>hasClassNamed: (in category 'classes and traits') -----
  hasClassNamed: aString
  Symbol hasInterned: aString ifTrue:
  [:symbol |
+ ^ (declarations at: symbol ifAbsent: [nil])
- ^ (contents at: symbol ifAbsent: [nil])
  isKindOf: Class].
  ^ false.!

Item was changed:
  ----- Method: Environment>>importSelf (in category 'configuring') -----
  importSelf
+ imports := Import namespace: declarations next: imports.
- imports := Import namespace: contents next: imports.
  self rebindUndeclared!

Item was changed:
  ----- Method: Environment>>includes: (in category 'emulating') -----
  includes: value
+ ^ declarations includes: value!
- ^ contents includes: value!

Item was changed:
  ----- Method: Environment>>includesKey: (in category 'emulating') -----
  includesKey: key
+ ^ declarations includesKey: key!
- ^ contents includesKey: key!

Item was changed:
  ----- Method: Environment>>initialize (in category 'initialize-release') -----
  initialize
+ references := IdentityDictionary new.
+ declarations := IdentityDictionary new.
- bindings := IdentityDictionary new.
- contents := IdentityDictionary new.
  public := IdentityDictionary new.
  undeclared := IdentityDictionary new.
  imports := Import null.
  exports := Export null.
  self importSelf.!

Item was changed:
  ----- Method: Environment>>initializeWithName: (in category 'initialize-release') -----
  initializeWithName: aString
  | smalltalk |
  self initialize.
  info := EnvironmentInfo name: aString.
  .
  smalltalk := SmalltalkImage basicNew.
  smalltalk globals: self.
+ declarations at: #Smalltalk put: smalltalk.
+ declarations at: #Undeclared put: undeclared.!
- contents at: #Smalltalk put: smalltalk.
- contents at: #Undeclared put: undeclared.!

Item was changed:
  ----- Method: Environment>>initializeWithSystemDictionary: (in category 'initialize-release') -----
  initializeWithSystemDictionary: old
 
  self initialize.
  info := EnvironmentInfo
  name: 'Smalltalk'
  organization: old organization
  packages: PackageOrganizer default.
+ old associationsDo: [:assc | declarations add: assc].
- old associationsDo: [:assc | contents add: assc].
  (old at: #Undeclared) associationsDo: [:assc | undeclared add: assc].
+ (declarations at: #Smalltalk) instVarNamed: 'globals' put: self.
+ declarations at: #Undeclared put: undeclared.!
- (contents at: #Smalltalk) instVarNamed: 'globals' put: self.
- contents at: #Undeclared put: undeclared.!

Item was changed:
  ----- Method: Environment>>keyAtIdentityValue: (in category 'emulating') -----
  keyAtIdentityValue: anObject
+ ^ declarations keyAtIdentityValue: anObject.!
- ^ contents keyAtIdentityValue: anObject.!

Item was changed:
  ----- Method: Environment>>keyAtIdentityValue:ifAbsent: (in category 'emulating') -----
  keyAtIdentityValue: anObject ifAbsent: aBlock
+ ^ declarations keyAtIdentityValue: anObject ifAbsent: aBlock!
- ^ contents keyAtIdentityValue: anObject ifAbsent: aBlock!

Item was changed:
  ----- Method: Environment>>keys (in category 'emulating') -----
  keys
+ ^ declarations keys!
- ^ contents keys!

Item was changed:
  ----- Method: Environment>>keysDo: (in category 'emulating') -----
  keysDo: aBlock
  "Evaluate aBlock for each of the receiver's keys."
 
+ declarations keysDo: aBlock!
- contents keysDo: aBlock!

Item was changed:
  ----- Method: Environment>>migrate (in category 'initialize-release') -----
  migrate
+ declarations := declarations.
+ references := references.!
- declarations := contents.
- references := bindings.!

Item was changed:
  ----- Method: Environment>>publicizeContents (in category 'private') -----
  publicizeContents
+ declarations associationsDo: [:binding | exports bind: binding].
- contents associationsDo: [:binding | exports bind: binding].
  !

Item was changed:
  ----- Method: Environment>>rebindUndeclared (in category 'private') -----
  rebindUndeclared
  undeclared keys do:
  [:name |
  (imports valueOf: name) ifNotNil:
  [:v |
+ references declare: name from: undeclared.
+ references at: name put: v]]!
- bindings declare: name from: undeclared.
- bindings at: name put: v]]!

Item was changed:
  ----- Method: Environment>>recompileAll (in category 'operations') -----
  recompileAll
+ references removeAll.
- bindings removeAll.
  self allClassesAndTraits
  do: [:classOrTrait | classOrTrait compileAll]
  displayingProgress:[:classOrTrait| 'Recompiling ', classOrTrait]
 
 
  !

Item was changed:
  ----- Method: Environment>>removeClassNamed: (in category 'classes and traits') -----
  removeClassNamed: aString
+ declarations
- contents
  at: aString asSymbol
  ifPresent: [:class | class removeFromSystem]
  ifAbsent:
  [Transcript cr; show: 'Removal of class named ', aString,
  ' ignored because ', aString, ' does not exist.']!

Item was changed:
  ----- Method: Environment>>removeKey:ifAbsent: (in category 'emulating') -----
  removeKey: key ifAbsent: aBlock
  self flag: #review.
+ ^ declarations removeKey: key ifAbsent: aBlock!
- ^ contents removeKey: key ifAbsent: aBlock!

Item was changed:
  ----- Method: Environment>>renameClass:from:to: (in category 'classes and traits') -----
  renameClass: aClass from: oldName to: newName
  "Rename the class, aClass, to have the title newName."
 
  | oldref category |
  category := self organization categoryOfElement: oldName.
  self organization classify: newName under: category suppressIfDefault: true.
  self organization removeElement: oldName.
  oldref := self associationAt: oldName.
+ declarations removeKey: oldName.
- contents removeKey: oldName.
  oldref key: newName.
+ declarations add: oldref.
- contents add: oldref.
  Smalltalk renamedClass: aClass from: oldName to: newName.
  SystemChangeNotifier uniqueInstance
  classRenamed: aClass
  from: oldName
  to: newName
  inCategory: category!

Item was changed:
  ----- Method: Environment>>renameClassNamed:as: (in category 'classes and traits') -----
  renameClassNamed: oldName as: newName
+ declarations
- contents
  at: oldName
  ifPresent: [:class | class rename: newName]
  ifAbsent:
  [Transcript cr; show: 'Class-rename for ', oldName,
  ' ignored because ', oldName, ' does not exist.']!

Item was changed:
  ----- Method: Environment>>scopeFor:from:envtAndPathIfFound: (in category 'emulating') -----
  scopeFor: aSymbol from: lower envtAndPathIfFound: aBlock
+ ^ (declarations includesKey: aSymbol)
- ^ (contents includesKey: aSymbol)
  ifTrue: [aBlock value: self value: String new]
  !

Item was changed:
  ----- Method: Environment>>select: (in category 'emulating') -----
  select: aBlock
+ ^ declarations select: aBlock!
- ^ contents select: aBlock!

Item was changed:
  ----- Method: Environment>>valueOf:ifAbsent: (in category 'binding') -----
  valueOf: aSymbol ifAbsent: aBlock
+ ^ references at: aSymbol ifAbsent: aBlock!
- ^ bindings at: aSymbol ifAbsent: aBlock!