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

TEnvironmentProvider subclass:#TFilesystemProvider
	instanceVariableNames:'classpath'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Tea-Compiler-Model-Provider'
!

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

!TFilesystemProvider class methodsFor:'instance creation'!

new
    "return an initialized instance"

    ^ self basicNew initialize.
! !

!TFilesystemProvider methodsFor:'accessing'!

classNamed:name 
    classpath do:[:each | 
        | classes |

        classes := self classNamed:name from:each.
        classes notEmptyOrNil ifTrue:[
            ^ classes.
        ]
    ].
    ^ nil

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

classNamed:name from:classpathentry 
    | dir file unit |

    dir := classpathentry asFilename.
    dir isDirectory ifFalse:[
        ^ nil
    ].
    file := dir / (name , '.tea').
    file isReadable ifFalse:[
        ^ nil
    ].
    unit := TSourceReader read:file.
    ^ unit classes detect:[:class | class name = name ] ifNone:[ nil ]

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

classpath
    ^ classpath

    "Created: / 24-09-2015 / 16:45:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TFilesystemProvider methodsFor:'initialization'!

initialize
    classpath := OrderedCollection with: (Smalltalk packageDirectoryForPackageId: 'jv:tea') / 'libt'

    "Modified: / 14-09-2015 / 15:06:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TFilesystemProvider class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !