'From Pharo3.0 of 18 March 2013 [Latest update: #30258] on 9 July 2013 at 2:37:45 pm'! !TClassDescription methodsFor: 'accessing parallel hierarchy' stamp: 'SebastianTleye 7/9/2013 14:29'! theMetaClass ^self explicitRequirement.! ! !TClassDescription methodsFor: 'accessing parallel hierarchy' stamp: 'SebastianTleye 7/9/2013 14:30'! theNonMetaClass ^self explicitRequirement.! ! !TClassDescription methodsFor: 'accessing parallel hierarchy' stamp: 'SebastianTleye 7/9/2013 14:29'! theMetaClass ^self explicitRequirement.! ! !TClassDescription methodsFor: 'accessing parallel hierarchy' stamp: 'SebastianTleye 7/9/2013 14:30'! theNonMetaClass ^self explicitRequirement.! ! !TPureBehavior methodsFor: 'accessing class hierarchy' stamp: 'SebastianTleye 7/5/2013 12:47'! withAllSubclassesDo: aBlock "Evaluate the argument, aBlock, for the receiver and each of its subclasses." self withAllSubclasses do: [ :subclass | aBlock value: subclass ].! ! !TPureBehavior methodsFor: 'accessing class hierarchy' stamp: 'SebastianTleye 7/5/2013 12:52'! withAllSubclasses "Answer a Set of the receiver, the receiver's descendent's, and the receiver's descendent's subclasses." ^ self allSubclasses add: self; yourself! ! !TPureBehavior methodsFor: 'accessing method dictionary' stamp: 'SebastianTleye 7/5/2013 15:59'! selectorsWithArgs: numberOfArgs "Return all selectors defined in this class that take this number of arguments" ^ self selectors select: [:selector | selector numArgs = numberOfArgs]! ! !TPureBehavior methodsFor: 'adding/removing methods' stamp: 'SebastianTleye 7/5/2013 11:18'! basicRemoveSelector: selector "Assuming that the argument, selector (a Symbol), is a message selector in my method dictionary, remove it and its method." | oldMethod | oldMethod := self methodDict at: selector ifAbsent: [^ self]. self methodDict removeKey: selector. "Now flush the method cache" oldMethod flushCache. selector flushCache.! ! !TPureBehavior methodsFor: 'testing method dictionary' stamp: 'SebastianTleye 7/5/2013 17:02'! thoroughWhichSelectorsReferTo: literal special: specialFlag byte: specialByte "Answer a set of selectors whose methods access the argument as a literal. Dives into the compact literal notation, making it slow but thorough " | selectors | selectors := IdentitySet new. self selectorsAndMethodsDo: [ :sel :method | ((self isTrait ifTrue: [method hasLiteralThorough: literal] ifFalse: [method refersToLiteral: literal]) or: [specialFlag and: [method scanFor: specialByte]]) ifTrue: [selectors add: sel]]. ^ selectors! ! !TPureBehavior methodsFor: 'traits' stamp: 'SebastianTleye 7/5/2013 10:25'! addTraitSelector: aSymbol withMethod: aCompiledMethod "Add aMethod with selector aSymbol to my methodDict. aMethod must not be defined locally." | source method | [(self includesLocalSelector: aSymbol) not] assert. self ensureLocalSelectors. source := aCompiledMethod getSourceReplacingSelectorWith: aSymbol. method := self compile: source classified: aCompiledMethod category notifying: nil trailer: self defaultMethodTrailer ifFail: [ ^nil ]. method putSource: source inFile: 2 withPreamble: [:f | f cr; nextPut: $!!; nextChunkPut: 'Trait method'; cr]. self isTrait ifFalse: [ method properties at: #traitSource put: aCompiledMethod]. self basicAddSelector: aSymbol withMethod: method! ! !TPureBehavior methodsFor: 'accessing class hierarchy' stamp: 'SebastianTleye 7/5/2013 12:47'! withAllSubclassesDo: aBlock "Evaluate the argument, aBlock, for the receiver and each of its subclasses." self withAllSubclasses do: [ :subclass | aBlock value: subclass ].! ! !TPureBehavior methodsFor: 'accessing class hierarchy' stamp: 'SebastianTleye 7/5/2013 12:52'! withAllSubclasses "Answer a Set of the receiver, the receiver's descendent's, and the receiver's descendent's subclasses." ^ self allSubclasses add: self; yourself! ! !TPureBehavior methodsFor: 'accessing method dictionary' stamp: 'SebastianTleye 7/5/2013 15:59'! selectorsWithArgs: numberOfArgs "Return all selectors defined in this class that take this number of arguments" ^ self selectors select: [:selector | selector numArgs = numberOfArgs]! ! !TPureBehavior methodsFor: 'adding/removing methods' stamp: 'SebastianTleye 7/5/2013 11:18'! basicRemoveSelector: selector "Assuming that the argument, selector (a Symbol), is a message selector in my method dictionary, remove it and its method." | oldMethod | oldMethod := self methodDict at: selector ifAbsent: [^ self]. self methodDict removeKey: selector. "Now flush the method cache" oldMethod flushCache. selector flushCache.! ! !TPureBehavior methodsFor: 'testing method dictionary' stamp: 'SebastianTleye 7/5/2013 17:02'! thoroughWhichSelectorsReferTo: literal special: specialFlag byte: specialByte "Answer a set of selectors whose methods access the argument as a literal. Dives into the compact literal notation, making it slow but thorough " | selectors | selectors := IdentitySet new. self selectorsAndMethodsDo: [ :sel :method | ((self isTrait ifTrue: [method hasLiteralThorough: literal] ifFalse: [method refersToLiteral: literal]) or: [specialFlag and: [method scanFor: specialByte]]) ifTrue: [selectors add: sel]]. ^ selectors! ! !TPureBehavior methodsFor: 'traits' stamp: 'SebastianTleye 7/5/2013 10:25'! addTraitSelector: aSymbol withMethod: aCompiledMethod "Add aMethod with selector aSymbol to my methodDict. aMethod must not be defined locally." | source method | [(self includesLocalSelector: aSymbol) not] assert. self ensureLocalSelectors. source := aCompiledMethod getSourceReplacingSelectorWith: aSymbol. method := self compile: source classified: aCompiledMethod category notifying: nil trailer: self defaultMethodTrailer ifFail: [ ^nil ]. method putSource: source inFile: 2 withPreamble: [:f | f cr; nextPut: $!!; nextChunkPut: 'Trait method'; cr]. self isTrait ifFalse: [ method properties at: #traitSource put: aCompiledMethod]. self basicAddSelector: aSymbol withMethod: method! ! !TBehavior methodsFor: '*Manifest-Core' stamp: 'SebastianTleye 7/9/2013 11:05'! isManifest ^ self name beginsWith: 'Manifest'! ! !TBehavior methodsFor: '*ast-core' stamp: 'SebastianTleye 7/9/2013 11:05'! parseTreeFor: aSymbol ^ RBParser parseMethod: (self sourceCodeAt: aSymbol) onError: [ :msg :pos | ^ nil ]! ! !TBehavior methodsFor: '*Nautilus' stamp: 'SebastianTleye 7/9/2013 11:06'! realClass ^ self! ! !TBehavior methodsFor: '*NativeBoost-Core' stamp: 'SebastianTleye 7/9/2013 11:06'! nbBindingOf: aName "answer a binding for a type name, by default use smalltalk name bindings" ^ self bindingOf: aName! ! !TBehavior methodsFor: '*NativeBoost-Core' stamp: 'SebastianTleye 7/9/2013 11:06'! externalTypeAlias: aTypeName "override, if you want to introduce type aliases. Answering nil means no type alias for given type name exists" ^ nil! ! !TBehavior methodsFor: '*NativeBoost-Core' stamp: 'SebastianTleye 7/9/2013 11:06'! nbFnArgument: argName generator: gen "Load the instance variable with given name" (self allInstVarNames includes: argName) ifFalse: [ ^ nil ]. ^ NBSTIvarArgument new receiverClass: self; ivarName: argName! ! !TBehavior methodsFor: '*Compiler-Kernel' stamp: 'SebastianTleye 7/5/2013 17:17'! bindingOf: varName ^self explicitRequirement.! ! !TBehavior methodsFor: 'obsolete subclasses' stamp: 'SebastianTleye 7/5/2013 17:47'! basicObsoleteSubclasses ^self explicitRequirement.! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! allCallsOnIn: aSystemNavigation "Answer a SortedCollection of all the methods that refer to me by name or as part of an association in a global dict." ^ (aSystemNavigation allReferencesTo: (self environment associationAt: self theNonMetaClass name)), (aSystemNavigation allCallsOn: self theNonMetaClass name) ! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! allUnsentMessages "Answer an array of all the messages defined by the receiver that are not sent anywhere in the system." ^ SystemNavigation new allUnsentMessagesIn: self selectors! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:06'! allCallsOn "Answer a SortedCollection of all the methods that refer to me by name or as part of an association in a global dict." ^ (self allCallsOnIn: self systemNavigation)! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! referencedClasses "Return the set of classes that are directly referenced by my methods" | answer | answer := Set new. self methods do: [ :cm | answer addAll: ( cm literals select: [ :l | l isKindOf: Association ] thenCollect: #value ) ]. ^ answer! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! allCallsOn: aSymbol "Answer a SortedCollection of all the methods that call on aSymbol." ^ self systemNavigation allCallsOn: aSymbol from: self . ! ! !TBehavior methodsFor: 'testing class hierarchy' stamp: 'SebastianTleye 7/5/2013 16:12'! includesBehavior: aClass self isTrait ifTrue: [ ^false ]. ^self == aClass or:[self inheritsFrom: aClass]! ! !TBehavior methodsFor: '*Tools-Inspector' stamp: 'SebastianTleye 7/9/2013 11:07'! inspectAllInstances "Inspect all instances of the receiver." | all allSize prefix | all := self allInstances. (allSize := all size) isZero ifTrue: [^ self inform: 'There are no instances of ', self name]. prefix := allSize = 1 ifTrue: ['The lone instance'] ifFalse: ['The ', allSize printString, ' instances']. all asArray inspectWithLabel: (prefix, ' of ', self name)! ! !TBehavior methodsFor: '*Tools-Inspector' stamp: 'SebastianTleye 7/9/2013 11:07'! inspectSubInstances "Inspect all instances of the receiver and all its subclasses. CAUTION - don't do this for something as generic as Object!!" | all allSize prefix | all := self allSubInstances. (allSize := all size) isZero ifTrue: [^ self inform: 'There are no instances of ', self name, ' or any of its subclasses']. prefix := allSize = 1 ifTrue: ['The lone instance'] ifFalse: ['The ', allSize printString, ' instances']. all asArray inspectWithLabel: (prefix, ' of ', self name, ' & its subclasses')! ! !TBehavior methodsFor: '*Manifest-Core' stamp: 'SebastianTleye 7/9/2013 11:05'! isManifest ^ self name beginsWith: 'Manifest'! ! !TBehavior methodsFor: '*ast-core' stamp: 'SebastianTleye 7/9/2013 11:05'! parseTreeFor: aSymbol ^ RBParser parseMethod: (self sourceCodeAt: aSymbol) onError: [ :msg :pos | ^ nil ]! ! !TBehavior methodsFor: '*Nautilus' stamp: 'SebastianTleye 7/9/2013 11:06'! realClass ^ self! ! !TBehavior methodsFor: '*NativeBoost-Core' stamp: 'SebastianTleye 7/9/2013 11:06'! nbBindingOf: aName "answer a binding for a type name, by default use smalltalk name bindings" ^ self bindingOf: aName! ! !TBehavior methodsFor: '*NativeBoost-Core' stamp: 'SebastianTleye 7/9/2013 11:06'! externalTypeAlias: aTypeName "override, if you want to introduce type aliases. Answering nil means no type alias for given type name exists" ^ nil! ! !TBehavior methodsFor: '*NativeBoost-Core' stamp: 'SebastianTleye 7/9/2013 11:06'! nbFnArgument: argName generator: gen "Load the instance variable with given name" (self allInstVarNames includes: argName) ifFalse: [ ^ nil ]. ^ NBSTIvarArgument new receiverClass: self; ivarName: argName! ! !TBehavior methodsFor: '*Compiler-Kernel' stamp: 'SebastianTleye 7/5/2013 17:17'! bindingOf: varName ^self explicitRequirement.! ! !TBehavior methodsFor: 'obsolete subclasses' stamp: 'SebastianTleye 7/5/2013 17:47'! basicObsoleteSubclasses ^self explicitRequirement.! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! allCallsOnIn: aSystemNavigation "Answer a SortedCollection of all the methods that refer to me by name or as part of an association in a global dict." ^ (aSystemNavigation allReferencesTo: (self environment associationAt: self theNonMetaClass name)), (aSystemNavigation allCallsOn: self theNonMetaClass name) ! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! allUnsentMessages "Answer an array of all the messages defined by the receiver that are not sent anywhere in the system." ^ SystemNavigation new allUnsentMessagesIn: self selectors! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:06'! allCallsOn "Answer a SortedCollection of all the methods that refer to me by name or as part of an association in a global dict." ^ (self allCallsOnIn: self systemNavigation)! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! referencedClasses "Return the set of classes that are directly referenced by my methods" | answer | answer := Set new. self methods do: [ :cm | answer addAll: ( cm literals select: [ :l | l isKindOf: Association ] thenCollect: #value ) ]. ^ answer! ! !TBehavior methodsFor: '*System-Support' stamp: 'SebastianTleye 7/9/2013 11:07'! allCallsOn: aSymbol "Answer a SortedCollection of all the methods that call on aSymbol." ^ self systemNavigation allCallsOn: aSymbol from: self . ! ! !TBehavior methodsFor: 'testing class hierarchy' stamp: 'SebastianTleye 7/5/2013 16:12'! includesBehavior: aClass self isTrait ifTrue: [ ^false ]. ^self == aClass or:[self inheritsFrom: aClass]! ! !TBehavior methodsFor: '*Tools-Inspector' stamp: 'SebastianTleye 7/9/2013 11:07'! inspectAllInstances "Inspect all instances of the receiver." | all allSize prefix | all := self allInstances. (allSize := all size) isZero ifTrue: [^ self inform: 'There are no instances of ', self name]. prefix := allSize = 1 ifTrue: ['The lone instance'] ifFalse: ['The ', allSize printString, ' instances']. all asArray inspectWithLabel: (prefix, ' of ', self name)! ! !TBehavior methodsFor: '*Tools-Inspector' stamp: 'SebastianTleye 7/9/2013 11:07'! inspectSubInstances "Inspect all instances of the receiver and all its subclasses. CAUTION - don't do this for something as generic as Object!!" | all allSize prefix | all := self allSubInstances. (allSize := all size) isZero ifTrue: [^ self inform: 'There are no instances of ', self name, ' or any of its subclasses']. prefix := allSize = 1 ifTrue: ['The lone instance'] ifFalse: ['The ', allSize printString, ' instances']. all asArray inspectWithLabel: (prefix, ' of ', self name, ' & its subclasses')! ! !TraitBehavior methodsFor: 'obsolete subclasses' stamp: 'SebastianTleye 7/5/2013 17:46'! basicObsoleteSubclasses ^WeakKeyToCollectionDictionary new.! ! !TraitBehavior methodsFor: 'obsolete subclasses' stamp: 'SebastianTleye 7/5/2013 17:46'! basicObsoleteSubclasses ^WeakKeyToCollectionDictionary new.! ! !Behavior methodsFor: '*Compiler-Kernel' stamp: 'SebastianTleye 7/5/2013 17:16'! bindingOf: varName "Answer the binding of some variable resolved in the scope of the receiver" ^self superclass bindingOf: varName! ! !Behavior methodsFor: '*Compiler-Kernel' stamp: 'SebastianTleye 7/5/2013 17:16'! bindingOf: varName "Answer the binding of some variable resolved in the scope of the receiver" ^self superclass bindingOf: varName! ! !Class methodsFor: 'private' stamp: 'SebastianTleye 7/4/2013 18:29'! spaceUsed "Object spaceUsed" ^ super spaceUsed + self class spaceUsed! ! !Class methodsFor: 'private' stamp: 'SebastianTleye 7/4/2013 18:29'! spaceUsed "Object spaceUsed" ^ super spaceUsed + self class spaceUsed! ! Trait removeSelector: #includesBehavior:! Trait removeSelector: #localSelectors:! Behavior removeSelector: #allCallsOn! Behavior removeSelector: #allCallsOn:! Behavior removeSelector: #allCallsOnIn:! Behavior removeSelector: #allUnsentMessages! Behavior removeSelector: #externalTypeAlias:! Behavior removeSelector: #inspectAllInstances! Behavior removeSelector: #inspectSubInstances! Behavior removeSelector: #isManifest! Behavior removeSelector: #nbBindingOf:! Behavior removeSelector: #nbFnArgument:generator:! Behavior removeSelector: #parseTreeFor:! Behavior removeSelector: #realClass! Behavior removeSelector: #referencedClasses! TraitBehavior removeSelector: #addTraitSelector:withMethod:! TraitBehavior removeSelector: #basicRemoveSelector:! !TraitBehavior reorganize! (#traits addTraitSelector:withMethod: traitComposition: flattenDownAllTraits traits users flattenDown: classesComposedWithMe traitsProvidingSelector: users: traitOrClassOfSelector: removeUser: updateMethodDictionarySelector: traitCompositionIncludes: notifyUsersOfChangedSelector: purgeLocalSelectors noteChangedSelectors: traitComposition traitCompositionString setTraitCompositionFrom: traitTransformations hasTraitComposition removeTraitSelector: setTraitComposition: notifyUsersOfChangedSelectors: removeFromComposition: applyChangesOfNewTraitCompositionReplacing: ensureLocalSelectors addUser: addToComposition: removeAlias:of: addExclusionOf:to:) (#'*ast-core' parseTreeFor:) (#copying deepCopy copyOfMethodDictionary postCopy) (#'accessing method dictionary' ultimateSourceCodeAt:ifAbsent: allMethods compiledMethodAt:ifAbsent: selectors deregisterLocalSelector: methodDict: allSelectorsAboveUntil: sourceCodeAt: compress allSelectorsBelow: methodDictionary basicLocalSelectors removeSelector: >> lookupSelector: nextQuotePosIn:startingFrom: registerLocalSelector: allSelectorsAbove methodDictionary: selectorsWithArgs: supermostPrecodeCommentFor: basicLocalSelectors: changeRecordsAt: methodDict firstCommentAt: methods zapAllMethods allSelectorsWithout: sourceCodeAt:ifAbsent: selectorsAndMethodsDo: compiledMethodAt: classAndMethodFor:do:ifAbsent: firstPrecodeCommentFor: precodeCommentOrInheritedCommentFor: commentsAt: commentsIn: selectorsDo: methodsDo: addSelectorSilently:withMethod: allSelectors) (#'testing class hierarchy' kindOfSubclass inheritsFrom:) (#'*Tools-Browser' browse) (#testing isObsolete includesBehavior: isBytes instSize isTrait isAnonymous isBits hasAbstractMethods isWeak isCompact canZapMethodDictionary isPointers shouldNotBeRedefined isWords isMeta isVariable isFixed sourceMatchesBytecodeAt: instSpec) (#'*Manifest-Core' isManifest) (#accessing isComposedBy: classDepth poolDictionaryNames typeOfClass numberOfInstanceVariables classPool) (#'system startup' shutDown: shutDown startUp: startUp) (#'*Compiler-Kernel' decompilerClass binding parserClass compile: bindingOf: compile:classified:notifying:trailer:ifFail: compiler defaultMethodTrailer evaluatorClass compile:notifying: compileAll compileAllFrom: evaluate: compilerClass recompileChanges sourceCodeTemplate recompile:from: recompile:) (#naming environment name) (#'accessing instances and variables' someInstance includesSharedPoolNamed: allClassVarNames classVarNames instVarNames instanceCount allSharedPools allowsSubInstVars allSubInstances allInstances sharedPools subclassInstVarNames allInstVarNames) (#'*NativeBoost-Core' nbBindingOf: externalTypeAlias: nbFnArgument:generator:) (#'*Tools-Inspector' inspectAllInstances inspectSubInstances) (#queries whichSelectorsAssign: copiesMethodsFromSuperclass whichClassDefinesInstVar: whichSuperclassSatisfies: copiesFromSuperclass: whichSelectorsRead: whichClassDefinesClassVar: copiedFromSuperclass: copiedMethodsFromSuperclass) (#'*Rpackage-Core' originalName) (#private spaceUsed becomeUncompact checkCanBeUncompact flushCache becomeCompactSimplyAt: becomeCompact indexIfCompact setFormat:) (#'obsolete subclasses' basicObsoleteSubclasses allLocalCallsOn: addObsoleteSubclass: removeAllObsoleteSubclasses removeObsoleteSubclass: obsoleteSubclasses) (#'*System-Support' allCallsOnIn: allUnsentMessages allCallsOn referencedClasses allCallsOn:) (#'user interface' withAllSubAndSuperclassesDo: unreferencedInstanceVariables) (#'*Nautilus' realClass) (#'class compatibility' subclassDefinerClass) (#'accessing class hierarchy' allSuperclasses superclass: withAllSubclasses subclasses withAllSuperclasses superclass withAllSubclassesDo: allSuperclassesIncluding: allSubclassesWithLevelDo:startingLevel: allSubclasses) (#enumerating selectSuperclasses: subclassesDo: selectSubclasses: withAllSuperAndSubclassesDo: allSubclassesDo: withAllSuperclassesDo: allInstancesDo: allUnreferencedInstanceVariables allSuperclassesDo: allSubInstancesDo:) (#initialization emptyMethodDictionary obsolete) (#'instance creation' new: basicNew: basicNew new) (#'memory usage' instancesSizeInMemory) (#'testing method dictionary' thoroughHasSelectorReferringTo:special:byte: isLocalAliasSelector: whichClassIncludesSelector: classBindingOf: isDisabledSelector: hasMethods whichSelectorsStoreInto: canUnderstand: whichSelectorsReferTo:special:byte: thoroughWhichSelectorsReferTo:special:byte: canPerform: whichSelectorsAccess: includesLocalSelector: whichSelectorsReferTo: isAliasSelector: includesSelector:) (#cleanup cleanUp cleanUp:) (#'initialize-release' initialize nonObsoleteClass superclass:methodDictionary:format:) (#compiling instVarNamesAndOffsetsDo: variablesAndOffsetsDo:) (#printing printHierarchy literalScannedAs:notifying: storeLiteral:on: printOn: longPrintOn:) (#'*Ring-Core-Kernel' protocols methodNamed: methodsInProtocol:) (#'adding/removing methods' localSelectors: adoptInstance: basicRemoveSelector: pureAddSelectorSilently:withMethod: addSelector:withMethod:notifying: methodDictAddSelectorSilently:withMethod: basicAddSelector:withMethod: addSelector:withMethod: pureRemoveSelector: removeSelectorSilently: localSelectors) ! TBehavior removeSelector: #addTraitSelector:withMethod:! TBehavior removeSelector: #basicRemoveSelector:! TBehavior removeSelector: #selectorsWithArgs:! TBehavior removeSelector: #thoroughWhichSelectorsReferTo:special:byte:! TBehavior removeSelector: #withAllSubclasses! TBehavior removeSelector: #withAllSubclassesDo:! TPureBehavior removeSelector: #bindingOf:! TPureBehavior removeSelector: #includesBehavior:! TPureBehavior removeSelector: #ultimateSourceCodeAt:ifAbsent:! TClassDescription removeSelector: #addTraitSelector:withMethod:! TClass removeSelector: #spaceUsed! TClass removeSelector: #withAllSubclassesDo:!