authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-04-24 16:33:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-04-24 16:33:52-07:00
log3886fdc19b624e6fa47dcd02b627548bc7a7ada0
treeb73b5f700b5514e78c48d755086fe21dc12099aa
parent8583fd7f9f96887fe685354662b1fc076ebeb031

rename unknown_size_array to slice


4 files changed, 23 insertions(+), 23 deletions(-)

src/all_types.hpp+1-1
......@@ -870,7 +870,7 @@ struct TypeTableEntryStruct {
870870 TypeStructField *fields;
871871 uint64_t size_bytes;
872872 bool is_invalid; // true if any fields are invalid
873 bool is_unknown_size_array;
873 bool is_slice;
874874 BlockContext *block_context;
875875
876876 // set this flag temporarily to detect infinite loops
src/analyze.cpp+12-12
......@@ -454,7 +454,7 @@ static void slice_type_common_init(CodeGen *g, TypeTableEntry *child_type,
454454
455455 unsigned element_count = 2;
456456 entry->data.structure.is_packed = false;
457 entry->data.structure.is_unknown_size_array = true;
457 entry->data.structure.is_slice = true;
458458 entry->data.structure.src_field_count = element_count;
459459 entry->data.structure.gen_field_count = element_count;
460460 entry->data.structure.fields = allocate<TypeStructField>(element_count);
......@@ -1762,8 +1762,8 @@ static bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTable
17621762 // unknown size array const
17631763 if (expected_type->id == TypeTableEntryIdStruct &&
17641764 actual_type->id == TypeTableEntryIdStruct &&
1765 expected_type->data.structure.is_unknown_size_array &&
1766 actual_type->data.structure.is_unknown_size_array &&
1765 expected_type->data.structure.is_slice &&
1766 actual_type->data.structure.is_slice &&
17671767 (!actual_type->data.structure.fields[0].type_entry->data.pointer.is_const ||
17681768 expected_type->data.structure.fields[0].type_entry->data.pointer.is_const))
17691769 {
......@@ -1966,9 +1966,9 @@ static bool types_match_with_implicit_cast(CodeGen *g, TypeTableEntry *expected_
19661966 return true;
19671967 }
19681968
1969 // implicit constant sized array to unknown size array conversion
1969 // implicit array to slice conversion
19701970 if (expected_type->id == TypeTableEntryIdStruct &&
1971 expected_type->data.structure.is_unknown_size_array &&
1971 expected_type->data.structure.is_slice &&
19721972 actual_type->id == TypeTableEntryIdArray &&
19731973 types_match_const_cast_only(
19741974 expected_type->data.structure.fields[0].type_entry->data.pointer.child_type,
......@@ -2273,7 +2273,7 @@ static TypeTableEntry *analyze_container_init_expr(CodeGen *g, ImportTableEntry
22732273 if (container_type->id == TypeTableEntryIdInvalid) {
22742274 return container_type;
22752275 } else if (container_type->id == TypeTableEntryIdStruct &&
2276 !container_type->data.structure.is_unknown_size_array &&
2276 !container_type->data.structure.is_slice &&
22772277 (kind == ContainerInitKindStruct || (kind == ContainerInitKindArray &&
22782278 container_init_expr->entries.length == 0)))
22792279 {
......@@ -2352,7 +2352,7 @@ static TypeTableEntry *analyze_container_init_expr(CodeGen *g, ImportTableEntry
23522352 }
23532353 return container_type;
23542354 } else if (container_type->id == TypeTableEntryIdStruct &&
2355 container_type->data.structure.is_unknown_size_array &&
2355 container_type->data.structure.is_slice &&
23562356 kind == ContainerInitKindArray)
23572357 {
23582358 int elem_count = container_init_expr->entries.length;
......@@ -2573,7 +2573,7 @@ static TypeTableEntry *analyze_slice_expr(CodeGen *g, ImportTableEntry *import,
25732573 return_type = get_slice_type(g, array_type->data.pointer.child_type,
25742574 node->data.slice_expr.is_const);
25752575 } else if (array_type->id == TypeTableEntryIdStruct &&
2576 array_type->data.structure.is_unknown_size_array)
2576 array_type->data.structure.is_slice)
25772577 {
25782578 return_type = get_slice_type(g,
25792579 array_type->data.structure.fields[0].type_entry->data.pointer.child_type,
......@@ -2623,7 +2623,7 @@ static TypeTableEntry *analyze_array_access_expr(CodeGen *g, ImportTableEntry *i
26232623 } else if (array_type->id == TypeTableEntryIdPointer) {
26242624 return_type = array_type->data.pointer.child_type;
26252625 } else if (array_type->id == TypeTableEntryIdStruct &&
2626 array_type->data.structure.is_unknown_size_array)
2626 array_type->data.structure.is_slice)
26272627 {
26282628 return_type = array_type->data.structure.fields[0].type_entry->data.pointer.child_type;
26292629 } else {
......@@ -3643,7 +3643,7 @@ static TypeTableEntry *analyze_for_expr(CodeGen *g, ImportTableEntry *import, Bl
36433643 } else if (array_type->id == TypeTableEntryIdArray) {
36443644 child_type = array_type->data.array.child_type;
36453645 } else if (array_type->id == TypeTableEntryIdStruct &&
3646 array_type->data.structure.is_unknown_size_array)
3646 array_type->data.structure.is_slice)
36473647 {
36483648 TypeTableEntry *pointer_type = array_type->data.structure.fields[0].type_entry;
36493649 assert(pointer_type->id == TypeTableEntryIdPointer);
......@@ -3979,9 +3979,9 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B
39793979 return resolve_cast(g, context, node, expr_node, wanted_type, CastOpFloatToInt, false);
39803980 }
39813981
3982 // explicit cast from fixed size array to unknown size array
3982 // explicit cast from array to slice
39833983 if (wanted_type->id == TypeTableEntryIdStruct &&
3984 wanted_type->data.structure.is_unknown_size_array &&
3984 wanted_type->data.structure.is_slice &&
39853985 actual_type->id == TypeTableEntryIdArray &&
39863986 types_match_const_cast_only(
39873987 wanted_type->data.structure.fields[0].type_entry->data.pointer.child_type,
src/codegen.cpp+7-7
......@@ -708,7 +708,7 @@ static LLVMValueRef gen_cast_expr(CodeGen *g, AstNode *node) {
708708 {
709709 assert(cast_expr->tmp_ptr);
710710 assert(wanted_type->id == TypeTableEntryIdStruct);
711 assert(wanted_type->data.structure.is_unknown_size_array);
711 assert(wanted_type->data.structure.is_slice);
712712
713713 TypeTableEntry *pointer_type = wanted_type->data.structure.fields[0].type_entry;
714714
......@@ -883,7 +883,7 @@ static LLVMValueRef gen_array_elem_ptr(CodeGen *g, AstNode *source_node, LLVMVal
883883 add_debug_source_node(g, source_node);
884884 return LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 1, "");
885885 } else if (array_type->id == TypeTableEntryIdStruct) {
886 assert(array_type->data.structure.is_unknown_size_array);
886 assert(array_type->data.structure.is_slice);
887887 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind);
888888 assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind);
889889
......@@ -998,7 +998,7 @@ static LLVMValueRef gen_slice_expr(CodeGen *g, AstNode *node) {
998998
999999 return tmp_struct_ptr;
10001000 } else if (array_type->id == TypeTableEntryIdStruct) {
1001 assert(array_type->data.structure.is_unknown_size_array);
1001 assert(array_type->data.structure.is_slice);
10021002 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind);
10031003 assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind);
10041004
......@@ -1046,7 +1046,7 @@ static LLVMValueRef gen_array_access_expr(CodeGen *g, AstNode *node, bool is_lva
10461046 if (array_type->id == TypeTableEntryIdPointer) {
10471047 child_type = array_type->data.pointer.child_type;
10481048 } else if (array_type->id == TypeTableEntryIdStruct) {
1049 assert(array_type->data.structure.is_unknown_size_array);
1049 assert(array_type->data.structure.is_slice);
10501050 TypeTableEntry *child_ptr_type = array_type->data.structure.fields[0].type_entry;
10511051 assert(child_ptr_type->id == TypeTableEntryIdPointer);
10521052 child_type = child_ptr_type->data.pointer.child_type;
......@@ -1134,7 +1134,7 @@ static LLVMValueRef gen_lvalue(CodeGen *g, AstNode *expr_node, AstNode *node,
11341134 *out_type_entry = array_type->data.pointer.child_type;
11351135 target_ref = gen_array_ptr(g, node);
11361136 } else if (array_type->id == TypeTableEntryIdStruct) {
1137 assert(array_type->data.structure.is_unknown_size_array);
1137 assert(array_type->data.structure.is_slice);
11381138 *out_type_entry = array_type->data.structure.fields[0].type_entry->data.pointer.child_type;
11391139 target_ref = gen_array_ptr(g, node);
11401140 } else {
......@@ -2430,7 +2430,7 @@ static LLVMValueRef gen_for_expr(CodeGen *g, AstNode *node) {
24302430 array_type->data.array.len, false);
24312431 child_type = array_type->data.array.child_type;
24322432 } else if (array_type->id == TypeTableEntryIdStruct) {
2433 assert(array_type->data.structure.is_unknown_size_array);
2433 assert(array_type->data.structure.is_slice);
24342434 TypeTableEntry *child_ptr_type = array_type->data.structure.fields[0].type_entry;
24352435 assert(child_ptr_type->id == TypeTableEntryIdPointer);
24362436 child_type = child_ptr_type->data.pointer.child_type;
......@@ -2537,7 +2537,7 @@ static LLVMValueRef gen_var_decl_raw(CodeGen *g, AstNode *source_node, AstNodeVa
25372537 if (var_decl->type) {
25382538 TypeTableEntry *var_type = get_type_for_type_node(var_decl->type);
25392539 if (var_type->id == TypeTableEntryIdStruct &&
2540 var_type->data.structure.is_unknown_size_array)
2540 var_type->data.structure.is_slice)
25412541 {
25422542 assert(var_decl->type->type == NodeTypeArrayType);
25432543 AstNode *size_node = var_decl->type->data.array_type.size;
src/eval.cpp+3-3
......@@ -331,7 +331,7 @@ static bool eval_container_init_expr(EvalFn *ef, AstNode *node, ConstExprValue *
331331 out_val->ok = true;
332332
333333 if (container_type->id == TypeTableEntryIdStruct &&
334 !container_type->data.structure.is_unknown_size_array &&
334 !container_type->data.structure.is_slice &&
335335 kind == ContainerInitKindStruct)
336336 {
337337 int expr_field_count = container_init_expr->entries.length;
......@@ -367,7 +367,7 @@ static bool eval_container_init_expr(EvalFn *ef, AstNode *node, ConstExprValue *
367367 add_error_note(ef->root->codegen, msg, node, buf_sprintf("unreachable expression here"));
368368 return true;
369369 } else if (container_type->id == TypeTableEntryIdStruct &&
370 container_type->data.structure.is_unknown_size_array &&
370 container_type->data.structure.is_slice &&
371371 kind == ContainerInitKindArray)
372372 {
373373
......@@ -892,7 +892,7 @@ static bool eval_array_access_expr(EvalFn *ef, AstNode *node, ConstExprValue *ou
892892 }
893893 *out_val = *array_val.data.x_ptr.ptr[index_int];
894894 } else if (array_type->id == TypeTableEntryIdStruct) {
895 assert(array_type->data.structure.is_unknown_size_array);
895 assert(array_type->data.structure.is_slice);
896896
897897 ConstExprValue *len_value = array_val.data.x_struct.fields[1];
898898 uint64_t len_int = len_value->data.x_bignum.data.x_uint;