Parser.st
changeset 52 d80ec10c3321
parent 51 124369e443f8
child 53 c5dd7abf8431
--- a/Parser.st	Tue Nov 22 01:23:56 1994 +0100
+++ b/Parser.st	Mon Nov 28 21:58:48 1994 +0100
@@ -38,7 +38,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	     All Rights Reserved
 
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.20 1994-11-22 00:23:56 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.21 1994-11-28 20:58:37 claus Exp $
 '!
 
 !Parser class methodsFor:'documentation'!
@@ -59,7 +59,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.20 1994-11-22 00:23:56 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.21 1994-11-28 20:58:37 claus Exp $
 "
 !
 
@@ -256,7 +256,7 @@
      If logged is true, an entry is added to the change-file. If the failBlock argument
      is non-nil, it is evaluated if an error occurs."
 
-    |parser tree mustBackup loggedString chgStream value|
+    |parser tree mustBackup loggedString chgStream value s sReal m|
 
     aStringOrStream isNil ifTrue:[^ nil].
     aStringOrStream isStream ifTrue:[
@@ -298,6 +298,9 @@
 
 	"
 	 if the parse tree is that of a constant, quickly return its value
+	 this is used for example, when reading objects simple objects
+	 via readFrom:. The overhead of compiling a method is avoided in this
+	 case.
 	"
 	tree isConstant ifTrue:[
 	    ^ tree evaluate
@@ -305,14 +308,37 @@
 	    "
 	     if I am the ByteCodeCompiler,
 	     generate a dummy method, execute it and return the value.
-	     otherwise, just evaluate the tree; slow, but not too bad ...
+	     otherwise, just evaluate the tree; slower, but not too bad ...
+	     This allows systems to be delivered without the ByteCodeCompiler,
+	     and still evaluate expressions (neede for example, to read resource
+	     files).
 	    "
-"/            self == Parser ifTrue:[
+	    self == Parser ifTrue:[
 		parser evalExitBlock:[:value | parser release. ^ value].
 		value := tree evaluate.
 		parser evalExitBlock:nil.
-"/            ] ifFalse:[
-"/            ]
+	    ] ifFalse:[
+		aStringOrStream isStream ifTrue:[
+		    s := aStringOrStream contents.
+		] ifFalse:[
+		    s := aStringOrStream
+		].
+		sReal := 'doIt ^[\' withCRs , s , '\] value' withCRs.
+		m := self compile:sReal forClass:anObject class
+			  inCategory:'_temporary_' notifying:requestor
+			  install:false skipIfSame:false silent:true.
+		m notNil ifTrue:[
+		    "
+		     fake: patch the source string, to what the user expects
+		     in the browser
+		    "
+		    m source:'       \' withCRs , s .
+		    value := m valueWithReceiver:anObject 
+				       arguments:#() 
+					selector:#doIt 
+					  search:nil.
+		].
+	    ]
 	]
     ].
     parser release.