Parser.st
changeset 45 e8331ba8ad5d
parent 44 74ddc944c27f
child 47 f861ad42703e
--- a/Parser.st	Sun Oct 02 23:01:25 1994 +0100
+++ b/Parser.st	Mon Oct 10 01:58:23 1994 +0100
@@ -38,7 +38,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	     All Rights Reserved
 
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.15 1994-10-02 22:01:25 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.16 1994-10-10 00:56:40 claus Exp $
 '!
 
 !Parser class methodsFor:'documentation'!
@@ -59,7 +59,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.15 1994-10-02 22:01:25 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.16 1994-10-10 00:56:40 claus Exp $
 "
 !
 
@@ -1492,7 +1492,7 @@
 primary
     "parse a primary-expression; return a node-tree, nil or #Error"
 
-    |val var expr pos name t sym|
+    |val var expr pos name t|
 
     pos := tokenPosition.
     (tokenType == #Self) ifTrue:[
@@ -2067,13 +2067,22 @@
 byteArray
     "started with ST-80 R4 - allow byteArray constants as #[ ... ]"
 
-    |arr elem pos1 pos2|
+    |bytes index limit newArray elem pos1 pos2|
 
     pos1 := tokenPosition.
-    arr := OrderedCollection new:50.
+    bytes := ByteArray new:5000.
+    index := 0. limit := 5000.
     [tokenType ~~ $] ] whileTrue:[
 	pos2 := tokenPosition.
-	elem := self arrayConstant.
+	"
+	 this is not good programming style, but speeds up
+	 reading of huge byte arrays (i.e. stored Images ...)
+	"
+	(tokenType == #Integer) ifTrue:[
+	    elem := tokenValue
+	] ifFalse:[
+	    elem := self arrayConstant.
+	].
 	(elem == #Error) ifTrue:[
 	    (tokenType == #EOF) ifTrue:[
 		self syntaxError:'unterminated bytearray-constant; '']'' expected' 
@@ -2083,13 +2092,22 @@
 	].
 	((elem isMemberOf:SmallInteger) and:
 	[(elem >= 0) and:[elem <= 255]]) ifTrue:[
-	    arr add:elem
+	    index := index + 1.
+	    bytes at:index put:elem.
+	    index == limit ifTrue:[
+		newArray := ByteArray new:(limit * 2).
+		newArray replaceFrom:1 to:limit with:bytes startingAt:1.
+		limit := limit * 2.
+		bytes := newArray
+	    ].
 	] ifFalse:[
 	    self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1
 	].
-	self nextToken
+	self nextToken.
     ].
-    ^ ByteArray withAll:arr
+    newArray := ByteArray new:index.
+    newArray replaceFrom:1 to:index with:bytes startingAt:1.
+    ^ newArray
 !
 
 arrayConstant
@@ -2482,8 +2500,13 @@
 
     |ok err sym node|
 
+    "
+     if compiling lazy, or errors are to be ignored, or there
+     is no requestor, do not check
+    "
     (LazyCompilation == true) ifTrue:[^ aSelectorString].
     (ignoreErrors or:[ignoreWarnings]) ifTrue:[^ aSelectorString].
+    requestor isNil ifTrue:[^ aSelectorString].
 
     err := ' is currently nowhere implemented'.
     "
@@ -2525,7 +2548,16 @@
 				ok := ok or:[aClass implements:sym]
 			    ].
 			]
-		    ]
+		    ].
+		    ok ifTrue:[
+			"if its a super send, we can do more checking"
+			receiver type == #Super ifTrue:[
+			    (classToCompileFor superclass whichClassImplements:sym) isNil ifTrue:[
+				err := ' is currently not implemented in any superclass'.
+				ok := false
+			    ]
+			]
+		    ].
 		]
 	    ]
 	]