Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: add a typemap level specifically for Any #16081

Merged
merged 1 commit into from
May 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ function visit(f, mc::TypeMapLevel)
end
end
mc.list !== nothing && visit(f, mc.list)
mc.any !== nothing && visit(f, mc.any)
nothing
end
function visit(f, d::TypeMapEntry)
Expand Down
6 changes: 4 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,9 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v)
offsetof(jl_typemap_level_t, arg1) == 0 * sizeof(jl_value_t*) &&
offsetof(jl_typemap_level_t, targ) == 1 * sizeof(jl_value_t*) &&
offsetof(jl_typemap_level_t, linear) == 2 * sizeof(jl_value_t*) &&
offsetof(jl_typemap_level_t, key) == 3 * sizeof(jl_value_t*) &&
sizeof(jl_typemap_level_t) == 4 * sizeof(jl_value_t*));
offsetof(jl_typemap_level_t, any) == 3 * sizeof(jl_value_t*) &&
offsetof(jl_typemap_level_t, key) == 4 * sizeof(jl_value_t*) &&
sizeof(jl_typemap_level_t) == 5 * sizeof(jl_value_t*));
if (node->arg1 != (void*)jl_nothing) {
jl_array_t *a = jl_alloc_cell_1d(0);
for (i = 0, l = jl_array_len(node->arg1); i < l; i++) {
Expand All @@ -960,6 +961,7 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v)
jl_serialize_value(s, jl_nothing);
}
jl_serialize_value(s, node->linear);
jl_serialize_value(s, node->any.unknown);
jl_serialize_value(s, node->key);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3386,9 +3386,9 @@ void jl_init_types(void)

jl_typemap_level_type =
jl_new_datatype(jl_symbol("TypeMapLevel"), jl_any_type, jl_emptysvec,
jl_svec(4, jl_symbol("arg1"), jl_symbol("targ"), jl_symbol("list"), jl_symbol("key")),
jl_svec(4, jl_any_type, jl_any_type, jl_any_type, jl_any_type),
0, 1, 3);
jl_svec(5, jl_symbol("arg1"), jl_symbol("targ"), jl_symbol("list"), jl_symbol("any"), jl_symbol("key")),
jl_svec(5, jl_any_type, jl_any_type, jl_any_type, jl_any_type, jl_any_type),
0, 1, 4);

jl_typemap_entry_type =
jl_new_datatype(jl_symbol("TypeMapEntry"), jl_any_type, jl_emptysvec,
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ typedef struct _jl_typemap_level_t {
jl_array_t *arg1; // Array{union jl_typemap_t}
jl_array_t *targ; // Array{union jl_typemap_t}
jl_typemap_entry_t *linear; // union jl_typemap_t (but no more levels)
union jl_typemap_t any; // type at offs is Any
jl_value_t *key; // [nullable]
} jl_typemap_level_t;

Expand Down
Loading