From c45e392c4fb6b59885aed1a642c5b19684a00d99 Mon Sep 17 00:00:00 2001 From: Thomas van Doornmalen Date: Mon, 5 Jul 2021 18:40:01 +0200 Subject: [PATCH] Working tests on julia-1.7.0beta2 with patches from https://github.com/JuliaLang/julia/issues/41464 --- jl_sys/src/jlrs_c.c | 10 ---------- jl_sys/src/jlrs_c.h | 2 -- jlrs/src/layout/typecheck.rs | 26 ++++++++++++++------------ jlrs/src/wrappers/ptr/datatype.rs | 5 +---- jlrs_derive_tests/src/lib.rs | 14 ++------------ 5 files changed, 17 insertions(+), 40 deletions(-) diff --git a/jl_sys/src/jlrs_c.c b/jl_sys/src/jlrs_c.c index b5345b68..37ebaa29 100644 --- a/jl_sys/src/jlrs_c.c +++ b/jl_sys/src/jlrs_c.c @@ -253,16 +253,6 @@ jlrs_result_t jlrs_type_unionall(jl_tvar_t *v, jl_value_t *body) return out; } - - -JL_DLLEXPORT JL_CONST_FUNC jl_gcframe_t **jl_get_pgcstack(void) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT { - exit(1); -} - jl_task_t *jlrs_current_task() { return jl_current_task; } - -int jl_field_index(jl_datatype_t *t, jl_sym_t *fld, int err) { - assert(0); -} diff --git a/jl_sys/src/jlrs_c.h b/jl_sys/src/jlrs_c.h index 03b16dc7..0f013c30 100644 --- a/jl_sys/src/jlrs_c.h +++ b/jl_sys/src/jlrs_c.h @@ -37,6 +37,4 @@ jlrs_result_t jlrs_set_nth_field(jl_value_t *v, size_t i, jl_value_t *rhs); jlrs_result_t jlrs_type_union(jl_value_t **ts, size_t n); jlrs_result_t jlrs_type_unionall(jl_tvar_t *v, jl_value_t *body); -JL_DLLEXPORT JL_CONST_FUNC jl_gcframe_t **jl_get_pgcstack(void) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT; - jl_task_t *jlrs_current_task(); \ No newline at end of file diff --git a/jlrs/src/layout/typecheck.rs b/jlrs/src/layout/typecheck.rs index 7f28f33b..a94ee5ca 100644 --- a/jlrs/src/layout/typecheck.rs +++ b/jlrs/src/layout/typecheck.rs @@ -135,12 +135,13 @@ pub struct MutableDatatype; unsafe impl Typecheck for MutableDatatype { fn typecheck(t: DataType) -> bool { unsafe { - t.type_name() - .wrapper_unchecked() - .unwrap_non_null(Private) - .as_ref() - .mutabl() - != 0 + DataType::typecheck(t) + && t.type_name() + .wrapper_unchecked() + .unwrap_non_null(Private) + .as_ref() + .mutabl() + != 0 } } } @@ -173,12 +174,13 @@ pub struct ImmutableDatatype; unsafe impl Typecheck for ImmutableDatatype { fn typecheck(t: DataType) -> bool { unsafe { - t.type_name() - .wrapper_unchecked() - .unwrap_non_null(Private) - .as_ref() - .mutabl() - == 0 + DataType::typecheck(t) + && t.type_name() + .wrapper_unchecked() + .unwrap_non_null(Private) + .as_ref() + .mutabl() + == 0 } } } diff --git a/jlrs/src/wrappers/ptr/datatype.rs b/jlrs/src/wrappers/ptr/datatype.rs index dac2d083..ee0e80a5 100644 --- a/jlrs/src/wrappers/ptr/datatype.rs +++ b/jlrs/src/wrappers/ptr/datatype.rs @@ -82,7 +82,6 @@ impl<'scope> DataType<'scope> { unsafe { SimpleVectorRef::wrap(jl_get_fieldtypes(self.unwrap(Private))) } } - // XXX -> TypeName /// Returns the field names of this type. pub fn field_names(self) -> SimpleVectorRef<'scope, Symbol<'scope>> { unsafe { SimpleVectorRef::wrap(jl_field_names(self.unwrap(Private))) } @@ -103,7 +102,6 @@ impl<'scope> DataType<'scope> { unsafe { self.unwrap_non_null(Private).as_ref().hash } } - //// XXX -> TypeName /// Returns true if this is an abstract type. pub fn is_abstract(self) -> bool { unsafe { @@ -153,7 +151,6 @@ impl<'scope> DataType<'scope> { unsafe { self.unwrap_non_null(Private).as_ref().zeroinit() != 0 } } - // XXX /// Returns true if a value of this type stores its data inline. pub fn is_inline_alloc(self) -> bool { unsafe { @@ -163,8 +160,8 @@ impl<'scope> DataType<'scope> { .as_ref() .mayinlinealloc() != 0 + && !self.unwrap_non_null(Private).as_ref().layout.is_null() } - // unsafe { jl_datatype_isinlinealloc(self.unwrap(Private)) != 0 } } /// If false, no value will have this type. diff --git a/jlrs_derive_tests/src/lib.rs b/jlrs_derive_tests/src/lib.rs index 9da7d596..f9336de5 100644 --- a/jlrs_derive_tests/src/lib.rs +++ b/jlrs_derive_tests/src/lib.rs @@ -591,28 +591,19 @@ mod tests { .wrapper_unchecked(); let v1 = Value::new(&mut *frame, 1i8)?; - let v2 = Value::new(&mut *frame, Tuple1(2i16))?; + let v2 = Value::new(&mut *frame, Tuple1(2i32))?; let v3 = Value::new(&mut *frame, 3i8)?; let jl_val = constr.call3(&mut *frame, v1, v2, v3)?.unwrap(); - assert!(Module::base(global) - .function_ref("typeof")? - .wrapper_unchecked() - .call1(&mut *frame, jl_val)? - .unwrap() - .cast::()? - .is::()); - let first = jl_val.get_nth_field(&mut *frame, 0).unwrap(); assert_eq!(first.unbox::().unwrap(), 1); let second = jl_val.get_nth_field(&mut *frame, 1).unwrap(); - assert_eq!(second.unbox::>().unwrap(), Tuple1(2)); + assert_eq!(second.unbox::>().unwrap(), Tuple1(2)); let third = jl_val.get_nth_field(&mut *frame, 2).unwrap(); assert_eq!(third.unbox::().unwrap(), 3); - assert!(jl_val.is::()); let uit = jl_val.unbox::()?; assert_eq!(uit.a, 1); assert_eq!(uit.c, 3); @@ -1000,7 +991,6 @@ mod tests { .is::()); let first = jl_val.get_nth_field(&mut *frame, 0).unwrap(); - eprintln!("First: {:?}", first); first.unbox::>>().unwrap(); assert!(jl_val.is::());