Closed privat closed 8 years ago
Is there a common internal type to represent NativeArray between the compiler and the interpreter?
No, native array are truly native, there isn't even a common representation between the separate and the global compiler. My best guess is to handle them as an opaque type (void* ?) for the moment.
Ok, so the only practical usage is to write a temporary extern implementation of a method until the intern version is integrated in c_src? So the only target engine should be the compiler? Because if the opaque type changes from engine to engine the C code would not be portable between the different engines.
Unless you have a use case of a method in NativeArray
that does not use the state of the receiver?
I may simply catch the error sooner in the interpreter. Because its internal representation of NativeArray does not make much sense in C.
In the compiler, I can mark it as equivalent to a void*
.
My main issue is that the reported error does not make sense.
My second issue is that the interpreter behavior differs form the compiler ones. If you look at the full example, the interpreter can handle the case with the class A without being more able to do anything with self
anyway.
Ohh.. I seems that the issue is possibly not related with NativeArray but with generics.
This one has the same behavior with nitc, nit and nith:
class A
fun foo `{ puts("foo"); `}
end
var a = new A
a.foo
This one does not and fails with nit and nith:
class A[E]
fun foo `{ puts("foo"); `}
end
var a = new A[Int]
a.foo
the error with nit:
x.nit:2,2--40: Runtime error: FFI Error: Cannot load foreign code library for x: nit_compile/x.so: undefined symbol: x___A_of_E_foo___impl
the error with nith:
x._ffi.c:14:43: error: unknown type name ‘A_of_nullable_Object
Heu... what's nith?
Hooo.. right, nith.
Exhibited by #1898 , the following code breaks the interpreter:
This outputs
na_ex.nit:2,2--27: Runtime error: FFI Error: Cannot load foreign code library for na_ex: nit_compile/na_ex.so: undefined symbol: na_ex___NativeArray_of_E_foo___impl
note: you need 8a0d0496177b59434e23c from #1898 else you will fail earlier because _Abstract method
mangled_cname
called onMParameterType
_