PositionableStream.st
changeset 44 b262907c93ea
parent 42 e33491f6f260
child 57 db9677479d35
--- a/PositionableStream.st	Sun Jan 16 04:38:33 1994 +0100
+++ b/PositionableStream.st	Sun Jan 16 04:47:41 1994 +0100
@@ -27,12 +27,14 @@
 and for filing-in/out of source code.
 This is an abstract class.
 
-$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.9 1994-01-12 19:10:02 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.10 1994-01-16 03:44:22 claus Exp $
 '!
 
 !PositionableStream class methodsFor:'initialization'!
 
 initialize
+    "setup the signal used to handle errors during fileIn"
+
     ErrorDuringFileInSignal isNil ifTrue:[
         ErrorDuringFileInSignal := (Signal new) mayProceed:true.
         ErrorDuringFileInSignal notifierString:'error during fileIn'.
@@ -139,13 +141,13 @@
 !
 
 upToEnd
-    "return a collection of the elements up-to the end
+    "return a collection of the elements up-to the end.
      Return nil if the stream-end is reached before."
 
     |newColl|
 
     "this implementation has stupid (o-square) runtime behavior -
-     should I add a query for resizability if collections and use
+     should I add a query for resizability of collection and use
      add: instead ?"
 
     newColl := collection species new.
@@ -229,7 +231,7 @@
     self position:(position + numberToSkip)
 ! !
 
-!PositionableStream methodsFor:'fileIn-Out'!
+!PositionableStream methodsFor:'chunk input/output'!
 
 skipSeparators
     "skip all whitespace; so that next will return next non-white-space
@@ -399,11 +401,68 @@
         ]
     ].
     self nextPut:sep
+! !
+
+!PositionableStream methodsFor:'fileIn'!
+
+fileIn
+    "file in from the receiver, i.e. read chunks and evaluate them -
+     return the value of the last chunk."
+
+    ^ self fileInNotifying:self
+!
+
+fileInNotifying:someone
+    "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|
+
+    SignalSet anySignal handle:[:ex |
+        |action what|
+
+        "handle the case where no GUI has been built in,
+         just abort with a notification"
+
+        Display isNil ifTrue:[
+            self notify:(ex signal notifierString).
+            ex return
+        ].
+
+        "otherwise ask what should be done now and either
+         continue or abort the fileIn"
+
+        what := ex errorString.
+        what isNil ifTrue:[
+            what := ex signal notifierString.
+        ].
+        action := self askForDebug:('error in fileIn: ' , what) withCRs.
+        action == #continue ifTrue:[
+            ex proceed
+        ].
+        action == #abort ifTrue:[
+            ex return
+        ].
+        Debugger enter:ex suspendedContext
+        "ex reject"
+    ] do:[
+        [self atEnd] whileFalse:[
+            lastValue := self fileInNextChunkNotifying:someone
+        ]
+    ].
+    ^ lastValue
+!
+
+fileInNextChunk
+    "read next chunk, evaluate it and return the result"
+
+    ^ self fileInNextChunkNotifying:nil
 !
 
 fileInNextChunkNotifying:someone
     "read next chunk, evaluate it and return the result;
-     someone is notified of errors"
+     someone (which is usually some codeView) is notified of errors."
 
     |aString sawExcla sep|
 
@@ -421,66 +480,7 @@
         ]
     ].
     ^ nil
-!
 
-fileInNextChunk
-    "read next chunk, evaluate it and return the result"
-
-    ^ self fileInNextChunkNotifying:nil
-!
-
-fileInNotifying:someone
-    "file in from the receiver, i.e. read chunks and evaluate them -
-     return the value of the last chunk; someone is notified of errors"
-
-    |lastValue|
-
-"
-    self position:1.
-"
-"
-    Smalltalk at:#ErrorHandler put:self.
-"
-    [
-        "ErrorDuringFileInSignal" SignalSet anySignal handle:[:ex |
-            |action|
-
-            "handle the case where no GUI has been built in,
-             just abort with a notification"
-
-            Display isNil ifTrue:[
-                self notify:(ex signal notifierString).
-                ex return
-            ].
-
-            "otherwise ask what should be done now and either
-             continue or abort the fileIn"
-
-            action := self askForDebug:(ex signal notifierString).
-            action == #continue ifTrue:[
-"
-                Smalltalk at:#ErrorHandler put:self.
-"
-                ex proceed
-            ].
-            action == #abort ifTrue:[
-                ex return
-            ].
-            ex reject
-        ] do:[
-            [self atEnd] whileFalse:[
-                lastValue := self fileInNextChunkNotifying:someone
-            ].
-        ].
-    ] valueNowOrOnUnwindDo:["Smalltalk at:#ErrorHandler put:nil"].
-    ^ lastValue
-!
-
-fileIn
-    "file in from the receiver, i.e. read chunks and evaluate them -
-     return the value of the last chunk"
-
-    ^ self fileInNotifying:self
 !
 
 askForDebug:message
@@ -496,49 +496,13 @@
     box buttonTitles:#('abort' 'debug' 'continue').
     box showAtPointer.
     ^ #abort
-!
-
-catch:aSymbol with:aMessage for:anObject
-    "this one is sent when an error occurs while filing in -
-     we dont want a debugger to come up but simply notify
-     the error (also on the Transcript so you have a trace of it)"
-
-    |message|
-
-    "switch back to regular error handling"
-    Smalltalk at:#ErrorHandler put:nil.
+! !
 
-    (aSymbol == #doesNotUnderstand:) ifTrue:[
-        anObject isNil ifTrue:[
-            "try to give a bit more detail on what went wrong"
-            (Metaclass respondsTo:(aMessage selector)) ifTrue:[
-                ('subclass:*' match:(aMessage selector)) ifTrue:[
-                    message := 'no superclass for ' , (aMessage arguments at:1)
-                ] ifFalse:[
-                    message := 'definitions for nonexisting class'
-                ]
-            ] ifFalse:[
-                message := 'bad message: ' , aMessage selector, ' to UndefinedObject'
-            ]
-        ] ifFalse:[
-            message := 'bad message: ' , aMessage selector ,
-                      ' to ' , anObject classNameWithArticle
-        ]
-    ] ifFalse:[
-        (aSymbol == #error:) ifTrue:[
-            message := aMessage
-        ] ifFalse:[
-            message := 'during fileIn'
-        ]
-    ].
-    message := 'Error: ' , message.
-    Transcript showCr:message.
-    ErrorDuringFileInSignal raiseRequestWith:message.
-    ^ nil
-!
+!PositionableStream methodsFor:'fileIn error handling'!
 
 error:aMessage position:position to:endPos
-    "error notification during fileIn with no requestor"
+    "error notification during fileIn with no requestor.
+     This is sent by the compiler/evaluator if it detects errors."
 
     position printOn:Transcript.
     Transcript show:' '.
@@ -547,13 +511,15 @@
 !
 
 correctableError:aMessage position:position to:endPos
-    "error notification during fileIn with no requestor"
+    "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"
+    "warning notification during fileIn with no requestor - ignore it.
+     This is sent by the compiler/evaluator if it detects errors."
 
     ^ self
 ! !