Closed Simn closed 5 years ago
Also:
class Main {
static public function main() {
var x:Null<Int> = 0;
x++;
}
}
java.lang.VerifyError: Bad local variable type
Exception Details:
Location:
Main.main([Ljava/lang/String;)V @5: iinc
Reason:
Type 'java/lang/Integer' (current frame, locals[1]) is not assignable to integer
Current Frame:
bci: @5
flags: { }
locals: { '[Ljava/lang/String;', 'java/lang/Integer' }
stack: { }
We can only use iinc
if we have strictly Int and none of that wrapped Nullshit.
And one more:
class Main {
static public function main() {
var n:Dynamic = 0;
n++;
}
}
src/Main.hx:4: characters 3-4 : Unuspported unop on Ljava/lang/Object;
Not quite sure what to actually generate here.
So if the type of unop should be Int, then for n++
we have to generate something like this, right?
var tmp = n.intValue();
n = Integer.valueOf(tmp + 1);
tmp;
(but in terms of stack and in instructions)
For Dynamic
, well:
var tmp = n;
n = Runtime.castToNumberThenAddOneAndWrapBackIntoTheSameType(n);
tmp;
What type does Dynamic++
have? If it's not dynamic then we have to cast tmp too...
The first and second case should be fixed.
For the Dynamic version we need a run-time support function that distinguishes the applicable types.
Or maybe we can just call opAdd/opSub actually...
Fails in the generator with:
I think it's because the TUnop itself is typed as Int: