Skip to content

Commit

Permalink
Working tests on julia-1.7.0beta2 with patches from JuliaLang/julia#4…
Browse files Browse the repository at this point in the history
  • Loading branch information
Taaitaaiger committed Jul 5, 2021
1 parent b253985 commit c45e392
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 40 deletions.
10 changes: 0 additions & 10 deletions jl_sys/src/jlrs_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 0 additions & 2 deletions jl_sys/src/jlrs_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
26 changes: 14 additions & 12 deletions jlrs/src/layout/typecheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions jlrs/src/wrappers/ptr/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))) }
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand Down
14 changes: 2 additions & 12 deletions jlrs_derive_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<DataType>()?
.is::<UnionInTuple>());

let first = jl_val.get_nth_field(&mut *frame, 0).unwrap();
assert_eq!(first.unbox::<i8>().unwrap(), 1);

let second = jl_val.get_nth_field(&mut *frame, 1).unwrap();
assert_eq!(second.unbox::<Tuple1<i16>>().unwrap(), Tuple1(2));
assert_eq!(second.unbox::<Tuple1<i32>>().unwrap(), Tuple1(2));

let third = jl_val.get_nth_field(&mut *frame, 2).unwrap();
assert_eq!(third.unbox::<i8>().unwrap(), 3);

assert!(jl_val.is::<UnionInTuple>());
let uit = jl_val.unbox::<UnionInTuple>()?;
assert_eq!(uit.a, 1);
assert_eq!(uit.c, 3);
Expand Down Expand Up @@ -1000,7 +991,6 @@ mod tests {
.is::<WithSetGenericTuple>());

let first = jl_val.get_nth_field(&mut *frame, 0).unwrap();
eprintln!("First: {:?}", first);
first.unbox::<Tuple1<WithGenericT<i64>>>().unwrap();

assert!(jl_val.is::<WithSetGenericTuple>());
Expand Down

0 comments on commit c45e392

Please sign in to comment.