Make 3 + 4 working, though the code is rather messy
...and needs a lot of cleanup. There are no checks for error cases,
no debug info, etc...
"{ Package: 'jv:tea/compiler' }"
"{ NameSpace: Smalltalk }"
TCompilerPass subclass:#TTypechecker
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Languages-Tea-Compiler'
!
!TTypechecker methodsFor:'visitor-double dispatching'!
acceptMessageNode: aMessageNode
| receiverType receiverBinding methodBinding |
super acceptMessageNode: aMessageNode.
receiverType := aMessageNode receiver binding type.
receiverType isSimpleType ifTrue:[
receiverBinding := context environment binding lookupClassNamed: receiverType name.
methodBinding := receiverBinding lookupMethodNamed: aMessageNode selector.
1 to: aMessageNode arguments size do:[:paramIdx |
| actualParamType formalParamType |
actualParamType := (aMessageNode arguments at: paramIdx) binding type.
formalParamType := methodBinding parameterTypes at: paramIdx.
(actualParamType isSubtypeOf: formalParamType) ifFalse:[
self error: 'Type mismatch'.
^ self.
].
].
aMessageNode binding: methodBinding.
^ self.
].
self notYetImplemented
"Created: / 02-09-2015 / 10:34:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 02-09-2015 / 17:11:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !