@@ -605,7 +605,10 @@ let toInt com (ctx: Context) r targetType (args: Expr list) =
605605 | JsNumber UInt32 -> emitJsExpr None ( Number UInt32) [ arg] " $0 >>> 0"
606606 | _ -> failwithf " Unexpected non-integer type %A " typeTo
607607 match sourceType, targetType with
608- | Char, _ -> Helper.InstanceCall( args.Head, " charCodeAt" , targetType, [ makeIntConst 0 ])
608+ | Char, _ ->
609+ match targetType, args with
610+ | Number kind, Value( CharConstant c, r)::_ -> Value( NumberConstant( float c, kind), r)
611+ | _ -> Helper.InstanceCall( args.Head, " charCodeAt" , targetType, [ makeIntConst 0 ])
609612 | String, _ -> stringToInt com ctx r targetType args
610613 | Builtin BclBigInt, _ -> Helper.LibCall( com, " BigInt" , castBigIntMethod targetType, targetType, args)
611614 | NumberExt typeFrom, NumberExt typeTo ->
@@ -696,7 +699,12 @@ let applyOp (com: ICompiler) (ctx: Context) r t opName (args: Expr list) argType
696699 Operation( Logical( op, left, right), Boolean, r)
697700 let nativeOp opName argTypes args =
698701 match opName, args with
699- | Operators.addition, [ left; right] -> binOp BinaryPlus left right
702+ | Operators.addition, [ left; right] ->
703+ match argTypes with
704+ | Char::_ ->
705+ let toUInt16 e = toInt com ctx None ( Number UInt16) [ e]
706+ Operation( Binary( BinaryPlus, toUInt16 left, toUInt16 right), Number UInt16, r) |> toChar
707+ | _ -> binOp BinaryPlus left right
700708 | Operators.subtraction, [ left; right] -> binOp BinaryMinus left right
701709 | Operators.multiply, [ left; right] -> binOp BinaryMultiply left right
702710 | ( Operators.division | Operators.divideByInt), [ left; right] ->
@@ -1622,6 +1630,12 @@ let operators (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr o
16221630 | " Sign" , _ ->
16231631 let args = toFloat com ctx r t args |> List.singleton
16241632 Helper.LibCall( com, " Util" , " sign" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
1633+ | " DivRem" , _ ->
1634+ let modName =
1635+ match i.SignatureArgTypes with
1636+ | Builtin ( BclInt64)::_ -> " Long"
1637+ | _ -> " Int32"
1638+ Helper.LibCall( com, modName, " divRem" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
16251639 // Numbers
16261640 | ( " Infinity" | " InfinitySingle" ), _ ->
16271641 Helper.GlobalIdent( " Number" , " POSITIVE_INFINITY" , t, ?loc= r) |> Some
0 commit comments