mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -08:00
C backend: fix passing NULL arrays to native methods
This commit is contained in:
parent
f828d049c4
commit
8cd96d2da2
|
@ -507,7 +507,7 @@ public class CodeGenerationVisitor implements ExprVisitor, StatementVisitor {
|
||||||
writer.print(")");
|
writer.print(")");
|
||||||
stringTemporaries.add(tmp);
|
stringTemporaries.add(tmp);
|
||||||
} else if (isPrimitiveArray(type)) {
|
} else if (isPrimitiveArray(type)) {
|
||||||
writer.print("ARRAY_DATA(");
|
writer.print("ARRAY_DATAN(");
|
||||||
expr.getArguments().get(i).acceptVisitor(this);
|
expr.getArguments().get(i).acceptVisitor(this);
|
||||||
writer.print(", ").printStrictType(((ValueType.Array) type).getItemType()).print(")");
|
writer.print(", ").printStrictType(((ValueType.Array) type).getItemType()).print(")");
|
||||||
} else if (isPrimitiveBuffer(type)) {
|
} else if (isPrimitiveBuffer(type)) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ static inline int32_t compare_double(double a, double b) {
|
||||||
#define ALIGN(addr, alignment) ((void*) (((uintptr_t) (addr) + ((alignment) - 1)) / (alignment) * (alignment)))
|
#define ALIGN(addr, alignment) ((void*) (((uintptr_t) (addr) + ((alignment) - 1)) / (alignment) * (alignment)))
|
||||||
#define ARRAY_LENGTH(array) (((JavaArray*) (array))->size)
|
#define ARRAY_LENGTH(array) (((JavaArray*) (array))->size)
|
||||||
#define ARRAY_DATA(array, type) ((type*) ALIGN((((JavaArray*) (array)) + 1), sizeof(type)))
|
#define ARRAY_DATA(array, type) ((type*) ALIGN((((JavaArray*) (array)) + 1), sizeof(type)))
|
||||||
|
#define ARRAY_DATAN(array, type) (array != NULL ? ARRAY_DATA(array, type) : NULL)
|
||||||
#define ARRAY_AT(array, type, index) (((type*) ARRAY_DATA(array, type))[index])
|
#define ARRAY_AT(array, type, index) (((type*) ARRAY_DATA(array, type))[index])
|
||||||
|
|
||||||
static void* throwClassCastException();
|
static void* throwClassCastException();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user