Initial shot of scopes & bindings and type checking. Must be rethought.
"{ Package: 'jv:tea/compiler' }"
"{ NameSpace: Smalltalk }"
TProgramNodeVisitor subclass:#TSemanticAnalyzer
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Languages-Tea-Compiler-Analysis'
!
!TSemanticAnalyzer class methodsFor:'documentation'!
documentation
"
This pass analyzes the tree, creates scopes and
initializes variable bindings.
[author:]
Jan Vrany <jan.vrany@fit.cvut.cz>
[instance variables:]
[class variables:]
[see also:]
"
! !
!TSemanticAnalyzer methodsFor:'visiting'!
visitArgument: anRBVariableNode
| binding |
anRBVariableNode parent isSequence ifTrue:[
binding := TLocalBinding type:anRBVariableNode typeSpec asType
name:anRBVariableNode name.
] ifFalse:[
binding := TArgumentBinding type:anRBVariableNode typeSpec asType
name:anRBVariableNode name.
].
anRBVariableNode parent scope addVariable: binding.
super visitArgument: anRBVariableNode.
"Created: / 25-08-2015 / 22:51:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TSemanticAnalyzer methodsFor:'visitor-double dispatching'!
acceptBlockNode: aBlockNode
aBlockNode scope: (aBlockNode parent scope subScope: aBlockNode).
super acceptBlockNode: aBlockNode
"Created: / 25-08-2015 / 22:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
acceptLiteralNode: aRBLiteralNode
aRBLiteralNode binding: (TConstantBinding value: aRBLiteralNode value).
super acceptLiteralNode: aRBLiteralNode
"Created: / 25-08-2015 / 23:17:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
acceptMethodNode: aMethodNode
aMethodNode scope: (TScope node: aMethodNode).
super acceptMethodNode: aMethodNode
"Created: / 25-08-2015 / 22:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
acceptVariableNode: aVariableNode
aVariableNode binding: (aVariableNode scope lookupVariable: aVariableNode name).
super acceptVariableNode: aVariableNode
"Created: / 25-08-2015 / 23:00:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !