author | Claus Gittinger <cg@exept.de> |
Fri, 10 Nov 1995 16:11:38 +0100 | |
changeset 517 | c8fae50c2cc5 |
parent 432 | 5815c61da8a2 |
child 530 | 07d0bce293c9 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
57 | 13 |
PeekableStream subclass:#PositionableStream |
369 | 14 |
instanceVariableNames:'collection position readLimit writeLimit' |
276 | 15 |
classVariableNames:'ErrorDuringFileInSignal ChunkSeparator' |
1 | 16 |
poolDictionaries:'' |
17 |
category:'Streams' |
|
18 |
! |
|
19 |
||
20 |
PositionableStream comment:' |
|
88 | 21 |
COPYRIGHT (c) 1989 by Claus Gittinger |
159 | 22 |
All Rights Reserved |
93 | 23 |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
24 |
$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.32 1995-11-10 15:11:38 cg Exp $ |
88 | 25 |
'! |
1 | 26 |
|
88 | 27 |
!PositionableStream class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
159 | 32 |
All Rights Reserved |
1 | 33 |
|
88 | 34 |
This software is furnished under a license and may be used |
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
10 | 42 |
|
88 | 43 |
version |
44 |
" |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
45 |
$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.32 1995-11-10 15:11:38 cg Exp $ |
88 | 46 |
" |
47 |
! |
|
48 |
||
49 |
documentation |
|
50 |
" |
|
51 |
Instances of PositionableStream allow positioning the read pointer. |
|
52 |
The PositionableStream class also adds methods for source-chunk reading |
|
53 |
and writing, and for filing-in/out of source code. |
|
54 |
This is an abstract class. |
|
55 |
" |
|
56 |
! ! |
|
1 | 57 |
|
10 | 58 |
!PositionableStream class methodsFor:'initialization'! |
1 | 59 |
|
10 | 60 |
initialize |
44 | 61 |
"setup the signal used to handle errors during fileIn" |
62 |
||
10 | 63 |
ErrorDuringFileInSignal isNil ifTrue:[ |
302 | 64 |
ErrorDuringFileInSignal := ErrorSignal newSignalMayProceed:true. |
159 | 65 |
ErrorDuringFileInSignal nameClass:self message:#errorDuringFileInSignal. |
66 |
ErrorDuringFileInSignal notifierString:'error during fileIn'. |
|
276 | 67 |
|
68 |
ChunkSeparator := $!! |
|
10 | 69 |
] |
70 |
! ! |
|
1 | 71 |
|
72 |
!PositionableStream class methodsFor:'constants'! |
|
73 |
||
74 |
chunkSeparator |
|
75 |
"return the chunk-separation character" |
|
76 |
||
276 | 77 |
^ ChunkSeparator |
1 | 78 |
! ! |
79 |
||
80 |
!PositionableStream class methodsFor:'instance creation'! |
|
81 |
||
82 |
on:aCollection |
|
83 |
"return a new PositionableStream streaming on aCollection" |
|
84 |
||
85 |
^ (self basicNew) on:aCollection |
|
86 |
! |
|
87 |
||
88 |
on:aCollection from:first to:last |
|
89 |
"return a new PositionableStream streaming on aCollection |
|
90 |
from first to last" |
|
91 |
||
369 | 92 |
^ (self basicNew) on:aCollection from:first to:last |
57 | 93 |
! |
94 |
||
95 |
with:aCollection |
|
96 |
"return a new PositionableStream streaming on aCollection, |
|
97 |
the stream is positioned to the end of the collection." |
|
98 |
||
362 | 99 |
^ (self basicNew) with:aCollection |
1 | 100 |
! ! |
101 |
||
102 |
!PositionableStream methodsFor:'private'! |
|
103 |
||
362 | 104 |
with:aCollection |
105 |
"setup for streaming to the end of aCollection" |
|
106 |
||
107 |
collection := aCollection. |
|
108 |
self setToEnd |
|
109 |
! |
|
110 |
||
369 | 111 |
on:aCollection from:first to:last |
112 |
"setup for streaming on aCollection from first to last" |
|
113 |
||
114 |
collection := aCollection. |
|
115 |
position := first. |
|
116 |
readLimit := last |
|
117 |
! |
|
118 |
||
1 | 119 |
on:aCollection |
120 |
"setup for streaming on aCollection" |
|
121 |
||
122 |
collection := aCollection. |
|
123 |
readLimit := aCollection size. |
|
57 | 124 |
position := "0" 1 |
1 | 125 |
! |
126 |
||
127 |
positionError |
|
128 |
"report an error when positioning past the end" |
|
129 |
||
130 |
^ self error:'cannot position past end of collection' |
|
131 |
! ! |
|
132 |
||
57 | 133 |
!PositionableStream methodsFor:'private'! |
134 |
||
135 |
contentsSpecies |
|
88 | 136 |
"return a class of which instances will be returned, when |
137 |
parts of the collection are asked for. |
|
138 |
(see upTo-kind of methods in subclasses)" |
|
139 |
||
57 | 140 |
^ collection species |
141 |
! ! |
|
142 |
||
360 | 143 |
!PositionableStream methodsFor:'queries'! |
144 |
||
145 |
isPositionable |
|
146 |
"return true, if the stream supports positioning (this one is)" |
|
147 |
||
148 |
^ true |
|
149 |
! ! |
|
150 |
||
1 | 151 |
!PositionableStream methodsFor:'accessing'! |
152 |
||
153 |
contents |
|
154 |
"return the entire contents of the stream" |
|
155 |
||
156 |
^ collection |
|
157 |
! |
|
158 |
||
159 |
peek |
|
160 |
"look ahead for and return the next element" |
|
161 |
||
162 |
|peekObject| |
|
163 |
||
164 |
peekObject := self next. |
|
10 | 165 |
self backStep. |
1 | 166 |
^ peekObject |
167 |
! |
|
168 |
||
169 |
peekFor:something |
|
10 | 170 |
"return true and move past if next == something; |
171 |
otherwise stay and let position unchanged" |
|
1 | 172 |
|
173 |
self next == something ifTrue:[ |
|
159 | 174 |
^ true |
1 | 175 |
]. |
10 | 176 |
self backStep. |
1 | 177 |
^ false |
178 |
! |
|
179 |
||
180 |
readLimit:aNumber |
|
369 | 181 |
"set the read-limit; thats the position at which EOF is returned" |
1 | 182 |
|
183 |
readLimit := aNumber |
|
369 | 184 |
! |
185 |
||
186 |
writeLimit:aNumber |
|
187 |
"set the writeLimit; thats the position after which writing is prohibited" |
|
188 |
||
189 |
writeLimit := aNumber |
|
1 | 190 |
! ! |
191 |
||
192 |
!PositionableStream methodsFor:'testing'! |
|
193 |
||
194 |
atEnd |
|
195 |
"return true, if the read-position is at the end" |
|
196 |
||
197 |
^ position > readLimit |
|
198 |
! |
|
199 |
||
200 |
isEmpty |
|
201 |
"return true, if the contents of the stream is empty" |
|
202 |
||
203 |
^ readLimit == 0 |
|
204 |
! ! |
|
205 |
||
206 |
!PositionableStream methodsFor:'positioning'! |
|
207 |
||
208 |
position |
|
209 |
"return the read position" |
|
210 |
||
211 |
^ position |
|
212 |
! |
|
213 |
||
214 |
position:index |
|
215 |
"set the read position" |
|
216 |
||
362 | 217 |
"/ FIX: allow positioning right after last element of stream |
218 |
"/ ((index > readLimit) or:[index < 0]) ifTrue: [^ self positionError]. |
|
219 |
||
220 |
((index > (readLimit+1)) or:[index < 0]) ifTrue: [^ self positionError]. |
|
1 | 221 |
position := index |
222 |
! |
|
223 |
||
10 | 224 |
backStep |
225 |
"move backward read position by one" |
|
226 |
||
57 | 227 |
position <= 0 ifTrue: [^ self positionError]. |
10 | 228 |
position := position - 1 |
229 |
! |
|
230 |
||
1 | 231 |
reset |
232 |
"set the read position to the beginning of the collection" |
|
233 |
||
57 | 234 |
position := "0" 1 |
1 | 235 |
! |
236 |
||
237 |
setToEnd |
|
238 |
"set the read position to the end of the collection" |
|
239 |
||
240 |
position := readLimit |
|
241 |
! |
|
242 |
||
243 |
skip:numberToSkip |
|
244 |
"skip the next numberToSkip elements" |
|
245 |
||
246 |
self position:(position + numberToSkip) |
|
247 |
! ! |
|
248 |
||
44 | 249 |
!PositionableStream methodsFor:'chunk input/output'! |
1 | 250 |
|
251 |
nextChunk |
|
252 |
"return the next chunk, i.e. all characters up to the next |
|
217 | 253 |
exclamation mark. Within the chunk, exclamation marks have to be doubled, |
254 |
they are undoubled here. |
|
255 |
Except for primitive code, in which doubling is not needed (allowed). |
|
256 |
This exception was added to make it easier to edit primitive code with |
|
257 |
external editors. However, this means, that other Smalltalks cannot always |
|
258 |
read chunks containing primitive code |
|
259 |
- but that doesnt really matter, since C-primitives are an ST/X feature anyway." |
|
1 | 260 |
|
261 |
|theString sep newString done thisChar nextChar inPrimitive |
|
262 |
index "{ Class:SmallInteger }" |
|
263 |
currSize "{ Class:SmallInteger }" | |
|
264 |
||
276 | 265 |
sep := ChunkSeparator. |
1 | 266 |
theString := String new:500. |
267 |
currSize := 500. |
|
268 |
thisChar := self skipSeparators. |
|
269 |
thisChar := self next. |
|
270 |
index := 0. |
|
271 |
done := false. |
|
272 |
inPrimitive := false. |
|
273 |
||
274 |
[done] whileFalse:[ |
|
159 | 275 |
((index + 2) <= currSize) ifFalse:[ |
276 |
newString := String new:(currSize * 2). |
|
277 |
newString replaceFrom:1 to:currSize with:theString. |
|
278 |
currSize := currSize * 2. |
|
279 |
theString := newString |
|
280 |
]. |
|
281 |
thisChar isNil ifTrue:[ |
|
282 |
done := true |
|
283 |
] ifFalse:[ |
|
284 |
(thisChar == $% ) ifTrue:[ |
|
285 |
nextChar := self peek. |
|
286 |
(nextChar == ${ ) ifTrue:[ |
|
287 |
inPrimitive := true. |
|
288 |
index := index + 1. |
|
289 |
theString at:index put:thisChar. |
|
290 |
thisChar := self next |
|
291 |
] ifFalse:[ |
|
292 |
(nextChar == $} ) ifTrue:[ |
|
293 |
inPrimitive := false. |
|
294 |
index := index + 1. |
|
295 |
theString at:index put:thisChar. |
|
296 |
thisChar := self next |
|
297 |
] |
|
298 |
] |
|
299 |
] ifFalse:[ |
|
300 |
inPrimitive ifFalse:[ |
|
301 |
(thisChar == sep) ifTrue:[ |
|
302 |
(self peek == sep) ifFalse:[ |
|
303 |
done := true |
|
304 |
] ifTrue:[ |
|
305 |
self next |
|
306 |
] |
|
307 |
] |
|
308 |
] |
|
309 |
] |
|
310 |
]. |
|
311 |
done ifFalse:[ |
|
312 |
index := index + 1. |
|
313 |
theString at:index put:thisChar. |
|
314 |
thisChar := self next |
|
315 |
] |
|
1 | 316 |
]. |
317 |
(index == 0) ifTrue:[^ '']. |
|
57 | 318 |
^ theString copyTo:index |
1 | 319 |
! |
320 |
||
432 | 321 |
nextPutChunkSeparator |
322 |
"append a chunk separator character" |
|
323 |
||
324 |
self nextPut:ChunkSeparator |
|
325 |
||
326 |
"Created: 13.9.1995 / 17:39:26 / claus" |
|
327 |
! |
|
328 |
||
1 | 329 |
nextChunkPut:aString |
330 |
"put aString as a chunk onto the receiver; |
|
217 | 331 |
double all exclamation marks except within primitives and append a |
276 | 332 |
single delimiting exclamation mark at the end. |
333 |
This modification of the chunk format was done to have primitive |
|
334 |
code more readable. (since it must be edited using the fileBrowser). |
|
335 |
Its no incompatibility, since inline primitives are an ST/X special |
|
336 |
anyway." |
|
1 | 337 |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
338 |
|sep stopChars inPrimitive character |
1 | 339 |
index "{ Class:SmallInteger }" |
340 |
endIndex "{ Class:SmallInteger }" |
|
217 | 341 |
stop "{ Class:SmallInteger }" |
253 | 342 |
next "{ Class:SmallInteger }"| |
1 | 343 |
|
276 | 344 |
sep := ChunkSeparator. |
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
345 |
stopChars := '{}' copyWith:sep. |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
346 |
|
1 | 347 |
inPrimitive := false. |
348 |
index := 1. |
|
349 |
endIndex := aString size. |
|
217 | 350 |
stop := endIndex + 1. |
1 | 351 |
|
352 |
[index <= endIndex] whileTrue:[ |
|
217 | 353 |
" |
354 |
find position of next interresting character; |
|
355 |
output stuff up to that one in one piece |
|
356 |
" |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
357 |
next := aString indexOfAny:stopChars startingAt:index ifAbsent:stop. |
1 | 358 |
|
217 | 359 |
((index == 1) and:[next == stop]) ifTrue:[ |
159 | 360 |
self nextPutAll:aString |
361 |
] ifFalse:[ |
|
217 | 362 |
self nextPutAll:aString startingAt:index to:(next - 1) |
159 | 363 |
]. |
1 | 364 |
|
159 | 365 |
index := next. |
366 |
(index <= endIndex) ifTrue:[ |
|
367 |
character := aString at:index. |
|
276 | 368 |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
369 |
(character == ${ ) ifTrue:[ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
370 |
"/ starts a primitive |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
371 |
((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
372 |
inPrimitive := true |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
373 |
] |
159 | 374 |
] ifFalse:[ |
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
375 |
"/ ends a primitive |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
376 |
(character == $} ) ifTrue:[ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
377 |
((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
378 |
inPrimitive := false |
159 | 379 |
] |
380 |
] ifFalse:[ |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
381 |
"/ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
382 |
"/ exclas have to be doubled - except if within a primitive |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
383 |
"/ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
384 |
inPrimitive ifFalse:[ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
385 |
(character == sep) ifTrue:[ |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
386 |
self nextPut:sep |
159 | 387 |
] |
388 |
] |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
389 |
] |
159 | 390 |
]. |
276 | 391 |
|
159 | 392 |
self nextPut:character. |
393 |
index := index + 1 |
|
394 |
] |
|
1 | 395 |
]. |
396 |
self nextPut:sep |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
397 |
|
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
398 |
"Modified: 10.11.1995 / 16:04:49 / cg" |
44 | 399 |
! ! |
400 |
||
401 |
!PositionableStream methodsFor:'fileIn'! |
|
402 |
||
403 |
fileIn |
|
404 |
"file in from the receiver, i.e. read chunks and evaluate them - |
|
405 |
return the value of the last chunk." |
|
406 |
||
283 | 407 |
^ self fileInNotifying:(SourceFileLoader on:self) passChunk:true |
44 | 408 |
! |
409 |
||
282 | 410 |
fileInNotifying:someone passChunk:passChunk |
44 | 411 |
"file in from the receiver, i.e. read chunks and evaluate them - |
412 |
return the value of the last chunk. |
|
93 | 413 |
Someone (which is usually some codeView) is notified of errors." |
44 | 414 |
|
415 |
|lastValue| |
|
416 |
||
282 | 417 |
" |
418 |
catch any errors during fileIn |
|
419 |
- offer debug/abort/continue choice |
|
420 |
" |
|
159 | 421 |
Object errorSignal handle:[:ex | |
362 | 422 |
|action what sender| |
423 |
||
424 |
what := ex errorString. |
|
425 |
what isNil ifTrue:[ |
|
426 |
what := ex signal notifierString. |
|
427 |
]. |
|
44 | 428 |
|
159 | 429 |
"handle the case where no GUI has been built in, |
430 |
just abort the fileIn with a notification" |
|
44 | 431 |
|
159 | 432 |
Display isNil ifTrue:[ |
362 | 433 |
sender := ex suspendedContext sender. |
434 |
self notify:(what , |
|
435 |
' in ' , sender receiver class name , |
|
436 |
'>>>' , sender selector). |
|
159 | 437 |
ex return |
438 |
]. |
|
44 | 439 |
|
159 | 440 |
"otherwise ask what should be done now and either |
441 |
continue or abort the fileIn" |
|
44 | 442 |
|
159 | 443 |
action := self askForDebug:('error in fileIn: ' , what) withCRs. |
444 |
action == #continue ifTrue:[ |
|
445 |
ex proceed |
|
446 |
]. |
|
447 |
action == #abort ifTrue:[ |
|
448 |
ex return |
|
449 |
]. |
|
253 | 450 |
"/ Debugger enter:ex suspendedContext |
362 | 451 |
(ex signal) enterDebuggerWith:ex message:what. |
452 |
ex reject |
|
44 | 453 |
] do:[ |
159 | 454 |
[self atEnd] whileFalse:[ |
282 | 455 |
lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk |
159 | 456 |
] |
44 | 457 |
]. |
458 |
^ lastValue |
|
459 |
! |
|
460 |
||
1 | 461 |
fileInNextChunkNotifying:someone |
462 |
"read next chunk, evaluate it and return the result; |
|
276 | 463 |
someone (which is usually some codeView) is notified of errors. |
464 |
Filein is done as follows: |
|
465 |
read a chunk |
|
466 |
if it started with an excla, evaluate it, and let the resulting object |
|
467 |
fileIn more chunks. |
|
468 |
This is a nice trick, since the methodsFor: expression evaluates to |
|
469 |
a ClassCategoryReader which reads and compiles chunks for its class. |
|
470 |
However, other than methodsFor expressions are possible - you can |
|
471 |
(in theory) create readers for any syntax. |
|
472 |
" |
|
1 | 473 |
|
282 | 474 |
^ self fileInNextChunkNotifying:someone passChunk:false |
475 |
! |
|
476 |
||
477 |
fileInNextChunkNotifying:someone passChunk:passChunk |
|
478 |
"read next chunk, evaluate it and return the result; |
|
479 |
someone (which is usually some codeView) is notified of errors. |
|
480 |
Filein is done as follows: |
|
481 |
read a chunk |
|
482 |
if it started with an excla, evaluate it, and let the resulting object |
|
483 |
fileIn more chunks. |
|
484 |
This is a nice trick, since the methodsFor: expression evaluates to |
|
485 |
a ClassCategoryReader which reads and compiles chunks for its class. |
|
486 |
However, other than methodsFor expressions are possible - you can |
|
487 |
(in theory) create readers for any syntax. |
|
488 |
" |
|
489 |
||
276 | 490 |
|aString sawExcla rslt done| |
1 | 491 |
|
492 |
self skipSeparators. |
|
493 |
self atEnd ifFalse:[ |
|
276 | 494 |
sawExcla := self peekFor:ChunkSeparator. |
159 | 495 |
aString := self nextChunk. |
496 |
aString size ~~ 0 ifTrue:[ |
|
282 | 497 |
passChunk ifTrue:[ |
498 |
someone source:aString |
|
499 |
]. |
|
500 |
sawExcla ifFalse:[ |
|
501 |
rslt := Compiler evaluate:aString notifying:someone. |
|
502 |
] ifTrue:[ |
|
503 |
rslt := Compiler evaluate:aString notifying:someone compile:false. |
|
504 |
||
159 | 505 |
" |
506 |
usually, the above chunk consists of some methodsFor:-expression |
|
507 |
in this case, the returned value is a ClassCategoryReader, |
|
508 |
which is used to load & compile the methods ... |
|
509 |
" |
|
253 | 510 |
rslt isNil ifTrue:[ |
511 |
" |
|
512 |
however, if that was nil (i.e. some error), we skip chunks |
|
513 |
up to the next empty chunk. |
|
514 |
" |
|
515 |
Transcript showCr:'skipping chunks ...'. |
|
516 |
done := false. |
|
517 |
[done] whileFalse:[ |
|
518 |
aString := self nextChunk. |
|
276 | 519 |
done := (aString size == 0) or:[aString isEmpty]. |
253 | 520 |
] |
521 |
] ifFalse:[ |
|
329 | 522 |
rslt := rslt fileInFrom:self notifying:someone passChunk:passChunk |
253 | 523 |
] |
159 | 524 |
] |
525 |
] |
|
1 | 526 |
]. |
159 | 527 |
^ rslt |
1 | 528 |
! |
529 |
||
530 |
askForDebug:message |
|
41 | 531 |
"launch a box asking if a debugger is wanted - used when an error |
532 |
occurs while filing in" |
|
533 |
||
180 | 534 |
Smalltalk isInitialized ifFalse:[ |
535 |
'error during startup: ' errorPrint. message errorPrintNL. |
|
536 |
^ #debug |
|
537 |
]. |
|
282 | 538 |
^ OptionBox |
539 |
request:message |
|
540 |
label:'Error in fileIn' |
|
541 |
form:(WarningBox iconBitmap) |
|
542 |
buttonLabels:#('abort' 'debug' 'continue') |
|
362 | 543 |
values:#(#abort #debug #continue) |
544 |
default:#continue. |
|
44 | 545 |
! ! |