--- a/PositionableStream.st Tue Feb 21 02:07:07 1995 +0100
+++ b/PositionableStream.st Wed Feb 22 02:14:51 1995 +0100
@@ -12,7 +12,7 @@
PeekableStream subclass:#PositionableStream
instanceVariableNames:'collection position readLimit'
- classVariableNames:'ErrorDuringFileInSignal'
+ classVariableNames:'ErrorDuringFileInSignal ChunkSeparator'
poolDictionaries:''
category:'Streams'
!
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.19 1995-02-15 10:27:49 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.20 1995-02-22 01:14:21 claus Exp $
'!
!PositionableStream class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.19 1995-02-15 10:27:49 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.20 1995-02-22 01:14:21 claus Exp $
"
!
@@ -66,6 +66,8 @@
ErrorDuringFileInSignal := Object errorSignal newSignalMayProceed:true.
ErrorDuringFileInSignal nameClass:self message:#errorDuringFileInSignal.
ErrorDuringFileInSignal notifierString:'error during fileIn'.
+
+ ChunkSeparator := $!!
]
! !
@@ -74,7 +76,7 @@
chunkSeparator
"return the chunk-separation character"
- ^ $!!
+ ^ ChunkSeparator
! !
!PositionableStream class methodsFor:'instance creation'!
@@ -235,7 +237,7 @@
index "{ Class:SmallInteger }"
currSize "{ Class:SmallInteger }" |
- sep := self class chunkSeparator.
+ sep := ChunkSeparator.
theString := String new:500.
currSize := 500.
thisChar := self skipSeparators.
@@ -294,7 +296,11 @@
nextChunkPut:aString
"put aString as a chunk onto the receiver;
double all exclamation marks except within primitives and append a
- single delimiting exclamation mark at the end."
+ single delimiting exclamation mark at the end.
+ This modification of the chunk format was done to have primitive
+ code more readable. (since it must be edited using the fileBrowser).
+ Its no incompatibility, since inline primitives are an ST/X special
+ anyway."
|sep gotPercent inPrimitive character
index "{ Class:SmallInteger }"
@@ -302,7 +308,7 @@
stop "{ Class:SmallInteger }"
next "{ Class:SmallInteger }"|
- sep := self class chunkSeparator.
+ sep := ChunkSeparator.
inPrimitive := false.
gotPercent := false.
index := 1.
@@ -331,6 +337,7 @@
index := next.
(index <= endIndex) ifTrue:[
character := aString at:index.
+
(character == $% ) ifTrue:[
gotPercent := true
] ifFalse:[
@@ -353,6 +360,7 @@
].
gotPercent := false
].
+
self nextPut:character.
index := index + 1
]
@@ -422,14 +430,22 @@
fileInNextChunkNotifying:someone
"read next chunk, evaluate it and return the result;
- someone (which is usually some codeView) is notified of errors."
+ 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 sep rslt done|
+ |aString sawExcla rslt done|
- sep := self class chunkSeparator.
self skipSeparators.
self atEnd ifFalse:[
- sawExcla := self peekFor:sep.
+ sawExcla := self peekFor:ChunkSeparator.
aString := self nextChunk.
aString size ~~ 0 ifTrue:[
rslt := Compiler evaluate:aString notifying:someone.
@@ -448,7 +464,7 @@
done := false.
[done] whileFalse:[
aString := self nextChunk.
- done := aString size == 0 or:[aString isEmpty].
+ done := (aString size == 0) or:[aString isEmpty].
]
] ifFalse:[
rslt := rslt fileInFrom:self notifying:someone
@@ -457,7 +473,6 @@
]
].
^ rslt
-
!
askForDebug:message