This file is indexed.

/usr/share/gnu-smalltalk/kernel/MethodDict.st is in gnu-smalltalk-common 3.2.4-2.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
"======================================================================
|
|   MethodDictionary Method Definitions
|
|
 ======================================================================"

"======================================================================
|
| Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
| Written by Paolo Bonzini.
|
| This file is part of the GNU Smalltalk class library.
|
| The GNU Smalltalk class library is free software; you can redistribute it
| and/or modify it under the terms of the GNU Lesser General Public License
| as published by the Free Software Foundation; either version 2.1, or (at
| your option) any later version.
| 
| The GNU Smalltalk class library is distributed in the hope that it will be
| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
| General Public License for more details.
| 
| You should have received a copy of the GNU Lesser General Public License
| along with the GNU Smalltalk class library; see the file COPYING.LIB.
| If not, write to the Free Software Foundation, 59 Temple Place - Suite
| 330, Boston, MA 02110-1301, USA.  
|
 ======================================================================"



IdentityDictionary subclass: MethodDictionary [
    
    <shape: #pointer>
    <category: 'Language-Implementation'>
    <comment: 'I am similar to an IdentityDictionary, except that removal and
rehashing operations inside my instances look atomic to the
interpreter.'>

    at: key put: value [
	"Store value as associated to the given key"

	<category: 'adding'>
	| index |
	index := self findIndex: key.
	(self primAt: index) isNil 
	    ifTrue: 
		[self incrementTally ifTrue: [index := self findIndex: key].
		self primAt: index put: key]
	    ifFalse: [(self valueAt: index) discardTranslation].
	self valueAt: index put: value.
	Behavior flushCache.
	^value
    ]

    remove: anAssociation [
	"Remove anAssociation's key from the dictionary"

	"The interpreter might be using this MethodDictionary while
	 this method is running!!  Therefore we perform the removal
	 in a copy, and then atomically become that copy"

	<category: 'removing'>
	| copy result |
	(self includesKey: anAssociation key) 
	    ifFalse: [SystemExceptions.NotFound signalOn: anAssociation key what: 'key'].
	copy := self copy.
	result := copy dangerouslyRemove: anAssociation.
	self become: copy.
	Behavior flushCache.
	^result
    ]

    removeKey: anElement ifAbsent: aBlock [
	"Remove the passed key from the dictionary, answer the result of
	 evaluating aBlock if it is not found"

	"The interpreter might be using this MethodDictionary while
	 this method is running!!  Therefore we perform the removal
	 in a copy, and then atomically become that copy"

	<category: 'removing'>
	| copy result |
	(self includesKey: anElement) ifFalse: [^aBlock value].
	copy := self copy.
	result := copy dangerouslyRemoveKey: anElement.
	self become: copy.
	Behavior flushCache.
	^result
    ]

    rehash [
	"Rehash the receiver"

	"The interpreter might be using this MethodDictionary while
	 this method is running!!  Therefore we create a copy that
	 has correct hashing (it is built on the fly), then atomically
	 become that copy"

	<category: 'rehashing'>
	self growBy: 0
    ]

    dangerouslyRemove: anAssociation [
	"This is not really dangerous.  But if normal removal
	 were done WHILE a MethodDictionary were being used, the
	 system might crash.  So instead we make a copy, then do
	 this operation (which is NOT dangerous in a copy that is
	 not being used), and then use the copy after the removal."

	<category: 'private methods'>
	| association |
	association := super remove: anAssociation.
	association value discardTranslation.
	^association
    ]

    dangerouslyRemoveKey: anElement [
	"This is not really dangerous.  But if normal removal
	 were done WHILE a MethodDictionary were being used, the
	 system might crash.  So instead we make a copy, then do
	 this operation (which is NOT dangerous in a copy that is
	 not being used), and then use the copy after the removal."

	<category: 'private methods'>
	| value |
	value := super removeKey: anElement
		    ifAbsent: [self error: 'synchronization problem?'].
	value discardTranslation.
	^value
    ]
]