Removed syntax for inline assembly, use <primitive: [:asm | ... ]> syntax.
This one is easier to implement and less introusive, syntax-wise. And follows
Smalltalk tradiiton.
"{ Package: 'jv:tea/compiler' }"
"{ NameSpace: Smalltalk }"
TCompilerPass subclass:#TSemanticAnalyser
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Languages-Tea-Compiler-Internals'
!
!TSemanticAnalyser class methodsFor:'documentation'!
documentation
"
This is the very first pass on the code. Its responsibility is:
* initialize bindings
* initialize scopes (i.e, assign scopes and populate them
with variable bindings)
[author:]
Jan Vrany <jan.vrany@fit.cvut.cz>
[instance variables:]
[class variables:]
[see also:]
"
! !
!TSemanticAnalyser methodsFor:'visiting'!
visitArgument: anRBVariableNode
| binding |
anRBVariableNode parent isSequence ifTrue:[
binding := TLocalBinding name:anRBVariableNode name.
] ifFalse:[
binding := TArgumentBinding name:anRBVariableNode name.
binding index: (anRBVariableNode parent arguments indexOf: anRBVariableNode)
+ (anRBVariableNode parent scope isMethodScope ifTrue:[1] ifFalse:[0])
].
anRBVariableNode parent scope addVariable: binding.
super visitArgument: anRBVariableNode.
"Created: / 25-08-2015 / 22:51:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 19-09-2015 / 06:17:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TSemanticAnalyser methodsFor:'visitor-double dispatching'!
acceptBlockNode: aBlockNode
| scope |
aBlockNode parent isSpecialFormNode ifTrue:[
scope := TScope node: aBlockNode parent: aBlockNode parent scope
] ifFalse:[
scope := TScope node: aBlockNode
].
aBlockNode scope: scope.
super acceptBlockNode: aBlockNode
"Created: / 25-08-2015 / 22:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 19-09-2015 / 06:16:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
acceptLiteralNode: aRBLiteralNode
| value |
super acceptLiteralNode: aRBLiteralNode.
value := aRBLiteralNode value.
value isInteger ifTrue:[
aRBLiteralNode binding: (TConstantBinding value: value).
^ self.
].
value isBoolean ifTrue:[
aRBLiteralNode binding: (TConstantBinding value: (value ifTrue:[1] ifFalse:[0]) type: (context environment binding lookupClassBoolean) type).
^ self.
].
self erorr: 'Unsupported constant'.
"Created: / 25-08-2015 / 23:17:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 20-09-2015 / 07:12:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
acceptMethodNode: aMethodNode
| scope bindingForSelf |
scope := TScope node: aMethodNode.
bindingForSelf := TArgumentBinding name:'self'.
bindingForSelf index: self.
scope addVariable: bindingForSelf.
aMethodNode scope: scope.
super acceptMethodNode: aMethodNode
"Created: / 25-08-2015 / 22:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 13-09-2015 / 09:30:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
acceptVariableNode: aVariableNode
| binding |
binding := aVariableNode scope lookupVariable: aVariableNode name.
binding isNil ifTrue:[
context reportSemanticError: ('Undeclared variable %1' bindWith: aVariableNode name).
^ self.
].
aVariableNode binding: binding.
super acceptVariableNode: aVariableNode
"Created: / 25-08-2015 / 23:00:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 20-09-2015 / 06:14:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TSemanticAnalyser class methodsFor:'documentation'!
version
^ 'Path: jv/tea/compiler/TSemanticAnalyzer.st, Version: 1.0, User: jv, Time: 2015-08-31T13:47:58.729+01'
!
version_HG
^ 'Path: jv/tea/compiler/TSemanticAnalyzer.st, Version: 1.0, User: jv, Time: 2015-08-31T13:47:58.729+01'
! !