@@ -1623,7 +1623,7 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
1623
1623
} else {
1624
1624
arg1 = compiler . compileExpression ( operands [ 1 ] , type , Constraints . ConvImplicit | Constraints . MustWrap ) ;
1625
1625
}
1626
- let op : BinaryOp = - 1 ;
1626
+ let op : BinaryOp | null = null ;
1627
1627
switch ( type . kind ) {
1628
1628
case TypeKind . I8 :
1629
1629
case TypeKind . I16 :
@@ -1639,14 +1639,14 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
1639
1639
case TypeKind . F32 : return module . binary ( BinaryOp . MaxF32 , arg0 , arg1 ) ;
1640
1640
case TypeKind . F64 : return module . binary ( BinaryOp . MaxF64 , arg0 , arg1 ) ;
1641
1641
}
1642
- if ( op as i32 != - 1 ) {
1642
+ if ( op ) {
1643
1643
let flow = compiler . currentFlow ;
1644
1644
let typeRef = type . toRef ( ) ;
1645
1645
let temp1 = flow . getTempLocal ( type ) ;
1646
1646
flow . setLocalFlag ( temp1 . index , LocalFlags . Wrapped ) ;
1647
1647
let temp2 = flow . getTempLocal ( type ) ;
1648
1648
flow . setLocalFlag ( temp2 . index , LocalFlags . Wrapped ) ;
1649
- let ret = module . select (
1649
+ return module . select (
1650
1650
module . local_tee ( temp1 . index , arg0 , false ) , // numeric
1651
1651
module . local_tee ( temp2 . index , arg1 , false ) , // numeric
1652
1652
module . binary ( op ,
@@ -1655,7 +1655,6 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
1655
1655
) ,
1656
1656
typeRef
1657
1657
) ;
1658
- return ret ;
1659
1658
}
1660
1659
}
1661
1660
compiler . error (
@@ -1691,7 +1690,7 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
1691
1690
} else {
1692
1691
arg1 = compiler . compileExpression ( operands [ 1 ] , type , Constraints . ConvImplicit | Constraints . MustWrap ) ;
1693
1692
}
1694
- let op : BinaryOp = - 1 ;
1693
+ let op : BinaryOp | null = null ;
1695
1694
switch ( type . kind ) {
1696
1695
case TypeKind . I8 :
1697
1696
case TypeKind . I16 :
@@ -1707,14 +1706,14 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
1707
1706
case TypeKind . F32 : return module . binary ( BinaryOp . MinF32 , arg0 , arg1 ) ;
1708
1707
case TypeKind . F64 : return module . binary ( BinaryOp . MinF64 , arg0 , arg1 ) ;
1709
1708
}
1710
- if ( op as i32 != - 1 ) {
1709
+ if ( op ) {
1711
1710
let flow = compiler . currentFlow ;
1712
1711
let typeRef = type . toRef ( ) ;
1713
1712
let temp1 = flow . getTempLocal ( type ) ;
1714
1713
flow . setLocalFlag ( temp1 . index , LocalFlags . Wrapped ) ;
1715
1714
let temp2 = flow . getTempLocal ( type ) ;
1716
1715
flow . setLocalFlag ( temp2 . index , LocalFlags . Wrapped ) ;
1717
- let ret = module . select (
1716
+ return module . select (
1718
1717
module . local_tee ( temp1 . index , arg0 , false ) , // numeric
1719
1718
module . local_tee ( temp2 . index , arg1 , false ) , // numeric
1720
1719
module . binary ( op ,
@@ -1723,7 +1722,6 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
1723
1722
) ,
1724
1723
typeRef
1725
1724
) ;
1726
- return ret ;
1727
1725
}
1728
1726
}
1729
1727
compiler . error (
0 commit comments