author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 23 Sep 2015 22:21:44 +0100 | |
changeset 15 | 10a95d798b36 |
parent 13 | 97090c2baa33 |
child 16 | 17a2d1d9f205 |
permissions | -rw-r--r-- |
"{ Package: 'jv:tea/compiler' }" "{ NameSpace: Smalltalk }" TObjectWithProperties subclass:#TScope instanceVariableNames:'node parent children variables' classVariableNames:'' poolDictionaries:'' category:'Languages-Tea-Compiler-Bindings' ! !TScope class methodsFor:'instance creation'! node: node ^ self node: node parent: nil. "Created: / 25-08-2015 / 22:28:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! node: node parent: parent ^ self new initializeWithNode: node parent: parent "Created: / 25-08-2015 / 22:24:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! ! !TScope methodsFor:'accessing'! children ^ children ? #() "Modified: / 25-08-2015 / 22:28:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! node ^ node ! parent ^ parent ! variables ^ variables ? #() "Modified: / 19-09-2015 / 05:56:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! ! !TScope methodsFor:'accesssing - llvm'! llvmAllocas ^ self propertyAt: #llvmAllocas ifAbsent: [ parent notNil ifTrue:[ parent llvmAllocas ] ifFalse:[nil] ] "Created: / 23-09-2015 / 21:42:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! llvmAllocas: anLLVMBasicBlock self propertyAt: #llvmAllocas put: anLLVMBasicBlock "Created: / 23-09-2015 / 21:40:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! ! !TScope methodsFor:'adding & removing'! addSubScope: aTScope children isNil ifTrue:[ children := OrderedCollection new: 5. ]. children add: aTScope "Created: / 19-09-2015 / 06:05:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! addVariable: aTVariableBinding variables isNil ifTrue:[ variables := OrderedCollection new. ]. variables add: aTVariableBinding "Created: / 25-08-2015 / 22:42:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! ! !TScope methodsFor:'initialization'! initializeWithNode: n parent: p node := n. parent := p. parent notNil ifTrue:[ parent addSubScope: self. ]. "Created: / 25-08-2015 / 22:25:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" "Modified: / 19-09-2015 / 06:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! ! !TScope methodsFor:'lookup'! lookupVariable: name "Return binding for variable with given name or nil if not found" | variable | variables notNil ifTrue:[ variable := variables detect:[:binding | binding name = name ] ifNone:[ nil ]. ]. (variable isNil and:[parent notNil]) ifTrue:[ variable := parent lookupVariable: name. ]. ^ variable "Created: / 25-08-2015 / 22:58:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" "Modified: / 20-09-2015 / 06:11:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! ! !TScope methodsFor:'testing'! hasSelfArgument ^ (node isMethod and:[node binding mclass isMetaclass not]) "Created: / 23-09-2015 / 18:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! isBlockScope ^ node isBlock "Created: / 02-09-2015 / 08:57:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! isMethodScope ^ node isMethod "Created: / 02-09-2015 / 08:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" ! !