equal
deleted
inserted
replaced
13 |
13 |
14 with: type1 with: type2 |
14 with: type1 with: type2 |
15 ^ self new initializeWith: type1 and: type2 |
15 ^ self new initializeWith: type1 and: type2 |
16 |
16 |
17 "Created: / 21-08-2015 / 18:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17 "Created: / 21-08-2015 / 18:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
18 ! |
|
19 |
|
20 withAll: types |
|
21 ^ self new initializeWithAll: types |
|
22 |
|
23 "Created: / 25-08-2015 / 22:51:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18 ! ! |
24 ! ! |
19 |
25 |
20 !TUnionType methodsFor:'accessing'! |
26 !TUnionType methodsFor:'accessing'! |
21 |
27 |
22 types |
28 types |
23 ^ types |
29 ^ types |
|
30 ! ! |
|
31 |
|
32 !TUnionType methodsFor:'comparing'! |
|
33 |
|
34 hash |
|
35 | h | |
|
36 |
|
37 h := types size. |
|
38 types do:[:type | h := h bitXor: type hash ]. |
|
39 ^ h |
|
40 |
|
41 "Created: / 25-08-2015 / 23:35:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
24 ! ! |
42 ! ! |
25 |
43 |
26 !TUnionType methodsFor:'initialization'! |
44 !TUnionType methodsFor:'initialization'! |
27 |
45 |
28 initializeWith: type1 with: type2 |
46 initializeWith: type1 with: type2 |
32 type2 isUnionType |
50 type2 isUnionType |
33 ifTrue: [ types := types , type2 types ] |
51 ifTrue: [ types := types , type2 types ] |
34 ifFalse:[ types := types copyWith: type2 ]. |
52 ifFalse:[ types := types copyWith: type2 ]. |
35 |
53 |
36 "Created: / 21-08-2015 / 18:39:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
54 "Created: / 21-08-2015 / 18:39:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
55 ! |
|
56 |
|
57 initializeWithAll: aCollection |
|
58 types := OrderedCollection new: aCollection size. |
|
59 aCollection do:[:type | |
|
60 type isUnionType |
|
61 ifTrue:[ types addAll: type types ] |
|
62 ifFalse:[types add: type ]. |
|
63 ]. |
|
64 types := types asArray. |
|
65 |
|
66 "Created: / 25-08-2015 / 22:50:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
37 ! ! |
67 ! ! |
38 |
68 |
39 !TUnionType methodsFor:'testing'! |
69 !TUnionType methodsFor:'testing'! |
40 |
70 |
41 isUnionType |
71 isUnionType |