This file is indexed.

/usr/share/gnu-smalltalk/kernel/Autoload.st is in gnu-smalltalk-common 3.2.4-2.

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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
"======================================================================
|
|   File autoloading mechanism
|
|
 ======================================================================"

"======================================================================
|
| Copyright 1991,1992,94,95,99,2000,2001,2002,2008
| Free Software Foundation, Inc.
| Written by Steve Byrne.
|
| 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.  
|
 ======================================================================"



Kernel.PackageInfo extend [
    autoload [
        <category: 'private-autoloading'>

        self fileIn
    ]
]

FilePath extend [
    autoload [
        <category: 'private-autoloading'>

        self withReadStreamDo: [:rs | rs fileIn ]
    ]
]

Namespace current: Kernel [

nil subclass: AutoloadClass [
    "Warning: instance variable indices appear below in #class:in:from:"
    | superClass methodDictionary instanceSpec subClasses instanceVariables environment name loader |
    
    <comment: 'I represent the metaclass of an autoloaded class before it is autoloaded.
Having a proxy for the metaclass as well allows one to send messages to
the metaclass (such as #methodsFor: to extend it with class-side methods)
and have the class autoloaded.'>
    <category: 'Examples-Useful tools'>

    AutoloadClass class >> class: nameSymbol in: aNamespace loader: anObject [
	| autoload behavior newClass |
	"Create the metaclass and its sole instance"
	behavior := Behavior new superclass: Autoload.

	"Turn the metaclass into an instance of AutoloadClass.  To do
	 this we create a `prototype' in the form of an array..."
	newClass := Array new: Kernel.AutoloadClass allInstVarNames size.
	1 to: behavior class instSize
	    do: [:i | newClass at: i put: (behavior instVarAt: i)].

	newClass
            at: 6 put: aNamespace;
            at: 7 put: nameSymbol;
            at: 8 put: anObject.

	"... and change its class magically after it is initialized."
	newClass changeClassTo: Kernel.AutoloadClass.

	"Now create the instance.  We go through some hops because of
	 the very limited set of messages that these classes know
	 about."
	autoload := behavior new.
	behavior become: newClass.
        ^autoload
    ]

    name [
	"Answer the name of the class to be autoloaded"

	<category: 'accessing'>
	^name
    ]

    environment [
	"Answer the namespace in which the class will be autoloaded"

	<category: 'accessing'>
	^environment
    ]

    doesNotUnderstand: aMessage [
	"Load the class and resend the message to its metaclass."

	<category: 'accessing'>
	^aMessage reinvokeFor: self loadedMetaclass_
    ]

    loadedMetaclass_ [
	"File-in the file and answer the metaclass for the new value of the
	 association which held the receiver"

	<category: 'accessing'>
	^self loadedClass_ class
    ]

    loadedClass_ [
	"File-in the file and answer the new value of the association which
	 held the receiver"

	<category: 'accessing'>
	| class saveLoader |
	loader isNil 
	    ifFalse: 
		[saveLoader := loader.
		loader := nil.
		environment at: name put: nil.
		saveLoader autoload].
	class := environment at: name ifAbsent: [nil].
	class isNil ifTrue: [
            ^Autoload error: '%1 should have defined class %2.%3 but didn''t'
                % {saveLoader. environment. name asString}].
	^class
    ]
]

]



nil subclass: Autoload [
    
    <comment: 'I am not a part of the normal Smalltalk kernel class system.  I provide the
ability to do late ("on-demand") loading of class definitions.  Through me,
you can define any class to be loaded when any message is sent to
the class itself (such as to create an instance) or to its metaclass (such
as #methodsFor: to extend it with class-side methods).'>
    <category: 'Examples-Useful tools'>

    Autoload class >> class: nameSymbol from: fileNameString [
	"Make Smalltalk automatically load the class named nameSymbol
	 from fileNameString when needed"

	<category: 'instance creation'>
	^self 
	    class: nameSymbol
	    in: Namespace current
	    from: fileNameString
    ]

    Autoload class >> class: nameSymbol loader: anObject [
	"Make Smalltalk automatically load the class named nameSymbol.
	 When the class is needed, anObject will be sent #autoload.
	 By default, instances of FilePath and Package can be used."

	<category: 'instance creation'>
	^self 
	    class: nameSymbol
	    in: Namespace current
	    loader: anObject
    ]

    Autoload class >> class: nameSymbol in: aNamespace from: fileNameString [
	"Make Smalltalk automatically load the class named nameSymbol
	 and residing in aNamespace from fileNameString when needed"

	<category: 'instance creation'>
	| file |
	"Check if the file exists."
        file := fileNameString asFile.
	file withReadStreamDo: [ :rs | ].

	"Turn the metaclass into an instance of AutoloadClass.  To do
	 this we create a `prototype' in the form of an array and then..."
        ^self class: nameSymbol in: aNamespace loader: file
    ]

    Autoload class >> class: nameSymbol in: aNamespace loader: anObject [
	"Make Smalltalk automatically load the class named nameSymbol
	 and residing in aNamespace.  When the class is needed, anObject
         will be sent #autoload.  By default, instances of FilePath and
         Package can be used."

	<category: 'instance creation'>
	| autoload |
        autoload := Kernel.AutoloadClass class: nameSymbol in: aNamespace loader: anObject.
	^aNamespace at: nameSymbol put: autoload
    ]

    class [
	"We need it to access the metaclass instance, because that's what
	 will load the file."

	<category: 'accessing'>
	<primitive: VMPrimitives.VMpr_Object_class>
    ]

    doesNotUnderstand: aMessage [
	"Load the class and resend the message to it"

	<category: 'accessing'>
	^aMessage reinvokeFor: self class loadedClass_
    ]
]