compiler/TNamespaceDefinition.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 20 Sep 2015 12:01:42 +0100
changeset 13 97090c2baa33
parent 7 7556e3d41d80
child 16 17a2d1d9f205
permissions -rw-r--r--
Fixes/refactoring of scopes and bindings. Fixed initialization of scopes and bindings. Make typechecker to seed types.

"{ Package: 'jv:tea/compiler' }"

"{ NameSpace: Smalltalk }"

RGNamespace subclass:#TNamespaceDefinition
	instanceVariableNames:'binding'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Tea-Compiler-Model'
!

!TNamespaceDefinition methodsFor:'accessing'!

binding
    binding isNil ifTrue:[ 
        binding := TNamespaceBinding namespace: self.
    ].
    ^ binding

    "Modified: / 02-09-2015 / 16:03:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

binding:aTNamespaceBinding
    binding := aTNamespaceBinding.
! !

!TNamespaceDefinition methodsFor:'adding elements'!

addMethod: method
    | mclassName mclassIsMeta mclass |

    mclassName := method className.
    (mclassName endsWith: ' class') ifTrue:[ 
        mclassName := (mclassName copyTo: mclassName size - 6) asSymbol.
        mclassIsMeta := true.
    ] ifFalse:[ 
        mclassIsMeta := false.
    ].
    mclass := self classNamed: mclassName.
    mclassIsMeta ifTrue:[ 
        mclass := mclass theMetaclass.
    ].
    mclass addMethod: method.

    "Created: / 31-08-2015 / 17:10:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 03-09-2015 / 15:48:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !