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

RGMethodDefinition subclass:#TMethodDefinition
	instanceVariableNames:'binding parseTree'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Tea-Compiler-Model'
!

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

!TMethodDefinition methodsFor:'accessing'!

binding
    binding isNil ifTrue:[ 
        | header |
        header := TParser parseMethodHeader: self source.

        binding := TMethodBinding class: self parent binding selector: header selector.
        binding parameterTypes: (header arguments collect:[ :arg | arg typeSpec asType ]).
        binding returnType: header returnTypeSpec asType.
    ].
    ^ binding

    "Created: / 31-08-2015 / 10:53:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-09-2015 / 10:57:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

parseTree
    parseTree isNil ifTrue:[ 
        parseTree := TParser parseMethod: self source.
        parseTree binding: self binding.
    ].
    ^ parseTree

    "Created: / 25-08-2015 / 19:43:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-09-2015 / 10:10:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selector
    "Retrieves the name of the method"

    name isNil ifTrue:[ 
        | src |    

        src := self sourceCode.
        src notNil ifTrue:[ 
            name := TParser parseMethodPattern: src.  
        ].
    ].
    ^ name

    "Created: / 29-08-2015 / 11:36:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-09-2015 / 06:23:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TMethodDefinition class methodsFor:'documentation'!

version_HG

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