Skip to content

Commit

Permalink
insert StoredArray and DenseArray types between AbstractArray and Array
Browse files Browse the repository at this point in the history
ref #987, #2345

this seems to be the less-controversial core of what we need.
this commit just adds the types and doesn't do anything else with them yet.
  • Loading branch information
JeffBezanson committed Jan 6, 2014
1 parent ced6490 commit 5ed527f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 23 deletions.
6 changes: 4 additions & 2 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
#end

#abstract AbstractArray{T,N}
#abstract StoredArray{T,N} <: AbstractArray{T,N}
#abstract DenseArray{T,N} <: StoredArray{T,N}

#type Array{T,N} <: AbstractArray{T,N}
#type Array{T,N} <: DenseArray{T,N}
#end

#type Module
Expand Down Expand Up @@ -116,7 +118,7 @@ export
# key types
Any, DataType, Vararg, ANY, NTuple, None, Top,
Tuple, Type, TypeConstructor, TypeName, TypeVar, Union, UnionType, Void,
AbstractArray,
AbstractArray, StoredArray, DenseArray,
# special objects
Box, Function, IntrinsicFunction, LambdaStaticData, Method, MethodTable,
Module, Nothing, Symbol, Task, Array,
Expand Down
2 changes: 2 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,8 @@ void jl_init_primitives(void)
add_builtin("Task", (jl_value_t*)jl_task_type);

add_builtin("AbstractArray", (jl_value_t*)jl_abstractarray_type);
add_builtin("StoredArray", (jl_value_t*)jl_storedarray_type);
add_builtin("DenseArray", (jl_value_t*)jl_densearray_type);
add_builtin("Array", (jl_value_t*)jl_array_type);

