File tree Expand file tree Collapse file tree 3 files changed +91
-5
lines changed Expand file tree Collapse file tree 3 files changed +91
-5
lines changed Original file line number Diff line number Diff line change @@ -3394,6 +3394,14 @@ export class Compiler extends DiagnosticEmitter {
3394
3394
var type = element . type ;
3395
3395
this . currentType = type ;
3396
3396
switch ( type . kind ) {
3397
+ case TypeKind . BOOL : {
3398
+ return this . module . i32 (
3399
+ element . constantValueKind == ConstantValueKind . INTEGER
3400
+ // @ts -ignore
3401
+ ? < i32 > i64_ne ( element . constantIntegerValue , i64_zero )
3402
+ : 0
3403
+ ) ;
3404
+ }
3397
3405
case TypeKind . I8 :
3398
3406
case TypeKind . I16 : {
3399
3407
let shift = type . computeSmallIntegerShift ( Type . i32 ) ;
@@ -3404,8 +3412,7 @@ export class Compiler extends DiagnosticEmitter {
3404
3412
) ; // recognized by canOverflow
3405
3413
}
3406
3414
case TypeKind . U8 :
3407
- case TypeKind . U16 :
3408
- case TypeKind . BOOL : {
3415
+ case TypeKind . U16 : {
3409
3416
let mask = element . type . computeSmallIntegerMask ( Type . i32 ) ;
3410
3417
return this . module . i32 (
3411
3418
element . constantValueKind == ConstantValueKind . INTEGER
Original file line number Diff line number Diff line change 129
129
assert ( val - 1 == 0xffff ) ;
130
130
}
131
131
132
+ // special cases
133
+ {
134
+ const b1 = < bool > 2 ;
135
+ assert ( b1 == true ) ;
136
+
137
+ const b2 = < bool > - 1 ;
138
+ assert ( b2 == true ) ;
139
+
140
+ const b3 = < bool > 0 ;
141
+ assert ( b3 == false ) ;
142
+
143
+ let b4 = < bool > 2 ;
144
+ assert ( b4 == true ) ;
145
+
146
+ let b5 = < bool > - 1 ;
147
+ assert ( b5 == true ) ;
148
+
149
+ let b6 = < bool > 0 ;
150
+ assert ( b6 == false ) ;
151
+ }
152
+
132
153
{
133
154
// regression #2131
134
155
const a : u32 = 65 ;
Original file line number Diff line number Diff line change 677
677
call $~lib/builtins/abort
678
678
unreachable
679
679
end
680
+ i32.const 1
681
+ i32.const 1
682
+ i32.eq
683
+ drop
684
+ i32.const 1
685
+ i32.const 1
686
+ i32.eq
687
+ drop
688
+ i32.const 0
689
+ i32.const 0
690
+ i32.eq
691
+ drop
692
+ i32.const 2
693
+ local.set $0
694
+ local.get $0
695
+ i32.const 0
696
+ i32.ne
697
+ i32.const 1
698
+ i32.eq
699
+ i32.eqz
700
+ if
701
+ i32.const 0
702
+ i32.const 32
703
+ i32.const 144
704
+ i32.const 3
705
+ call $~lib/builtins/abort
706
+ unreachable
707
+ end
708
+ i32.const -1
709
+ local.set $1
710
+ local.get $1
711
+ i32.const 0
712
+ i32.ne
713
+ i32.const 1
714
+ i32.eq
715
+ i32.eqz
716
+ if
717
+ i32.const 0
718
+ i32.const 32
719
+ i32.const 147
720
+ i32.const 3
721
+ call $~lib/builtins/abort
722
+ unreachable
723
+ end
724
+ i32.const 0
725
+ local.set $2
726
+ local.get $2
727
+ i32.const 0
728
+ i32.eq
729
+ i32.eqz
730
+ if
731
+ i32.const 0
732
+ i32.const 32
733
+ i32.const 150
734
+ i32.const 3
735
+ call $~lib/builtins/abort
736
+ unreachable
737
+ end
680
738
i32.const 65
681
739
i32.const 63457
682
740
i32.const 504
690
748
i32.const 65535
691
749
i32.and
692
750
i32.add
693
- local.set $0
694
- local.get $0
751
+ local.set $2
752
+ local.get $2
695
753
i32.const 65597
696
754
i32.eq
697
755
i32.eqz
698
756
if
699
757
i32.const 0
700
758
i32.const 32
701
- i32.const 138
759
+ i32.const 159
702
760
i32.const 3
703
761
call $~lib/builtins/abort
704
762
unreachable
You can’t perform that action at this time.
0 commit comments