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

TType subclass:#TSimpleType
	instanceVariableNames:'name'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Tea-Compiler-Types'
!

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

!TSimpleType class methodsFor:'instance creation'!

named: aString
    ^ self new initializeWithName: aString

    "Created: / 21-08-2015 / 19:24:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TSimpleType methodsFor:'accessing'!

name
    ^ name
! !

!TSimpleType methodsFor:'comparing'!

= anotherType
    ^ self class = anotherType class and:[ self name = anotherType name ]

    "Created: / 25-08-2015 / 23:36:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

hash
    ^ name hash

    "Created: / 25-08-2015 / 23:34:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TSimpleType methodsFor:'conversion'!

asLLVMTypeInModule: aLLVMModule
    "Return the type as LLVMType"

    name = 'tUIntegerW' ifTrue:[ 
        ^ LLVMType intptr
    ].
    name = 'tSIntegerW' ifTrue:[ 
        ^ LLVMType intptr
    ].
    name = 'tPointer' ifTrue:[ 
        ^ LLVMType void pointer    
    ].
    name = 'tBoolean' ifTrue:[ 
        ^ LLVMType int1    
    ].
    ^ self notYetImplemented

    "Created: / 31-08-2015 / 09:06:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-09-2015 / 11:43:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TSimpleType methodsFor:'initialization'!

initializeWithName: aString
    name := aString

    "Created: / 21-08-2015 / 19:23:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TSimpleType methodsFor:'printing & storing'!

printWithoutAnglesOn:aStream
    aStream nextPutAll: name

    "Modified: / 21-08-2015 / 17:08:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TSimpleType methodsFor:'testing'!

isSimpleType
    ^ true
!

isSubtypeOf: anotherType
    "/ Hack for now - types must match exactly...
    ^ anotherType class == self class and:[ anotherType name = name ]

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