compiler/TEnvironment.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Sep 2015 03:51:15 +0100
changeset 16 17a2d1d9f205
parent 10 2b9beeac547e
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 }"

TNamespaceDefinition subclass:#TEnvironment
	instanceVariableNames:'provider'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Tea-Compiler-Model'
!

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

!TEnvironment methodsFor:'accessing'!

provider
    ^ provider
!

provider:providerObject
    "Set provider, an object used to ask for class definitions if
     class is not yet loaded into the receiver"
    provider := providerObject.

    "Modified (comment): / 12-09-2015 / 09:52:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TEnvironment methodsFor:'initialization'!

initialize
    super initialize.
    provider := TFilesystemProvider new

    "Created: / 14-09-2015 / 15:13:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TEnvironment methodsFor:'lookup by name'!

classOrTraitNamed: className
    | classOrTrait |

    classOrTrait := super classOrTraitNamed: className.
    classOrTrait isNil ifTrue:[ 
        | class |

        class := provider classNamed:className.
        class notNil ifTrue:[ 
            self addElement: class.
        ]
    ].
    classOrTrait := super classOrTraitNamed: className.
    ^ classOrTrait.

    "Created: / 12-09-2015 / 09:48:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-09-2015 / 15:28:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !