--- a/PositionableStream.st Fri Feb 24 17:32:55 1995 +0100
+++ b/PositionableStream.st Fri Feb 24 17:38:46 1995 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.20 1995-02-22 01:14:21 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.21 1995-02-24 16:37:50 claus Exp $
'!
!PositionableStream class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.20 1995-02-22 01:14:21 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.21 1995-02-24 16:37:50 claus Exp $
"
!
@@ -374,22 +374,20 @@
"file in from the receiver, i.e. read chunks and evaluate them -
return the value of the last chunk."
- ^ self fileInNotifying:self
+ ^ self fileInNotifying:(CompilationErrorHandler on:self) passChunk:true
!
-fileInNextChunk
- "read next chunk, evaluate it and return the result"
-
- ^ self fileInNextChunkNotifying:nil
-!
-
-fileInNotifying:someone
+fileInNotifying:someone passChunk:passChunk
"file in from the receiver, i.e. read chunks and evaluate them -
return the value of the last chunk.
Someone (which is usually some codeView) is notified of errors."
|lastValue|
+ "
+ catch any errors during fileIn
+ - offer debug/abort/continue choice
+ "
Object errorSignal handle:[:ex |
|action what|
@@ -422,7 +420,7 @@
"ex reject"
] do:[
[self atEnd] whileFalse:[
- lastValue := self fileInNextChunkNotifying:someone
+ lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk
]
].
^ lastValue
@@ -441,6 +439,22 @@
(in theory) create readers for any syntax.
"
+ ^ self fileInNextChunkNotifying:someone passChunk:false
+!
+
+fileInNextChunkNotifying:someone passChunk:passChunk
+ "read next chunk, evaluate it and return the result;
+ someone (which is usually some codeView) is notified of errors.
+ Filein is done as follows:
+ read a chunk
+ if it started with an excla, evaluate it, and let the resulting object
+ fileIn more chunks.
+ This is a nice trick, since the methodsFor: expression evaluates to
+ a ClassCategoryReader which reads and compiles chunks for its class.
+ However, other than methodsFor expressions are possible - you can
+ (in theory) create readers for any syntax.
+ "
+
|aString sawExcla rslt done|
self skipSeparators.
@@ -448,8 +462,14 @@
sawExcla := self peekFor:ChunkSeparator.
aString := self nextChunk.
aString size ~~ 0 ifTrue:[
- rslt := Compiler evaluate:aString notifying:someone.
- sawExcla ifTrue:[
+ passChunk ifTrue:[
+ someone source:aString
+ ].
+ sawExcla ifFalse:[
+ rslt := Compiler evaluate:aString notifying:someone.
+ ] ifTrue:[
+ rslt := Compiler evaluate:aString notifying:someone compile:false.
+
"
usually, the above chunk consists of some methodsFor:-expression
in this case, the returned value is a ClassCategoryReader,
@@ -479,44 +499,14 @@
"launch a box asking if a debugger is wanted - used when an error
occurs while filing in"
- |box|
-
Smalltalk isInitialized ifFalse:[
'error during startup: ' errorPrint. message errorPrintNL.
^ #debug
].
- box := OptionBox title:message numberOfOptions:3.
- box actions:(Array with:[^ #abort]
- with:[^ #debug]
- with:[^ #continue]).
- box buttonTitles:#('abort' 'debug' 'continue').
- box label:'fileIn Error'.
- box showAtPointer.
- ^ #abort
+ ^ OptionBox
+ request:message
+ label:'Error in fileIn'
+ form:(WarningBox iconBitmap)
+ buttonLabels:#('abort' 'debug' 'continue')
+ values:#(#abort #debug #continue).
! !
-
-!PositionableStream methodsFor:'fileIn error handling'!
-
-error:aMessage position:position to:endPos
- "error notification during fileIn with no requestor.
- This is sent by the compiler/evaluator if it detects errors."
-
-"/ position printOn:Transcript.
-"/ Transcript show:' '.
- Transcript showCr:aMessage.
- ^ false
-!
-
-correctableError:aMessage position:position to:endPos
- "error notification during fileIn with no requestor.
- This is sent by the compiler/evaluator if it detects errors."
-
- ^ self error:aMessage position:position to:endPos
-!
-
-warning:aMessage position:position to:endPos
- "warning notification during fileIn with no requestor - ignore it.
- This is sent by the compiler/evaluator if it detects errors."
-
- ^ self
-! !