compiler/TSimpleType.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 23 Sep 2015 22:21:44 +0100
changeset 15 10a95d798b36
parent 9 569bf5707c7e
child 16 17a2d1d9f205
permissions -rw-r--r--
Added support for local variables and #whileTrue: special form Allocate all local variables in a special basic block named `allocas`. Added support for #whileTrue: special form.

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

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