--- a/compiler/TTypechecker.st Tue Sep 22 17:43:38 2015 +0100
+++ b/compiler/TTypechecker.st Wed Sep 23 22:21:44 2015 +0100
@@ -25,6 +25,24 @@
!TTypechecker methodsFor:'visitor-double dispatching'!
+acceptBlockNode: aBlockNode
+ | formalType actualType |
+
+ super acceptBlockNode: aBlockNode.
+
+ formalType := aBlockNode binding type.
+ actualType := aBlockNode body statements last binding type.
+ formalType isAutomaticType ifTrue:[
+ aBlockNode binding returnType: actualType.
+ ] ifFalse:[
+ formalType = actualType ifFalse:[
+ context reportTypeError: ('Block return type is specified as %1 but actually is %3' bindWith: formalType with: actualType).
+ ].
+ ].
+
+ "Created: / 23-09-2015 / 16:44:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
acceptIfTrueIfFalseNode: node
| receiverType booleanType |
@@ -94,6 +112,25 @@
"Created: / 02-09-2015 / 10:34:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-09-2015 / 14:22:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+acceptWhileTrueNode: node
+ | receiverType booleanType |
+
+ (node isCascaded not or: [node isFirstCascaded]) ifTrue: [
+ self visitNode: node receiver
+ ].
+ node arguments do: [:each | self visitNode: each].
+
+ receiverType := node receiver binding type.
+ booleanType := context environment binding lookupClassBoolean type.
+
+ receiverType = booleanType ifFalse:[
+ context reportTypeError: 'receiver of ifTrue:ifFalse: special form must be of type tBoolean (is ' , receiverType printString.
+ ].
+
+ "Created: / 23-09-2015 / 14:06:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 23-09-2015 / 16:46:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TTypechecker class methodsFor:'documentation'!