--- a/Parser.st Fri Oct 24 15:15:37 2008 +0200
+++ b/Parser.st Fri Oct 31 13:51:27 2008 +0100
@@ -67,6 +67,13 @@
privateIn:Parser
!
+Parser::ParseError subclass:#UndefinedVariableError
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:Parser
+!
+
Notification subclass:#UndefinedVariableNotification
instanceVariableNames:'parser'
classVariableNames:''
@@ -4251,91 +4258,98 @@
]
].
- nameSpaceQuerySignal answer:spc
- do:[
- |method|
-
- "
- if compile is false, or the parse tree is that of a constant,
- or a variable, quickly return its value.
- This is used for example, when reading simple objects
- via #readFrom:.
- The overhead of compiling a method is avoided in this case.
- "
- ((SuppressDoItCompilation == true)
- or:[compile not
- or:[tree isSimpleConstant
- or:[tree isSimpleVariable
- or:[aStringOrStream isStream
- or:[aContext notNil]]]]]) ifTrue:[
- ^ tree evaluate
- ].
-
- "
- if I am the ByteCodeCompiler,
- generate a dummy method, execute it and return the value.
- otherwise, just evaluate the tree; slower, but not too bad ...
-
- This allows systems to be delivered without the ByteCodeCompiler,
- and still evaluate expressions
- (needed to read resource files or to process .rc files).
- "
- self == Parser ifTrue:[
- self evalExitBlock:[:value | self release. ^ value].
- value := tree evaluate.
- self evalExitBlock:nil.
- ] ifFalse:[
- s := self correctedSource.
- s isNil ifTrue:[
- aStringOrStream isStream ifTrue:[
- s := self collectedSource. "/ does not work yet ...
- ] ifFalse:[
- s := aStringOrStream
+ Parser::UndefinedVariableError handle:[:ex |
+ failBlock isNil ifTrue:[
+ ex proceedWith:nil.
+ ].
+ ^ failBlock value
+ ] do:[
+ nameSpaceQuerySignal answer:spc
+ do:[
+ |method|
+
+ "
+ if compile is false, or the parse tree is that of a constant,
+ or a variable, quickly return its value.
+ This is used for example, when reading simple objects
+ via #readFrom:.
+ The overhead of compiling a method is avoided in this case.
+ "
+ ((SuppressDoItCompilation == true)
+ or:[compile not
+ or:[tree isSimpleConstant
+ or:[tree isSimpleVariable
+ or:[aStringOrStream isStream
+ or:[aContext notNil]]]]]) ifTrue:[
+ ^ tree evaluate
+ ].
+
+ "
+ if I am the ByteCodeCompiler,
+ generate a dummy method, execute it and return the value.
+ otherwise, just evaluate the tree; slower, but not too bad ...
+
+ This allows systems to be delivered without the ByteCodeCompiler,
+ and still evaluate expressions
+ (needed to read resource files or to process .rc files).
+ "
+ self == Parser ifTrue:[
+ self evalExitBlock:[:value | self release. ^ value].
+ value := tree evaluate.
+ self evalExitBlock:nil.
+ ] ifFalse:[
+ s := self correctedSource.
+ s isNil ifTrue:[
+ aStringOrStream isStream ifTrue:[
+ s := self collectedSource. "/ does not work yet ...
+ ] ifFalse:[
+ s := aStringOrStream
+ ].
].
- ].
-
- "/ actually, its a block, to allow
- "/ easy return ...
-
- sReal := 'doIt ^[ ' , s , '\] value' withCRs.
-
- compiler := ByteCodeCompiler new.
- compiler initializeFlagsFrom:self.
- method := compiler
- compile:sReal
- forClass:anObject class
- inCategory:'_temporary_'
- notifying:requestor
- install:false
- skipIfSame:false
- silent:true
- foldConstants:false.
-
- method notNil ifTrue:[
- method ~~ #Error ifTrue:[
- "
- fake: patch the source string, to what the user expects
- in the browser
- "
- method source:"' ' , "s string.
- "
- dont do any just-in-time compilation on it.
- "
- method checked:true.
-
- value := method
- valueWithReceiver:anObject
- arguments:nil "/ (Array with:m)
- selector:(requestor isNil ifTrue:#'doItX' ifFalse:#'doIt') "/ #doIt:
- search:nil
- sender:nil.
- ] ifFalse:[
- self evalExitBlock:[:value | self release. ^ value].
- value := tree evaluate.
- self evalExitBlock:nil.
- ]
- ].
- ]
+
+ "/ actually, its a block, to allow
+ "/ easy return ...
+
+ sReal := 'doIt ^[ ' , s , '\] value' withCRs.
+
+ compiler := ByteCodeCompiler new.
+ compiler initializeFlagsFrom:self.
+ method := compiler
+ compile:sReal
+ forClass:anObject class
+ inCategory:'_temporary_'
+ notifying:requestor
+ install:false
+ skipIfSame:false
+ silent:true
+ foldConstants:false.
+
+ method notNil ifTrue:[
+ method ~~ #Error ifTrue:[
+ "
+ fake: patch the source string, to what the user expects
+ in the browser
+ "
+ method source:"' ' , "s string.
+ "
+ dont do any just-in-time compilation on it.
+ "
+ method checked:true.
+
+ value := method
+ valueWithReceiver:anObject
+ arguments:nil "/ (Array with:m)
+ selector:(requestor isNil ifTrue:#'doItX' ifFalse:#'doIt') "/ #doIt:
+ search:nil
+ sender:nil.
+ ] ifFalse:[
+ self evalExitBlock:[:value | self release. ^ value].
+ value := tree evaluate.
+ self evalExitBlock:nil.
+ ]
+ ].
+ ]
+ ].
].
self release.
^ value
@@ -9391,7 +9405,7 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.583 2008-10-24 13:15:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.584 2008-10-31 12:51:27 cg Exp $'
! !
Parser initialize!