--- a/Parser.st Fri Feb 24 16:21:56 1995 +0100
+++ b/Parser.st Fri Feb 24 16:22:33 1995 +0100
@@ -39,7 +39,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.29 1995-02-20 22:57:14 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.30 1995-02-24 15:22:08 claus Exp $
'!
!Parser class methodsFor:'documentation'!
@@ -60,7 +60,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.29 1995-02-20 22:57:14 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.30 1995-02-24 15:22:08 claus Exp $
"
!
@@ -172,7 +172,8 @@
!Parser class methodsFor:'evaluating expressions'!
evaluate:aStringOrStream
- "return the result of evaluating an expression in aStringOrStream"
+ "return the result of evaluating an expression in aStringOrStream.
+ No doit-entry is added to the changeLog."
^ self
evaluate:aStringOrStream
@@ -181,6 +182,7 @@
notifying:nil
logged:false
ifFail:nil
+ compile:true
"
Compiler evaluate:'1 + 2'
@@ -189,9 +191,30 @@
"
!
+evaluate:aStringOrStream compile:compile
+ "return the result of evaluating aString,
+ The compile argument specifies if the string should be compiled down to
+ bytecode or instead be interpreted from the parseTree.
+ The first should be done for doIts etc, where a readable walkback is
+ required.
+ The latter is better done for constants, styleSheet and resource
+ reading and simple sends, where the overhead of compilation is bigger
+ than the interpretation overhead."
+
+ ^ self
+ evaluate:aStringOrStream
+ in:nil
+ receiver:nil
+ notifying:nil
+ logged:false
+ ifFail:nil
+ compile:compile
+!
+
evaluate:aStringOrStream ifFail:failBlock
"return the result of evaluating an expression in aStringOrStream.
- In case of any syntax errors, return the value of failBlock."
+ In case of any syntax errors, return the value of failBlock.
+ No doit-entry is added to the changeLog."
^ self
evaluate:aStringOrStream
@@ -200,15 +223,15 @@
notifying:nil
logged:false
ifFail:failBlock
-
+ compile:true
"
Compiler evaluate:'1 +' ifFail:['oops']
-
"
!
evaluate:aStringOrStream logged:logged
- "return the result of evaluating an expression in aStringOrStream"
+ "return the result of evaluating an expression in aStringOrStream.
+ The argument log controls if an entry is added to the changeLog."
^ self
evaluate:aStringOrStream
@@ -217,6 +240,11 @@
notifying:nil
logged:logged
ifFail:nil
+ compile:true
+ "
+ Compiler evaluate:'''some string''' logged:false
+ Compiler evaluate:'''some string''' logged:true
+ "
!
evaluate:aStringOrStream notifying:requestor
@@ -230,7 +258,28 @@
notifying:requestor
logged:false
ifFail:nil
-
+ compile:true
+!
+
+evaluate:aStringOrStream notifying:requestor compile:compile
+ "return the result of evaluating aString,
+ errors are reported to requestor.
+ The compile argument specifies if the string should be compiled down to
+ bytecode or instead be interpreted from the parseTree.
+ The first should be done for doIts etc, where a readable walkback is
+ required.
+ The latter is better done for constants, styleSheet and resource
+ reading and simple sends, where the overhead of compilation is bigger
+ than the interpretation overhead."
+
+ ^ self
+ evaluate:aStringOrStream
+ in:nil
+ receiver:nil
+ notifying:requestor
+ logged:false
+ ifFail:nil
+ compile:compile
!
evaluate:aStringOrStream receiver:anObject notifying:requestor
@@ -245,11 +294,25 @@
notifying:requestor
logged:false
ifFail:nil
+ compile:true
+
+ "
+ Compiler evaluate:'self x' receiver:(1 @ 2) notifying:nil
+ "
!
-evaluate:aStringOrStream in:aContext receiver:anObject
- notifying:requestor
- ifFail:failBlock
+evaluate:aStringOrStream receiver:anObject notifying:requestor compile:compile
+ "return the result of evaluating aString,
+ errors are reported to requestor. Allow access to
+ anObject as self and to its instVars (used in the inspector).
+ The compile argument specifies if the string should be compiled down to
+ bytecode or instead be interpreted from the parseTree.
+ The first should be done for doIts etc, where a readable walkback is
+ required.
+ The latter is better done for constants, styleSheet and resource
+ reading and simple sends, where the overhead of compilation is bigger
+ than the interpretation overhead."
+
^ self
evaluate:aStringOrStream
in:nil
@@ -257,6 +320,23 @@
notifying:requestor
logged:false
ifFail:nil
+ compile:compile
+!
+
+evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor ifFail:failBlock
+ "return the result of evaluating aStringOrStream, errors are reported to requestor.
+ Allow access to anObject as self and to its instVars (used in the inspector).
+ No doIt entry is added to the change-file.
+ If the failBlock argument is non-nil, it is evaluated if an error occurs."
+
+ ^ self
+ evaluate:aStringOrStream
+ in:nil
+ receiver:anObject
+ notifying:requestor
+ logged:false
+ ifFail:nil
+ compile:true
!
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock
@@ -265,6 +345,29 @@
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."
+ ^ self
+ evaluate:aStringOrStream
+ in:aContext
+ receiver:anObject
+ notifying:requestor
+ logged:logged
+ ifFail:failBlock
+ compile:true
+!
+
+evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile
+ "return the result of evaluating aStringOrStream, errors are reported to requestor.
+ Allow access to anObject as self and to its instVars (used in the inspector).
+ 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.
+ Finally, compile specifies if the string should be compiled down to
+ bytecode or instead be interpreted from the parseTree.
+ The first should be done for doIts etc, where a readable walkback is
+ required.
+ The latter is better done for constants, styleSheet and resource
+ reading and simple sends, where the overhead of compilation is bigger
+ than the interpretation overhead."
+
|parser tree mustBackup loggedString chgStream value s sReal m|
aStringOrStream isNil ifTrue:[^ nil].
@@ -306,12 +409,13 @@
].
"
- if the parse tree is that of a constant, 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.
+ if compile is false, or the parse tree is that of a constant,
+ 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.
"
- tree isConstant ifTrue:[
+ (compile not or:[tree isConstant]) ifTrue:[
^ tree evaluate
] ifFalse:[
"
@@ -981,6 +1085,8 @@
"redefined since parser can give more detailed info about
the class & selector where the error occured."
+ |text|
+
ignoreErrors ifFalse:[
Smalltalk silentLoading == true ifFalse:[
Transcript show:(pos printString).
@@ -988,17 +1094,18 @@
selector notNil ifTrue:[
Transcript show:aMessage.
classToCompileFor notNil ifTrue:[
- Transcript showCr:(' in ' , classToCompileFor name , '>>' , selector)
+ text := ' in ' , classToCompileFor name , '>>' , selector
] ifFalse:[
- Transcript showCr:(' in ' , selector)
+ text := ' in ' , selector
]
] ifFalse:[
classToCompileFor notNil ifTrue:[
- Transcript showCr:aMessage , ' (' , classToCompileFor name , ')'
+ text := aMessage , ' (' , classToCompileFor name , ')'
] ifFalse:[
- Transcript showCr:aMessage
+ text := aMessage
]
- ]
+ ].
+ Transcript showCr:text.
]
]
!
@@ -1203,18 +1310,20 @@
| <empty>
"
- |stats|
+ |stats pos wmsg|
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[
"an ST-80 primitive - parsed but ignored"
+ pos := tokenPosition.
self nextToken.
primitiveNr := self parseST80Primitive.
(primitiveNr == #Error) ifTrue:[^ #Error].
primitiveNr < 0 ifTrue:[
- self warning:'ST-80 directive ignored'
+ wmsg := 'ST-80 directive ignored'
] ifFalse:[
- self warning:'ST-80 primitive ignored'
- ]
+ wmsg := 'ST-80 primitive ignored'
+ ].
+ self warning:wmsg position:pos
].
(self parseMethodBodyVarSpec == #Error) ifTrue:[^ #Error].