compiler/TSimpleType.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 31 Aug 2015 18:37:31 +0100
changeset 5 976f21e29d37
parent 4 3d80069ea3e2
child 6 0c806a7f1888
permissions -rw-r--r--
Added TSourceReader to allow reading source files. Initial work on T environment...

"{ Package: 'jv:tea/compiler' }"

"{ NameSpace: Smalltalk }"

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

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

    "/ Q&D hack for builtin types, sigh...
    name = 'i1' ifTrue:[ 
        ^ LLVMType int1
    ].
    name = 'i8' ifTrue:[ 
        ^ LLVMType int1
    ].
    name = 'i32' ifTrue:[ 
        ^ LLVMType int32
    ].
    name = 'i64' ifTrue:[ 
        ^ LLVMType int64
    ].
    name = 'iptr' ifTrue:[ 
        ^ LLVMType intptr
    ].
    name = 'SmallInteger' ifTrue:[ 
        ^ LLVMType intptr
    ].                  
    self notYetImplemented

    "Created: / 31-08-2015 / 09:06:45 / 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'!

printOn:aStream
    aStream nextPut: $<; space.
    self printWithoutAnglesOn:aStream.
    aStream space; nextPut: $>.

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

printWithoutAnglesOn:aStream
    aStream nextPutAll: name

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

!TSimpleType methodsFor:'testing'!

isSimpleType
    ^ true
! !