compiler/TNamespaceDefinition.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Sep 2015 03:51:15 +0100
changeset 16 17a2d1d9f205
parent 7 7556e3d41d80
permissions -rw-r--r--
Added standalone Tea compiler - teak It allows for compilation of .tea files from the command line.

"
    Copyright (C) 2015-now Jan Vrany

    This code is not an open-source (yet). You may use this code
    for your own experiments and projects, given that:

    * all modification to the code will be sent to the
      original author for inclusion in future releases
    * this is not used in any commercial software

    This license is provisional and may (will) change in
    a future.
"
"{ Package: 'jv:tea/compiler' }"

"{ NameSpace: Smalltalk }"

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

!TNamespaceDefinition class methodsFor:'documentation'!

copyright
"
    Copyright (C) 2015-now Jan Vrany

    This code is not an open-source (yet). You may use this code
    for your own experiments and projects, given that:

    * all modification to the code will be sent to the
      original author for inclusion in future releases
    * this is not used in any commercial software

    This license is provisional and may (will) change in
    a future.
"
! !

!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>"
! !