@@ -28,6 +28,10 @@ fun evalUnaryOp(name: String, type: CompileTimeType, value: Any): Any? {
28
28
" toString" -> return (value as Byte ).toString()
29
29
" unaryMinus" -> return (value as Byte ).unaryMinus()
30
30
" unaryPlus" -> return (value as Byte ).unaryPlus()
31
+ " toULong" -> return (value as Byte ).toULong()
32
+ " toUInt" -> return (value as Byte ).toUInt()
33
+ " toUShort" -> return (value as Byte ).toUShort()
34
+ " toUByte" -> return (value as Byte ).toUByte()
31
35
}
32
36
CHAR -> when (name) {
33
37
" toByte" -> return (value as Char ).toByte()
@@ -51,6 +55,8 @@ fun evalUnaryOp(name: String, type: CompileTimeType, value: Any): Any? {
51
55
" toString" -> return (value as Double ).toString()
52
56
" unaryMinus" -> return (value as Double ).unaryMinus()
53
57
" unaryPlus" -> return (value as Double ).unaryPlus()
58
+ " toULong" -> return (value as Double ).toULong()
59
+ " toUInt" -> return (value as Double ).toUInt()
54
60
}
55
61
FLOAT -> when (name) {
56
62
" toByte" -> return (value as Float ).toByte()
@@ -63,6 +69,8 @@ fun evalUnaryOp(name: String, type: CompileTimeType, value: Any): Any? {
63
69
" toString" -> return (value as Float ).toString()
64
70
" unaryMinus" -> return (value as Float ).unaryMinus()
65
71
" unaryPlus" -> return (value as Float ).unaryPlus()
72
+ " toULong" -> return (value as Float ).toULong()
73
+ " toUInt" -> return (value as Float ).toUInt()
66
74
}
67
75
INT -> when (name) {
68
76
" inv" -> return (value as Int ).inv ()
@@ -76,6 +84,10 @@ fun evalUnaryOp(name: String, type: CompileTimeType, value: Any): Any? {
76
84
" toString" -> return (value as Int ).toString()
77
85
" unaryMinus" -> return (value as Int ).unaryMinus()
78
86
" unaryPlus" -> return (value as Int ).unaryPlus()
87
+ " toULong" -> return (value as Int ).toULong()
88
+ " toUInt" -> return (value as Int ).toUInt()
89
+ " toUShort" -> return (value as Int ).toUShort()
90
+ " toUByte" -> return (value as Int ).toUByte()
79
91
}
80
92
LONG -> when (name) {
81
93
" inv" -> return (value as Long ).inv ()
@@ -89,6 +101,10 @@ fun evalUnaryOp(name: String, type: CompileTimeType, value: Any): Any? {
89
101
" toString" -> return (value as Long ).toString()
90
102
" unaryMinus" -> return (value as Long ).unaryMinus()
91
103
" unaryPlus" -> return (value as Long ).unaryPlus()
104
+ " toULong" -> return (value as Long ).toULong()
105
+ " toUInt" -> return (value as Long ).toUInt()
106
+ " toUShort" -> return (value as Long ).toUShort()
107
+ " toUByte" -> return (value as Long ).toUByte()
92
108
}
93
109
SHORT -> when (name) {
94
110
" toByte" -> return (value as Short ).toByte()
@@ -101,11 +117,71 @@ fun evalUnaryOp(name: String, type: CompileTimeType, value: Any): Any? {
101
117
" toString" -> return (value as Short ).toString()
102
118
" unaryMinus" -> return (value as Short ).unaryMinus()
103
119
" unaryPlus" -> return (value as Short ).unaryPlus()
120
+ " toULong" -> return (value as Short ).toULong()
121
+ " toUInt" -> return (value as Short ).toUInt()
122
+ " toUShort" -> return (value as Short ).toUShort()
123
+ " toUByte" -> return (value as Short ).toUByte()
104
124
}
105
125
STRING -> when (name) {
106
126
" length" -> return (value as String ).length
107
127
" toString" -> return (value as String ).toString()
108
128
}
129
+ UINT -> when (name) {
130
+ " inv" -> return (value as UInt ).inv ()
131
+ " toByte" -> return (value as UInt ).toByte()
132
+ " toDouble" -> return (value as UInt ).toDouble()
133
+ " toFloat" -> return (value as UInt ).toFloat()
134
+ " toInt" -> return (value as UInt ).toInt()
135
+ " toLong" -> return (value as UInt ).toLong()
136
+ " toShort" -> return (value as UInt ).toShort()
137
+ " toString" -> return (value as UInt ).toString()
138
+ " toUByte" -> return (value as UInt ).toUByte()
139
+ " toUInt" -> return (value as UInt ).toUInt()
140
+ " toULong" -> return (value as UInt ).toULong()
141
+ " toUShort" -> return (value as UInt ).toUShort()
142
+ }
143
+ ULONG -> when (name) {
144
+ " inv" -> return (value as ULong ).inv ()
145
+ " toByte" -> return (value as ULong ).toByte()
146
+ " toDouble" -> return (value as ULong ).toDouble()
147
+ " toFloat" -> return (value as ULong ).toFloat()
148
+ " toInt" -> return (value as ULong ).toInt()
149
+ " toLong" -> return (value as ULong ).toLong()
150
+ " toShort" -> return (value as ULong ).toShort()
151
+ " toString" -> return (value as ULong ).toString()
152
+ " toUByte" -> return (value as ULong ).toUByte()
153
+ " toUInt" -> return (value as ULong ).toUInt()
154
+ " toULong" -> return (value as ULong ).toULong()
155
+ " toUShort" -> return (value as ULong ).toUShort()
156
+ }
157
+ UBYTE -> when (name) {
158
+ " inv" -> return (value as UByte ).inv ()
159
+ " toByte" -> return (value as UByte ).toByte()
160
+ " toDouble" -> return (value as UByte ).toDouble()
161
+ " toFloat" -> return (value as UByte ).toFloat()
162
+ " toInt" -> return (value as UByte ).toInt()
163
+ " toLong" -> return (value as UByte ).toLong()
164
+ " toShort" -> return (value as UByte ).toShort()
165
+ " toString" -> return (value as UByte ).toString()
166
+ " toUByte" -> return (value as UByte ).toUByte()
167
+ " toUInt" -> return (value as UByte ).toUInt()
168
+ " toULong" -> return (value as UByte ).toULong()
169
+ " toUShort" -> return (value as UByte ).toUShort()
170
+ }
171
+ USHORT -> when (name) {
172
+ " inv" -> return (value as UShort ).inv ()
173
+ " toByte" -> return (value as UShort ).toByte()
174
+ " toDouble" -> return (value as UShort ).toDouble()
175
+ " toFloat" -> return (value as UShort ).toFloat()
176
+ " toInt" -> return (value as UShort ).toInt()
177
+ " toLong" -> return (value as UShort ).toLong()
178
+ " toShort" -> return (value as UShort ).toShort()
179
+ " toString" -> return (value as UShort ).toString()
180
+ " toUByte" -> return (value as UShort ).toUByte()
181
+ " toUInt" -> return (value as UShort ).toUInt()
182
+ " toULong" -> return (value as UShort ).toULong()
183
+ " toUShort" -> return (value as UShort ).toUShort()
184
+ }
109
185
else -> {}
110
186
}
111
187
return null
@@ -524,6 +600,210 @@ fun evalBinaryOp(name: String, leftType: CompileTimeType, left: Any, rightType:
524
600
}
525
601
else -> {}
526
602
}
603
+ UINT -> when (rightType) {
604
+ UINT -> when (name) {
605
+ " and" -> return (left as UInt ).and (right as UInt )
606
+ " compareTo" -> return (left as UInt ).compareTo(right as UInt )
607
+ " div" -> return (left as UInt ).div(right as UInt )
608
+ " floorDiv" -> return (left as UInt ).floorDiv(right as UInt )
609
+ " minus" -> return (left as UInt ).minus(right as UInt )
610
+ " mod" -> return (left as UInt ).mod(right as UInt )
611
+ " or" -> return (left as UInt ).or (right as UInt )
612
+ " plus" -> return (left as UInt ).plus(right as UInt )
613
+ " rem" -> return (left as UInt ).rem(right as UInt )
614
+ " times" -> return (left as UInt ).times(right as UInt )
615
+ " xor" -> return (left as UInt ).xor(right as UInt )
616
+ }
617
+ UBYTE -> when (name) {
618
+ " compareTo" -> return (left as UInt ).compareTo(right as UByte )
619
+ " div" -> return (left as UInt ).div(right as UByte )
620
+ " floorDiv" -> return (left as UInt ).floorDiv(right as UByte )
621
+ " minus" -> return (left as UInt ).minus(right as UByte )
622
+ " mod" -> return (left as UInt ).mod(right as UByte )
623
+ " plus" -> return (left as UInt ).plus(right as UByte )
624
+ " rem" -> return (left as UInt ).rem(right as UByte )
625
+ " times" -> return (left as UInt ).times(right as UByte )
626
+ }
627
+ USHORT -> when (name) {
628
+ " compareTo" -> return (left as UInt ).compareTo(right as UShort )
629
+ " div" -> return (left as UInt ).div(right as UShort )
630
+ " floorDiv" -> return (left as UInt ).floorDiv(right as UShort )
631
+ " minus" -> return (left as UInt ).minus(right as UShort )
632
+ " mod" -> return (left as UInt ).mod(right as UShort )
633
+ " plus" -> return (left as UInt ).plus(right as UShort )
634
+ " rem" -> return (left as UInt ).rem(right as UShort )
635
+ " times" -> return (left as UInt ).times(right as UShort )
636
+ }
637
+ ULONG -> when (name) {
638
+ " compareTo" -> return (left as UInt ).compareTo(right as ULong )
639
+ " div" -> return (left as UInt ).div(right as ULong )
640
+ " floorDiv" -> return (left as UInt ).floorDiv(right as ULong )
641
+ " minus" -> return (left as UInt ).minus(right as ULong )
642
+ " mod" -> return (left as UInt ).mod(right as ULong )
643
+ " plus" -> return (left as UInt ).plus(right as ULong )
644
+ " rem" -> return (left as UInt ).rem(right as ULong )
645
+ " times" -> return (left as UInt ).times(right as ULong )
646
+ }
647
+ ANY -> when (name) {
648
+ " equals" -> return (left as UInt ).equals(right)
649
+ }
650
+ INT -> when (name) {
651
+ " shl" -> return (left as UInt ).shl(right as Int )
652
+ " shr" -> return (left as UInt ).shr(right as Int )
653
+ }
654
+ else -> {}
655
+ }
656
+ ULONG -> when (rightType) {
657
+ ULONG -> when (name) {
658
+ " and" -> return (left as ULong ).and (right as ULong )
659
+ " compareTo" -> return (left as ULong ).compareTo(right as ULong )
660
+ " div" -> return (left as ULong ).div(right as ULong )
661
+ " floorDiv" -> return (left as ULong ).floorDiv(right as ULong )
662
+ " minus" -> return (left as ULong ).minus(right as ULong )
663
+ " mod" -> return (left as ULong ).mod(right as ULong )
664
+ " or" -> return (left as ULong ).or (right as ULong )
665
+ " plus" -> return (left as ULong ).plus(right as ULong )
666
+ " rem" -> return (left as ULong ).rem(right as ULong )
667
+ " times" -> return (left as ULong ).times(right as ULong )
668
+ " xor" -> return (left as ULong ).xor(right as ULong )
669
+ }
670
+ UBYTE -> when (name) {
671
+ " compareTo" -> return (left as ULong ).compareTo(right as UByte )
672
+ " div" -> return (left as ULong ).div(right as UByte )
673
+ " floorDiv" -> return (left as ULong ).floorDiv(right as UByte )
674
+ " minus" -> return (left as ULong ).minus(right as UByte )
675
+ " mod" -> return (left as ULong ).mod(right as UByte )
676
+ " plus" -> return (left as ULong ).plus(right as UByte )
677
+ " rem" -> return (left as ULong ).rem(right as UByte )
678
+ " times" -> return (left as ULong ).times(right as UByte )
679
+ }
680
+ USHORT -> when (name) {
681
+ " compareTo" -> return (left as ULong ).compareTo(right as UShort )
682
+ " div" -> return (left as ULong ).div(right as UShort )
683
+ " floorDiv" -> return (left as ULong ).floorDiv(right as UShort )
684
+ " minus" -> return (left as ULong ).minus(right as UShort )
685
+ " mod" -> return (left as ULong ).mod(right as UShort )
686
+ " plus" -> return (left as ULong ).plus(right as UShort )
687
+ " rem" -> return (left as ULong ).rem(right as UShort )
688
+ " times" -> return (left as ULong ).times(right as UShort )
689
+ }
690
+ UINT -> when (name) {
691
+ " compareTo" -> return (left as ULong ).compareTo(right as UInt )
692
+ " div" -> return (left as ULong ).div(right as UInt )
693
+ " floorDiv" -> return (left as ULong ).floorDiv(right as UInt )
694
+ " minus" -> return (left as ULong ).minus(right as UInt )
695
+ " mod" -> return (left as ULong ).mod(right as UInt )
696
+ " plus" -> return (left as ULong ).plus(right as UInt )
697
+ " rem" -> return (left as ULong ).rem(right as UInt )
698
+ " times" -> return (left as ULong ).times(right as UInt )
699
+ }
700
+ ANY -> when (name) {
701
+ " equals" -> return (left as ULong ).equals(right)
702
+ }
703
+ INT -> when (name) {
704
+ " shl" -> return (left as ULong ).shl(right as Int )
705
+ " shr" -> return (left as ULong ).shr(right as Int )
706
+ }
707
+ else -> {}
708
+ }
709
+ UBYTE -> when (rightType) {
710
+ UBYTE -> when (name) {
711
+ " and" -> return (left as UByte ).and (right as UByte )
712
+ " compareTo" -> return (left as UByte ).compareTo(right as UByte )
713
+ " div" -> return (left as UByte ).div(right as UByte )
714
+ " floorDiv" -> return (left as UByte ).floorDiv(right as UByte )
715
+ " minus" -> return (left as UByte ).minus(right as UByte )
716
+ " mod" -> return (left as UByte ).mod(right as UByte )
717
+ " or" -> return (left as UByte ).or (right as UByte )
718
+ " plus" -> return (left as UByte ).plus(right as UByte )
719
+ " rem" -> return (left as UByte ).rem(right as UByte )
720
+ " times" -> return (left as UByte ).times(right as UByte )
721
+ " xor" -> return (left as UByte ).xor(right as UByte )
722
+ }
723
+ USHORT -> when (name) {
724
+ " compareTo" -> return (left as UByte ).compareTo(right as UShort )
725
+ " div" -> return (left as UByte ).div(right as UShort )
726
+ " floorDiv" -> return (left as UByte ).floorDiv(right as UShort )
727
+ " minus" -> return (left as UByte ).minus(right as UShort )
728
+ " mod" -> return (left as UByte ).mod(right as UShort )
729
+ " plus" -> return (left as UByte ).plus(right as UShort )
730
+ " rem" -> return (left as UByte ).rem(right as UShort )
731
+ " times" -> return (left as UByte ).times(right as UShort )
732
+ }
733
+ UINT -> when (name) {
734
+ " compareTo" -> return (left as UByte ).compareTo(right as UInt )
735
+ " div" -> return (left as UByte ).div(right as UInt )
736
+ " floorDiv" -> return (left as UByte ).floorDiv(right as UInt )
737
+ " minus" -> return (left as UByte ).minus(right as UInt )
738
+ " mod" -> return (left as UByte ).mod(right as UInt )
739
+ " plus" -> return (left as UByte ).plus(right as UInt )
740
+ " rem" -> return (left as UByte ).rem(right as UInt )
741
+ " times" -> return (left as UByte ).times(right as UInt )
742
+ }
743
+ ULONG -> when (name) {
744
+ " compareTo" -> return (left as UByte ).compareTo(right as ULong )
745
+ " div" -> return (left as UByte ).div(right as ULong )
746
+ " floorDiv" -> return (left as UByte ).floorDiv(right as ULong )
747
+ " minus" -> return (left as UByte ).minus(right as ULong )
748
+ " mod" -> return (left as UByte ).mod(right as ULong )
749
+ " plus" -> return (left as UByte ).plus(right as ULong )
750
+ " rem" -> return (left as UByte ).rem(right as ULong )
751
+ " times" -> return (left as UByte ).times(right as ULong )
752
+ }
753
+ ANY -> when (name) {
754
+ " equals" -> return (left as UByte ).equals(right)
755
+ }
756
+ else -> {}
757
+ }
758
+ USHORT -> when (rightType) {
759
+ USHORT -> when (name) {
760
+ " and" -> return (left as UShort ).and (right as UShort )
761
+ " compareTo" -> return (left as UShort ).compareTo(right as UShort )
762
+ " div" -> return (left as UShort ).div(right as UShort )
763
+ " floorDiv" -> return (left as UShort ).floorDiv(right as UShort )
764
+ " minus" -> return (left as UShort ).minus(right as UShort )
765
+ " mod" -> return (left as UShort ).mod(right as UShort )
766
+ " or" -> return (left as UShort ).or (right as UShort )
767
+ " plus" -> return (left as UShort ).plus(right as UShort )
768
+ " rem" -> return (left as UShort ).rem(right as UShort )
769
+ " times" -> return (left as UShort ).times(right as UShort )
770
+ " xor" -> return (left as UShort ).xor(right as UShort )
771
+ }
772
+ UBYTE -> when (name) {
773
+ " compareTo" -> return (left as UShort ).compareTo(right as UByte )
774
+ " div" -> return (left as UShort ).div(right as UByte )
775
+ " floorDiv" -> return (left as UShort ).floorDiv(right as UByte )
776
+ " minus" -> return (left as UShort ).minus(right as UByte )
777
+ " mod" -> return (left as UShort ).mod(right as UByte )
778
+ " plus" -> return (left as UShort ).plus(right as UByte )
779
+ " rem" -> return (left as UShort ).rem(right as UByte )
780
+ " times" -> return (left as UShort ).times(right as UByte )
781
+ }
782
+ UINT -> when (name) {
783
+ " compareTo" -> return (left as UShort ).compareTo(right as UInt )
784
+ " div" -> return (left as UShort ).div(right as UInt )
785
+ " floorDiv" -> return (left as UShort ).floorDiv(right as UInt )
786
+ " minus" -> return (left as UShort ).minus(right as UInt )
787
+ " mod" -> return (left as UShort ).mod(right as UInt )
788
+ " plus" -> return (left as UShort ).plus(right as UInt )
789
+ " rem" -> return (left as UShort ).rem(right as UInt )
790
+ " times" -> return (left as UShort ).times(right as UInt )
791
+ }
792
+ ULONG -> when (name) {
793
+ " compareTo" -> return (left as UShort ).compareTo(right as ULong )
794
+ " div" -> return (left as UShort ).div(right as ULong )
795
+ " floorDiv" -> return (left as UShort ).floorDiv(right as ULong )
796
+ " minus" -> return (left as UShort ).minus(right as ULong )
797
+ " mod" -> return (left as UShort ).mod(right as ULong )
798
+ " plus" -> return (left as UShort ).plus(right as ULong )
799
+ " rem" -> return (left as UShort ).rem(right as ULong )
800
+ " times" -> return (left as UShort ).times(right as ULong )
801
+ }
802
+ ANY -> when (name) {
803
+ " equals" -> return (left as UShort ).equals(right)
804
+ }
805
+ else -> {}
806
+ }
527
807
else -> {}
528
808
}
529
809
return null
0 commit comments