TUnionType.st
changeset 0 db69a8d8b368
equal deleted inserted replaced
-1:000000000000 0:db69a8d8b368
       
     1 "{ Package: 'jv:tea' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 TType subclass:#TUnionType
       
     6 	instanceVariableNames:'types'
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'Languages-Tea-Type System'
       
    10 !
       
    11 
       
    12 !TUnionType class methodsFor:'instance creation'!
       
    13 
       
    14 with: type1 with: type2
       
    15     ^ self new initializeWith: type1 and: type2
       
    16 
       
    17     "Created: / 21-08-2015 / 18:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    18 ! !
       
    19 
       
    20 !TUnionType methodsFor:'accessing'!
       
    21 
       
    22 types
       
    23     ^ types
       
    24 ! !
       
    25 
       
    26 !TUnionType methodsFor:'initialization'!
       
    27 
       
    28 initializeWith: type1 with: type2
       
    29     type1 isUnionType 
       
    30         ifTrue: [ types := type1 types copy  ]
       
    31         ifFalse:[ types := Array with: type1 ].
       
    32     type2 isUnionType 
       
    33         ifTrue: [ types := types , type2 types ]
       
    34         ifFalse:[ types := types copyWith: type2 ].
       
    35 
       
    36     "Created: / 21-08-2015 / 18:39:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    37 ! !
       
    38 
       
    39 !TUnionType methodsFor:'testing'!
       
    40 
       
    41 isUnionType
       
    42     ^ true
       
    43 ! !
       
    44