add_builtin("Expr", (jl_value_t*)jl_expr_type);
Expand Down
34 changes: 16 additions & 18 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ static jl_value_t *jl_deserialize_datatype(ios_t *s, int pos)
dt->fptr = jl_deserialize_fptr(s);
if (dt->name == jl_array_type->name || dt->name == jl_pointer_type->name ||
dt->name == jl_type_type->name || dt->name == jl_vararg_type->name ||
dt->name == jl_abstractarray_type->name) {
dt->name == jl_abstractarray_type->name || dt->name == jl_storedarray_type->name ||
dt->name == jl_densearray_type->name) {
// builtin types are not serialized, so their caches aren't
// explicitly saved. so we reconstruct the caches of builtin
// parametric types here.
Expand Down Expand Up @@ -1208,8 +1209,7 @@ void jl_init_serializer(void)
jl_box_int32(51), jl_box_int32(52), jl_box_int32(53),
jl_box_int32(54), jl_box_int32(55), jl_box_int32(56),
jl_box_int32(57), jl_box_int32(58), jl_box_int32(59),
jl_box_int32(60), jl_box_int32(61), jl_box_int32(62),
jl_box_int32(63), jl_box_int32(64),
jl_box_int32(60), jl_box_int32(61),
#endif
jl_box_int64(0), jl_box_int64(1), jl_box_int64(2),
jl_box_int64(3), jl_box_int64(4), jl_box_int64(5),
Expand All @@ -1232,30 +1232,28 @@ void jl_init_serializer(void)
jl_box_int64(51), jl_box_int64(52), jl_box_int64(53),
jl_box_int64(54), jl_box_int64(55), jl_box_int64(56),
jl_box_int64(57), jl_box_int64(58), jl_box_int64(59),
jl_box_int64(60), jl_box_int64(61), jl_box_int64(62),
jl_box_int64(63), jl_box_int64(64),
jl_box_int64(60), jl_box_int64(61),
#endif
jl_labelnode_type, jl_linenumbernode_type,
jl_gotonode_type, jl_quotenode_type, jl_topnode_type,
jl_type_type, jl_bottom_type, jl_pointer_type,
jl_vararg_type, jl_ntuple_type, jl_abstractarray_type,
jl_box_type, jl_typector_type, jl_undef_type, jl_top_type,
jl_typename_type, jl_task_type, jl_uniontype_type,
jl_typetype_type, jl_typetype_tvar, jl_ANY_flag,
jl_array_any_type, jl_intrinsic_type, jl_method_type,
jl_storedarray_type, jl_densearray_type, jl_box_type,
jl_typector_type, jl_undef_type, jl_top_type, jl_typename_type,
jl_task_type, jl_uniontype_type, jl_typetype_type, jl_typetype_tvar,
jl_ANY_flag, jl_array_any_type, jl_intrinsic_type, jl_method_type,
jl_methtable_type, jl_voidpointer_type, jl_newvarnode_type,
jl_array_symbol_type, jl_tupleref(jl_tuple_type,0),

jl_symbol_type->name, jl_pointer_type->name,
jl_datatype_type->name, jl_uniontype_type->name,
jl_array_type->name, jl_expr_type->name,
jl_symbol_type->name, jl_pointer_type->name, jl_datatype_type->name,
jl_uniontype_type->name, jl_array_type->name, jl_expr_type->name,
jl_typename_type->name, jl_type_type->name, jl_methtable_type->name,
jl_method_type->name, jl_tvar_type->name,
jl_vararg_type->name, jl_ntuple_type->name, jl_abstractarray_type->name,
jl_lambda_info_type->name, jl_module_type->name,
jl_box_type->name, jl_function_type->name,
jl_typector_type->name, jl_intrinsic_type->name, jl_undef_type->name,
jl_task_type->name,
jl_method_type->name, jl_tvar_type->name, jl_vararg_type->name,
jl_ntuple_type->name, jl_abstractarray_type->name,
jl_storedarray_type->name, jl_densearray_type->name,
jl_lambda_info_type->name, jl_module_type->name, jl_box_type->name,
jl_function_type->name, jl_typector_type->name,
jl_intrinsic_type->name, jl_undef_type->name, jl_task_type->name,
jl_labelnode_type->name, jl_linenumbernode_type->name,
jl_gotonode_type->name, jl_quotenode_type->name,
jl_topnode_type->name,
Expand Down
21 changes: 18 additions & 3 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jl_value_t *jl_bottom_type;
jl_value_t *jl_top_type;
jl_datatype_t *jl_vararg_type;
jl_datatype_t *jl_abstractarray_type;
jl_datatype_t *jl_storedarray_type;
jl_datatype_t *jl_densearray_type;

jl_datatype_t *jl_bool_type;
jl_datatype_t *jl_char_type;
Expand Down Expand Up @@ -2668,14 +2670,27 @@ void jl_init_types(void)
jl_methtable_type->fptr = jl_f_no_function;

tv = jl_tuple2(tvar("T"), tvar("N"));
jl_abstractarray_type = jl_new_abstracttype((jl_value_t*)jl_symbol("AbstractArray"),
jl_any_type, tv);
jl_abstractarray_type =
jl_new_abstracttype((jl_value_t*)jl_symbol("AbstractArray"),
jl_any_type, tv);

tv = jl_tuple2(tvar("T"), tvar("N"));
jl_storedarray_type =
jl_new_abstracttype((jl_value_t*)jl_symbol("StoredArray"),
(jl_datatype_t*)jl_apply_type((jl_value_t*)jl_abstractarray_type, tv),
tv);

tv = jl_tuple2(tvar("T"), tvar("N"));
jl_densearray_type =
jl_new_abstracttype((jl_value_t*)jl_symbol("DenseArray"),
(jl_datatype_t*)jl_apply_type((jl_value_t*)jl_storedarray_type, tv),
tv);

tv = jl_tuple2(tvar("T"), tvar("N"));
jl_array_type =
jl_new_datatype(jl_symbol("Array"),
(jl_datatype_t*)
jl_apply_type((jl_value_t*)jl_abstractarray_type, tv),
jl_apply_type((jl_value_t*)jl_densearray_type, tv),
tv,
jl_null, jl_null, 0, 1);
jl_array_typename = jl_array_type->name;
Expand Down
2 changes: 2 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ extern DLLEXPORT jl_datatype_t *jl_module_type;
extern jl_datatype_t *jl_vararg_type;
extern jl_datatype_t *jl_function_type;
extern jl_datatype_t *jl_abstractarray_type;
extern jl_datatype_t *jl_storedarray_type;
extern jl_datatype_t *jl_densearray_type;
extern jl_datatype_t *jl_array_type;
extern jl_typename_t *jl_array_typename;
extern jl_datatype_t *jl_weakref_type;
Expand Down

1 comment on commit 5ed527f

@stevengj
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point these will need to be documented...

Please sign in to comment.