compiler/TClassBinding.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 }"

TBinding subclass:#TClassBinding
	instanceVariableNames:'clazz'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Tea-Compiler-Bindings'
!

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

!TClassBinding class methodsFor:'instance creation'!

clazz: aTClassDefinition
    ^ self new initializeWithClazz: aTClassDefinition

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

name: aString
    ^ self new initializeWithName: aString

    "Created: / 31-08-2015 / 11:21:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TClassBinding methodsFor:'accessing'!

clazz
   ^ clazz

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

type
   ^ TSimpleType named: clazz name

    "Created: / 31-08-2015 / 11:45:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-09-2015 / 15:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TClassBinding methodsFor:'initialization'!

initializeWithClazz: aTClassDefinition
    clazz := aTClassDefinition

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

!TClassBinding methodsFor:'lookup'!

lookupMethodNamed: selector
    | method |

    method := clazz methodNamed: selector.
    method isNil ifTrue:[ 
        self error: ('Could not resolve method %1 >> #%2' bindWith: clazz name with: selector)  
    ].
    ^ method binding

    "Created: / 02-09-2015 / 16:06:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TClassBinding methodsFor:'testing'!

isClassBinding
    ^ true
!

isMetaclass
    ^ clazz isMetaclass

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