--- a/MessageNode.st Tue Aug 16 17:59:13 2005 +0200
+++ b/MessageNode.st Thu Sep 15 13:29:36 2005 +0200
@@ -349,6 +349,37 @@
!MessageNode methodsFor:'checks'!
+checkCondition
+ |args lastArg|
+
+ receiver isBlock ifTrue:[
+ (Block canUnderstand:selector) ifFalse:[
+ ^ 'blocks usually do not respond to ' , selector , ' messages'
+ ].
+ ].
+
+ "/ (rr keyw:ra = a) ifTrue:[ ...]
+
+ receiver isMessage ifTrue:[
+ (receiver numArgs > 0) ifTrue:[
+ (receiver selector isKeyword) ifTrue:[
+ (args := receiver arguments) notEmptyOrNil ifTrue:[
+ (lastArg := args last) isMessage ifTrue:[
+ lastArg parenthized ifFalse:[
+ (#( #'=' #'~=' #'==' #'~~' '>' '<' '>=' '<=')
+ includes:(lastArg selector)) ifTrue:[
+ ^ 'possible precedence error (missing parenthesis) in condition'
+ ]
+ ]
+ ]
+ ]
+ ]
+ ].
+ ].
+
+ ^ nil
+!
+
checkInlinability
"early check for possible inlinability"
@@ -448,7 +479,7 @@
!
plausibilityCheck
- |rec arg1 arg2 arg1Value operand|
+ |rec arg1 arg2 arg1Value operand msg|
(argArray size > 0) ifTrue:[
arg1 := argArray at:1
@@ -497,11 +528,7 @@
an error often occuring when you are a beginner ...
"
((selector == #ifTrue:) or:[selector == #ifFalse:]) ifTrue:[
- receiver isBlock ifTrue:[
- (Block canUnderstand:selector) ifFalse:[
- ^ 'blocks usually do not respond to ' , selector , ' messages'
- ].
- ].
+ (msg := self checkCondition) notNil ifTrue:[^ msg].
"/ arg1 isBlock ifFalse:[
"/ arg1 isConstant ifFalse:[
"/ ^ 'will fail at runtime, if argument to ' , selector , ' does not evaluate to a block or respond reasonable to #value'
@@ -509,11 +536,7 @@
"/ ]
].
((selector == #ifTrue:ifFalse:) or:[selector == #ifFalse:ifTrue:]) ifTrue:[
- receiver isBlock ifTrue:[
- (Block canUnderstand:selector) ifFalse:[
- ^ 'blocks usually do not respond to ' , selector , ' messages'
- ].
- ].
+ (msg := self checkCondition) notNil ifTrue:[^ msg].
"/ arg1 isBlock ifFalse:[
"/ arg1 isConstant ifFalse:[
"/ ^ 'will fail at runtime, if 1st. argument to ' , selector , ' does not evaluate to a block or respond reasonable to #value'
@@ -2914,5 +2937,5 @@
!MessageNode class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.144 2005-04-20 14:40:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.145 2005-09-15 11:29:36 cg Exp $'
! !