Skip to content

Commit

Permalink
[jvm] handle some missing TFloat cases
Browse files Browse the repository at this point in the history
closes #10965
  • Loading branch information
Simn committed Feb 13, 2023
1 parent a985681 commit 29a318d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/generators/genjvm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,9 @@ class texpr_to_jvm
| TDouble ->
code#dconst 1.;
if op = Increment then code#dadd else code#dsub
| TFloat ->
code#fconst 1.;
if op = Increment then code#fadd else code#fsub
| TByte | TShort | TInt ->
code#iconst Int32.one;
if op = Increment then code#iadd else code#isub;
Expand All @@ -1412,6 +1415,7 @@ class texpr_to_jvm
begin match jsig with
| TLong -> code#lneg;
| TDouble -> code#dneg;
| TFloat -> code#fneg;
| TByte | TShort | TInt -> code#ineg;
| _ -> jm#invokestatic haxe_jvm_path "opNeg" (method_sig [object_sig] (Some object_sig))
end;
Expand Down
39 changes: 39 additions & 0 deletions tests/unit/src/unit/issues/Issue10965.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package unit.issues;

class Issue10965 extends Test {
#if jvm
function testNeg() {
var a:Single = 1;
var c = -a;
eq((-1 : Single), c);
}

function testIncPre() {
var a:Single = 1;
var c = ++a;
eq((2 : Single), a);
eq((2 : Single), c);
}

function testIncPost() {
var a:Single = 1;
var c = a++;
eq((2 : Single), a);
eq((1 : Single), c);
}

function testDecPre() {
var a:Single = 1;
var c = --a;
eq((0 : Single), a);
eq((0 : Single), c);
}

function testDecPost() {
var a:Single = 1;
var c = a--;
eq((0 : Single), a);
eq((1 : Single), c);
}
#end
}

0 comments on commit 29a318d

Please sign in to comment.