diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index c1f5b16363f2a..0b60d3a2a71f6 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -159,7 +159,6 @@ function generate_precompile_statements() include_time = @elapsed for statement in sort(collect(statements)) # println(statement) # Work around #28808 - occursin("Char(0x", statement) && continue statement == "precompile(Tuple{typeof(Base.show), Base.IOContext{Base.TTY}, Type{Vararg{Any, N} where N}})" && continue try Base.include_string(PrecompileStagingArea, statement) diff --git a/src/rtutils.c b/src/rtutils.c index 184356ad7cfa7..ff116d3463add 100644 --- a/src/rtutils.c +++ b/src/rtutils.c @@ -978,22 +978,33 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt else if (jl_datatype_type && jl_is_datatype(vt)) { int istuple = jl_is_tuple_type(vt), isnamedtuple = jl_is_namedtuple_type(vt); size_t tlen = jl_datatype_nfields(vt); - if (isnamedtuple) { - if (tlen == 0) - n += jl_printf(out, "NamedTuple"); - } - else if (!istuple) { - n += jl_static_show_x(out, (jl_value_t*)vt, depth); - } - n += jl_printf(out, "("); size_t nb = jl_datatype_size(vt); if (nb > 0 && tlen == 0) { uint8_t *data = (uint8_t*)v; - n += jl_printf(out, "0x"); - for(int i = nb - 1; i >= 0; --i) - n += jl_printf(out, "%02" PRIx8, data[i]); - } - else { + n += jl_printf(out, "reinterpret("); + n += jl_static_show_x(out, (jl_value_t*)vt, depth); + n += jl_printf(out, ", 0x"); + uint32_t a = 0x01020304; + uint8_t *endian_bom = (uint8_t*) &a; + if (*endian_bom == 0x01) { // big endian + for(int i = 0; i < nb; ++i) + n += jl_printf(out, "%02" PRIx8, data[i]); + } else if (*endian_bom == 0x04) { // little endian + for(int i = nb - 1; i >= 0; --i) + n += jl_printf(out, "%02" PRIx8, data[i]); + } else { + assert(0); // unsupported endianness + } + n += jl_printf(out, ")"); + } else { + if (isnamedtuple) { + if (tlen == 0) + n += jl_printf(out, "NamedTuple"); + } + else if (!istuple) { + n += jl_static_show_x(out, (jl_value_t*)vt, depth); + } + n += jl_printf(out, "("); size_t i = 0; if (vt == jl_typemap_entry_type) i = 1; @@ -1024,8 +1035,8 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt n += jl_printf(out, ", next=↩︎\n "); n += jl_static_show_x(out, jl_fieldref_noalloc(v, 0), depth); } + n += jl_printf(out, ")"); } - n += jl_printf(out, ")"); } else { n += jl_printf(out, "