Open dipyalov opened 10 months ago
Forgot to mention - I have --debug option set. And my investigation has shown that this code is generated for debugging purposes in unsafe_cast HL op produced here:
Still don't understand how it should be fixed yet.
Should replacing unsafe_cast_to ctx ret rt e.epos
with unsafe_cast_to ~debugchk:false ctx ret rt e.epos
be OK? Or is there a special idea to not set debugchk to false?
I'm getting a similar error, but I have no idea where in my codebase it's coming from. It doesn't show up when compiling for hashlink HL
Error: Don't know how to compare bytes and bytes (hlc)
I was able to narrow it down to hl.Bytes. But that makes little sense.
class Junk{
public static function exists2(a : hl.Bytes) {
return a != null;
}
}
class HelloWorld {
public static function main() {
trace('Hello, World! ${Junk.exists2(null)}');
}
}
Error: Don't know how to compare bytes and bytes (hlc)
I don't see HBytes anywhere here, but my ocaml is not great.
let common_type ctx e1 e2 for_eq p =
let t1 = to_type ctx e1.etype in
let t2 = to_type ctx e2.etype in
let rec loop t1 t2 =
if t1 == t2 then t1 else
match t1, t2 with
| HUI8, (HUI16 | HI32 | HI64 | HF32 | HF64) -> t2
| HUI16, (HI32 | HI64 | HF32 | HF64) -> t2
| (HI32 | HI64), HF32 -> t2 (* possible loss of precision *)
| (HI32 | HI64 | HF32), HF64 -> t2
| (HUI8|HUI16|HI32|HI64|HF32|HF64), (HUI8|HUI16|HI32|HI64|HF32|HF64) -> t1
| (HUI8|HUI16|HI32|HI64|HF32|HF64), (HNull t2) -> if for_eq then HNull (loop t1 t2) else loop t1 t2
| (HNull t1), (HUI8|HUI16|HI32|HI64|HF32|HF64) -> if for_eq then HNull (loop t1 t2) else loop t1 t2
| (HNull t1), (HNull t2) -> if for_eq then HNull (loop t1 t2) else loop t1 t2
| HDyn, (HUI8|HUI16|HI32|HI64|HF32|HF64) -> HF64
| (HUI8|HUI16|HI32|HI64|HF32|HF64), HDyn -> HF64
| HDyn, _ -> HDyn
| _, HDyn -> HDyn
| _ when for_eq && safe_cast t1 t2 -> t2
| _ when for_eq && safe_cast t2 t1 -> t1
| HBool, HNull HBool when for_eq -> t2
| HNull HBool, HBool when for_eq -> t1
| HObj _, HVirtual _ | HVirtual _, HObj _ | HVirtual _ , HVirtual _ -> HDyn
| HFun _, HFun _ -> HDyn
| _ ->
abort ("Don't know how to compare " ^ tstr t1 ^ " and " ^ tstr t2) p
in
loop t1 t2
But this is the regular HL code emitter, which works. It's just the HL/C equivalent that doesn't work.
in hl2c.ml I wonder if adding HByte comparison case at line 747 should be:
match rtype a, rtype b with
| (HUI8 | HUI16 | HI32 | HF32 | HF64 | HBool | HI64), (HUI8 | HUI16 | HI32 | HF32 | HF64 | HBool | HI64) ->
phys_compare()
| HBytes, HBytes ->
phys_compare()
@Simn I saw your HArry / HArry compare case change and thought this was something similar.
Haxe: latest git Hashlink: latest git Heaps.io: latest git
I'm compiling a sample Heaps.io project with DX12 backend to HL/C target. Compiler throws "Error: Don't know how to compare array and array (hlc)" message.
My investigation has shown the following:
The "flushPipeline" method of heaps/h3d/DX12Driver.hx has the following code:
And something between:
makes HL/C generate the following C code:
The ### WRONG ### part is my modification to debug this as the haxe compiler actually fails at this point because it can't generate comparison statement for 2 arrays.