|
else if (vt == jl_datatype_type) { |
|
// typeof(v) == DataType, so v is a Type object. |
|
// Types are printed as a fully qualified name, with parameters, e.g. |
|
// `Base.Set{Int}`, and function types are printed as e.g. `typeof(Main.f)` |
|
jl_datatype_t *dv = (jl_datatype_t*)v; |
|
jl_sym_t *globname; |
|
int globfunc = is_globname_binding(v, dv) && is_globfunction(v, dv, &globname); |
|
jl_sym_t *sym = globfunc ? globname : dv->name->name; |
|
char *sn = jl_symbol_name(sym); |
|
size_t quote = 0; |
|
if (dv->name == jl_tuple_typename) { |
|
if (dv == jl_tuple_type) |
|
return jl_printf(out, "Tuple"); |
|
int taillen = 1, tlen = jl_nparams(dv), i; |
|
for (i = tlen-2; i >= 0; i--) { |
|
if (jl_tparam(dv, i) == jl_tparam(dv, tlen-1)) |
|
taillen++; |
|
else |
|
break; |
|
} |
|
if (taillen == tlen && taillen > 3) { |
|
n += jl_printf(out, "NTuple{%d, ", tlen); |
|
n += jl_static_show_x(out, jl_tparam0(dv), depth); |
|
n += jl_printf(out, "}"); |
|
} |
|
else { |
|
n += jl_printf(out, "Tuple{"); |
|
for (i = 0; i < (taillen > 3 ? tlen-taillen : tlen); i++) { |
|
if (i > 0) |
|
n += jl_printf(out, ", "); |
|
n += jl_static_show_x(out, jl_tparam(dv, i), depth); |
|
} |
|
if (taillen > 3) { |
|
n += jl_printf(out, ", Vararg{"); |
|
n += jl_static_show_x(out, jl_tparam(dv, tlen-1), depth); |
|
n += jl_printf(out, ", %d}", taillen); |
|
} |
|
n += jl_printf(out, "}"); |
|
} |
|
return n; |
|
} |
|
if (globfunc) { |
|
n += jl_printf(out, "typeof("); |
|
} |
|
if (jl_core_module && (dv->name->module != jl_core_module || !jl_module_exports_p(jl_core_module, sym))) { |
|
n += jl_static_show_x(out, (jl_value_t*)dv->name->module, depth); |
|
n += jl_printf(out, "."); |
|
size_t i = 0; |
|
if (globfunc && !jl_id_start_char(u8_nextchar(sn, &i))) { |
|
n += jl_printf(out, ":("); |
|
quote = 1; |
|
} |
|
} |
|
n += jl_static_show_x_sym_escaped(out, sym); |
|
if (globfunc) { |
|
n += jl_printf(out, ")"); |
|
if (quote) { |
|
n += jl_printf(out, ")"); |
|
} |
|
} |
|
if (dv->parameters && (jl_value_t*)dv != dv->name->wrapper) { |
|
size_t j, tlen = jl_nparams(dv); |
|
if (tlen > 0) { |
|
n += jl_printf(out, "{"); |
|
for (j = 0; j < tlen; j++) { |
|
jl_value_t *p = jl_tparam(dv,j); |
|
n += jl_static_show_x(out, p, depth); |
|
if (j != tlen-1) |
|
n += jl_printf(out, ", "); |
|
} |
|
n += jl_printf(out, "}"); |
|
} |
|
} |
|
} |