166 ]. |
168 ]. |
167 ^ stream pathName. |
169 ^ stream pathName. |
168 ! |
170 ! |
169 |
171 |
170 readStream |
172 readStream |
|
173 "read from self" |
|
174 |
171 ^ self |
175 ^ self |
|
176 |
|
177 "Modified (comment): / 16-02-2017 / 15:59:52 / stefan" |
172 ! |
178 ! |
173 |
179 |
174 stream |
180 stream |
175 ^ stream |
181 ^ stream |
176 ! |
182 ! |
177 |
183 |
178 stream:something |
184 stream:something |
179 stream := something. |
185 stream := something. |
180 ! ! |
186 ! ! |
181 |
187 |
182 !EncodedStream methodsFor:'private fileIn'! |
188 !EncodedStream methodsFor:'chunk input/output'! |
183 |
189 |
184 basicFileInNotifying:someone passChunk:passChunk |
190 nextChunk |
185 "central method to file in from the receiver, i.e. read chunks and evaluate them - |
191 "as a side effect, check for an encoding chunk" |
186 return the value of the last chunk. |
192 |
187 Someone (which is usually some codeView) is notified of errors." |
193 |prevEncoder chunk| |
188 |
194 |
189 |lastValue pkg nameSpace usedNameSpaces |
195 chunk := stream nextChunk. |
190 packageQuerySignal nameSpaceQuerySignal usedNameSpaceQuerySignal |
196 chunk isEmptyOrNil ifTrue:[ |
191 changeDefaultApplicationNotificationSignal |
197 ^ chunk. |
192 defaultApplicationQuerySignal defaultApplication |
198 ]. |
193 confirmationQuerySignal handledSignals passedSignals askSomeoneForPackage outerContext askForVariableTypeOfUndeclaredQuery| |
199 |
194 |
200 prevEncoder := encoder. |
195 self skipSeparators. |
201 (prevEncoder isNullEncoder and:[stream isPositionable not]) ifTrue:[ |
196 lastValue := self peek. |
202 "/ not already checked |
197 lastValue == $< ifTrue:[ |
203 "/ check if we need lazy setup of the encoder |
198 "/ assume, it's an xml file |
204 "/ (used with non-positionable streams) |
199 ^ self fileInXMLNotifying:someone passChunk:passChunk. |
205 (chunk includesString:'{ Encoding:') ifTrue:[ |
200 ]. |
206 |enc| |
201 lastValue == $# ifTrue:[ |
207 |
202 "assume unix interpreter name: |
208 enc := self class encoderFor:(CharacterEncoder guessEncodingOfBuffer:chunk). |
203 '#!!stx -e' or something like this" |
209 enc notNil ifTrue:[ |
204 self nextPeek == $!! ifTrue:[ |
210 prevEncoder := encoder := enc. |
205 "skip the unix command line" |
211 ]. |
206 self nextLine |
|
207 ] ifFalse:[ |
|
208 self error:'Invalid chunk start' |
|
209 ] |
212 ] |
210 ]. |
213 ]. |
211 |
214 ^ prevEncoder decodeString:chunk |
212 (Smalltalk at:#Compiler) isNil ifTrue:[ |
215 |
213 self isFileStream ifTrue:[ |
216 "Modified: / 16-02-2017 / 14:54:57 / stefan" |
214 Transcript show:('[' , self pathName , '] '). |
|
215 ]. |
|
216 Transcript showCR:'cannot fileIn (no compiler).'. |
|
217 ^ nil. |
|
218 ]. |
|
219 |
|
220 "/ support for V'Age applications |
|
221 defaultApplicationQuerySignal := Class defaultApplicationQuerySignal. |
|
222 changeDefaultApplicationNotificationSignal := Class changeDefaultApplicationNotificationSignal. |
|
223 |
|
224 "/ support for ST/X's nameSpaces & packages |
|
225 packageQuerySignal := Class packageQuerySignal. |
|
226 nameSpaceQuerySignal := Class nameSpaceQuerySignal. |
|
227 usedNameSpaceQuerySignal := Class usedNameSpaceQuerySignal. |
|
228 |
|
229 (someone respondsTo:#packageToInstall) ifTrue:[ |
|
230 pkg := someone packageToInstall. |
|
231 askSomeoneForPackage := true. |
|
232 ] ifFalse:[ |
|
233 pkg := packageQuerySignal query. |
|
234 askSomeoneForPackage := false. |
|
235 ]. |
|
236 (someone respondsTo:#currentNameSpace) ifTrue:[ |
|
237 nameSpace := someone currentNameSpace |
|
238 ] ifFalse:[ |
|
239 nameSpace := nameSpaceQuerySignal query. |
|
240 ]. |
|
241 (someone respondsTo:#usedNameSpaces) ifTrue:[ |
|
242 usedNameSpaces := someone usedNameSpaces |
|
243 ] ifFalse:[ |
|
244 usedNameSpaces := usedNameSpaceQuerySignal query. |
|
245 ]. |
|
246 (someone respondsTo:#defaultApplication) ifTrue:[ |
|
247 defaultApplication := someone defaultApplication |
|
248 ] ifFalse:[ |
|
249 defaultApplication := defaultApplicationQuerySignal query. |
|
250 ]. |
|
251 |
|
252 confirmationQuerySignal := Metaclass confirmationQuerySignal. |
|
253 |
|
254 handledSignals := SignalSet new. |
|
255 passedSignals := IdentitySet new. |
|
256 |
|
257 handledSignals add:changeDefaultApplicationNotificationSignal. |
|
258 passedSignals add:changeDefaultApplicationNotificationSignal. |
|
259 handledSignals add:defaultApplicationQuerySignal. |
|
260 passedSignals add:defaultApplicationQuerySignal. |
|
261 |
|
262 handledSignals add:packageQuerySignal. |
|
263 handledSignals add:usedNameSpaceQuerySignal. |
|
264 handledSignals add:nameSpaceQuerySignal. |
|
265 handledSignals add:confirmationQuerySignal. |
|
266 passedSignals add:confirmationQuerySignal. |
|
267 Parser notNil ifTrue:[ |
|
268 "only if libcomp is present" |
|
269 "Also catch a 'Parser askForVariableTypeOfUndeclaredQuery' and proceed with nil. |
|
270 Imagine somebody has autodefine workspace variables on and then |
|
271 evaluate Smalltalk loadPackage:'xyz' that loads code from source (using file-in), |
|
272 certainly we don't want to compile workspace variable access for every |
|
273 not-yet-loaded class in some namespace. |
|
274 This is demonstrated by Regression::CompilerTests2>>test_01 |
|
275 and this change actually fixes this test." |
|
276 askForVariableTypeOfUndeclaredQuery := Parser askForVariableTypeOfUndeclaredQuery. |
|
277 handledSignals add:askForVariableTypeOfUndeclaredQuery. |
|
278 ]. |
|
279 |
|
280 |
|
281 outerContext := thisContext. |
|
282 |
|
283 handledSignals handle:[:ex | |
|
284 |sig| |
|
285 |
|
286 sig := ex creator. |
|
287 ((passedSignals includes:sig) and:[sig isHandledIn:outerContext]) ifTrue:[ |
|
288 ex reject |
|
289 ]. |
|
290 |
|
291 sig == changeDefaultApplicationNotificationSignal ifTrue:[ |
|
292 "/ invoked via #becomeDefault to set the defaultApp and the package. |
|
293 "/ (only when filing in V'Age code) |
|
294 defaultApplication := ex parameter. |
|
295 pkg := defaultApplication name asSymbol. |
|
296 ex proceedWith:nil |
|
297 ]. |
|
298 sig == defaultApplicationQuerySignal ifTrue:[ |
|
299 "/ query for the application to add classes & methods into |
|
300 "/ (only when filing in V'Age code) |
|
301 ex proceedWith:defaultApplication |
|
302 ]. |
|
303 sig == packageQuerySignal ifTrue:[ |
|
304 "answer the package to use for classes & methods" |
|
305 askSomeoneForPackage ifTrue:[ |
|
306 ex proceedWith:someone packageToInstall |
|
307 ] ifFalse:[ |
|
308 ex proceedWith:pkg |
|
309 ] |
|
310 ]. |
|
311 sig == usedNameSpaceQuerySignal ifTrue:[ |
|
312 "answer the nameSpaces to be searched when encountering globals" |
|
313 ex proceedWith:usedNameSpaces |
|
314 ]. |
|
315 sig == nameSpaceQuerySignal ifTrue:[ |
|
316 "answer the nameSpace to install new classes in" |
|
317 ex proceedWith:nameSpace |
|
318 ]. |
|
319 sig == confirmationQuerySignal ifTrue:[ |
|
320 "don't pop up dialogs" |
|
321 ex proceedWith:false |
|
322 ]. |
|
323 sig == askForVariableTypeOfUndeclaredQuery ifTrue:[ |
|
324 "no autodefined variables or so" |
|
325 ex proceedWith:nil. |
|
326 ]. |
|
327 ] do:[ |
|
328 [self atEnd] whileFalse:[ |
|
329 lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk |
|
330 ] |
|
331 ]. |
|
332 ^ lastValue |
|
333 |
|
334 "Modified: / 10.9.1999 / 16:54:01 / stefan" |
|
335 "Modified: / 16.11.2001 / 16:21:28 / cg" |
|
336 "Modified: / 18-03-2013 / 17:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
337 ! ! |
217 ! ! |
338 |
218 |
339 !EncodedStream methodsFor:'stream protocol'! |
219 !EncodedStream methodsFor:'stream protocol'! |
340 |
220 |
341 atEnd |
221 atEnd |