authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-26 15:10:11-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-26 15:11:05-04:00
logaf95e1557214df4a1a34a712efc2f8dafb502c82
tree5d732211732bc7ef9fd7f4565c3d5e6668dcd2b8
parent8e714289cac55fd6f793cf21cea5fa1930edb985

rename get_maybe_type to get_optional_type


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

src/all_types.hpp+1-1
......@@ -1233,7 +1233,7 @@ struct TypeTableEntry {
12331233
12341234 // use these fields to make sure we don't duplicate type table entries for the same type
12351235 TypeTableEntry *pointer_parent[2]; // [0 - mut, 1 - const]
1236 TypeTableEntry *maybe_parent;
1236 TypeTableEntry *optional_parent;
12371237 TypeTableEntry *promise_parent;
12381238 TypeTableEntry *promise_frame_parent;
12391239 // If we generate a constant name value for this type, we memoize it here.
src/analyze.cpp+6-6
......@@ -482,7 +482,7 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)
482482 return return_type->promise_frame_parent;
483483 }
484484
485 TypeTableEntry *awaiter_handle_type = get_maybe_type(g, g->builtin_types.entry_promise);
485 TypeTableEntry *awaiter_handle_type = get_optional_type(g, g->builtin_types.entry_promise);
486486 TypeTableEntry *result_ptr_type = get_pointer_to_type(g, return_type, false);
487487
488488 ZigList<const char *> field_names = {};
......@@ -513,9 +513,9 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)
513513 return entry;
514514}
515515
516TypeTableEntry *get_maybe_type(CodeGen *g, TypeTableEntry *child_type) {
517 if (child_type->maybe_parent) {
518 TypeTableEntry *entry = child_type->maybe_parent;
516TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {
517 if (child_type->optional_parent) {
518 TypeTableEntry *entry = child_type->optional_parent;
519519 return entry;
520520 } else {
521521 ensure_complete_type(g, child_type);
......@@ -592,7 +592,7 @@ TypeTableEntry *get_maybe_type(CodeGen *g, TypeTableEntry *child_type) {
592592
593593 entry->data.maybe.child_type = child_type;
594594
595 child_type->maybe_parent = entry;
595 child_type->optional_parent = entry;
596596 return entry;
597597 }
598598}
......@@ -2996,7 +2996,7 @@ static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) {
29962996 return wrong_panic_prototype(g, proto_node, fn_type);
29972997 }
29982998
2999 TypeTableEntry *optional_ptr_to_stack_trace_type = get_maybe_type(g, get_ptr_to_stack_trace_type(g));
2999 TypeTableEntry *optional_ptr_to_stack_trace_type = get_optional_type(g, get_ptr_to_stack_trace_type(g));
30003000 if (fn_type_id->param_info[1].type != optional_ptr_to_stack_trace_type) {
30013001 return wrong_panic_prototype(g, proto_node, fn_type);
30023002 }
src/analyze.hpp+1-1
......@@ -24,7 +24,7 @@ TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
2424TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);
2525TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type);
2626TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id);
27TypeTableEntry *get_maybe_type(CodeGen *g, TypeTableEntry *child_type);
27TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type);
2828TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t array_size);
2929TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type);
3030TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
src/ir.cpp+19-19
......@@ -3044,7 +3044,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode
30443044
30453045 ir_build_store_ptr(irb, scope, node, irb->exec->coro_result_field_ptr, return_value);
30463046 IrInstruction *promise_type_val = ir_build_const_type(irb, scope, node,
3047 get_maybe_type(irb->codegen, irb->codegen->builtin_types.entry_promise));
3047 get_optional_type(irb->codegen, irb->codegen->builtin_types.entry_promise));
30483048 // TODO replace replacement_value with @intToPtr(?promise, 0x1) when it doesn't crash zig
30493049 IrInstruction *replacement_value = irb->exec->coro_handle;
30503050 IrInstruction *maybe_await_handle = ir_build_atomic_rmw(irb, scope, node,
......@@ -6654,7 +6654,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *parent_scope, Ast
66546654 ir_build_store_ptr(irb, parent_scope, node, result_ptr_field_ptr, my_result_var_ptr);
66556655 IrInstruction *save_token = ir_build_coro_save(irb, parent_scope, node, irb->exec->coro_handle);
66566656 IrInstruction *promise_type_val = ir_build_const_type(irb, parent_scope, node,
6657 get_maybe_type(irb->codegen, irb->codegen->builtin_types.entry_promise));
6657 get_optional_type(irb->codegen, irb->codegen->builtin_types.entry_promise));
66586658 IrInstruction *maybe_await_handle = ir_build_atomic_rmw(irb, parent_scope, node,
66596659 promise_type_val, awaiter_field_ptr, nullptr, irb->exec->coro_handle, nullptr,
66606660 AtomicRmwOp_xchg, AtomicOrderSeqCst);
......@@ -6988,7 +6988,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
69886988 VariableTableEntry *await_handle_var = ir_create_var(irb, node, coro_scope, nullptr, false, false, true, const_bool_false);
69896989 IrInstruction *null_value = ir_build_const_null(irb, coro_scope, node);
69906990 IrInstruction *await_handle_type_val = ir_build_const_type(irb, coro_scope, node,
6991 get_maybe_type(irb->codegen, irb->codegen->builtin_types.entry_promise));
6991 get_optional_type(irb->codegen, irb->codegen->builtin_types.entry_promise));
69926992 ir_build_var_decl(irb, coro_scope, node, await_handle_var, await_handle_type_val, nullptr, null_value);
69936993 irb->exec->await_handle_var_ptr = ir_build_var_ptr(irb, coro_scope, node, await_handle_var);
69946994
......@@ -8762,7 +8762,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
87628762 } else if (prev_inst->value.type->id == TypeTableEntryIdOptional) {
87638763 return prev_inst->value.type;
87648764 } else {
8765 return get_maybe_type(ira->codegen, prev_inst->value.type);
8765 return get_optional_type(ira->codegen, prev_inst->value.type);
87668766 }
87678767 } else {
87688768 return prev_inst->value.type;
......@@ -12127,7 +12127,7 @@ static TypeTableEntry *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
1212712127{
1212812128 if (instruction->optional == IrInstructionErrorReturnTrace::Null) {
1212912129 TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(ira->codegen);
12130 TypeTableEntry *optional_type = get_maybe_type(ira->codegen, ptr_to_stack_trace_type);
12130 TypeTableEntry *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);
1213112131 if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) {
1213212132 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1213312133 assert(get_codegen_ptr_type(optional_type) != nullptr);
......@@ -13105,7 +13105,7 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op
1310513105 case TypeTableEntryIdPromise:
1310613106 {
1310713107 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);
13108 out_val->data.x_type = get_maybe_type(ira->codegen, type_entry);
13108 out_val->data.x_type = get_optional_type(ira->codegen, type_entry);
1310913109 return ira->codegen->builtin_types.entry_type;
1311013110 }
1311113111 case TypeTableEntryIdUnreachable:
......@@ -16326,7 +16326,7 @@ static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
1632616326 true, false, PtrLenUnknown,
1632716327 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8),
1632816328 0, 0);
16329 fn_def_fields[6].type = get_maybe_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr));
16329 fn_def_fields[6].type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr));
1633016330 if (fn_node->is_extern && buf_len(fn_node->lib_name) > 0) {
1633116331 fn_def_fields[6].data.x_optional = create_const_vals(1);
1633216332 ConstExprValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name);
......@@ -16609,7 +16609,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1660916609 // child: ?type
1661016610 ensure_field_index(result->type, "child", 0);
1661116611 fields[0].special = ConstValSpecialStatic;
16612 fields[0].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type);
16612 fields[0].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
1661316613
1661416614 if (type_entry->data.promise.result_type == nullptr)
1661516615 fields[0].data.x_optional = nullptr;
......@@ -16763,7 +16763,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1676316763 // tag_type: ?type
1676416764 ensure_field_index(result->type, "tag_type", 1);
1676516765 fields[1].special = ConstValSpecialStatic;
16766 fields[1].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type);
16766 fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
1676716767
1676816768 AstNode *union_decl_node = type_entry->data.unionation.decl_node;
1676916769 if (union_decl_node->data.container_decl.auto_enum ||
......@@ -16803,7 +16803,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1680316803
1680416804 ConstExprValue *inner_fields = create_const_vals(3);
1680516805 inner_fields[1].special = ConstValSpecialStatic;
16806 inner_fields[1].type = get_maybe_type(ira->codegen, type_info_enum_field_type);
16806 inner_fields[1].type = get_optional_type(ira->codegen, type_info_enum_field_type);
1680716807
1680816808 if (fields[1].data.x_optional == nullptr) {
1680916809 inner_fields[1].data.x_optional = nullptr;
......@@ -16874,7 +16874,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1687416874
1687516875 ConstExprValue *inner_fields = create_const_vals(3);
1687616876 inner_fields[1].special = ConstValSpecialStatic;
16877 inner_fields[1].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_usize);
16877 inner_fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_usize);
1687816878
1687916879 if (!type_has_bits(struct_field->type_entry)) {
1688016880 inner_fields[1].data.x_optional = nullptr;
......@@ -16934,7 +16934,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1693416934 // return_type: ?type
1693516935 ensure_field_index(result->type, "return_type", 3);
1693616936 fields[3].special = ConstValSpecialStatic;
16937 fields[3].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type);
16937 fields[3].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
1693816938 if (type_entry->data.fn.fn_type_id.return_type == nullptr)
1693916939 fields[3].data.x_optional = nullptr;
1694016940 else {
......@@ -16947,7 +16947,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1694716947 // async_allocator_type: type
1694816948 ensure_field_index(result->type, "async_allocator_type", 4);
1694916949 fields[4].special = ConstValSpecialStatic;
16950 fields[4].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type);
16950 fields[4].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
1695116951 if (type_entry->data.fn.fn_type_id.async_allocator_type == nullptr)
1695216952 fields[4].data.x_optional = nullptr;
1695316953 else {
......@@ -16990,7 +16990,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1699016990 inner_fields[1].type = ira->codegen->builtin_types.entry_bool;
1699116991 inner_fields[1].data.x_bool = fn_param_info->is_noalias;
1699216992 inner_fields[2].special = ConstValSpecialStatic;
16993 inner_fields[2].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type);
16993 inner_fields[2].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
1699416994
1699516995 if (arg_is_generic)
1699616996 inner_fields[2].data.x_optional = nullptr;
......@@ -17342,7 +17342,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct
1734217342 IrInstruction *result = ir_build_cmpxchg(&ira->new_irb, instruction->base.scope, instruction->base.source_node,
1734317343 nullptr, casted_ptr, casted_cmp_value, casted_new_value, nullptr, nullptr, instruction->is_weak,
1734417344 operand_type, success_order, failure_order);
17345 result->value.type = get_maybe_type(ira->codegen, operand_type);
17345 result->value.type = get_optional_type(ira->codegen, operand_type);
1734617346 ir_link_new_instruction(result, &instruction->base);
1734717347 ir_add_alloca(ira, result, result->value.type);
1734817348 return result->value.type;
......@@ -19013,7 +19013,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
1901319013 old_align_bytes = ptr_type->data.pointer.alignment;
1901419014 TypeTableEntry *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes);
1901519015
19016 result_type = get_maybe_type(ira->codegen, better_ptr_type);
19016 result_type = get_optional_type(ira->codegen, better_ptr_type);
1901719017 } else if (target_type->id == TypeTableEntryIdOptional &&
1901819018 target_type->data.maybe.child_type->id == TypeTableEntryIdFn)
1901919019 {
......@@ -19021,7 +19021,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
1902119021 old_align_bytes = fn_type_id.alignment;
1902219022 fn_type_id.alignment = align_bytes;
1902319023 TypeTableEntry *fn_type = get_fn_type(ira->codegen, &fn_type_id);
19024 result_type = get_maybe_type(ira->codegen, fn_type);
19024 result_type = get_optional_type(ira->codegen, fn_type);
1902519025 } else if (is_slice(target_type)) {
1902619026 TypeTableEntry *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;
1902719027 old_align_bytes = slice_ptr_type->data.pointer.alignment;
......@@ -19782,7 +19782,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstru
1978219782 instruction->base.source_node, coro_id, coro_handle);
1978319783 ir_link_new_instruction(result, &instruction->base);
1978419784 TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
19785 result->value.type = get_maybe_type(ira->codegen, ptr_type);
19785 result->value.type = get_optional_type(ira->codegen, ptr_type);
1978619786 return result->value.type;
1978719787}
1978819788
......@@ -19850,7 +19850,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira,
1985019850 instruction->base.source_node, alloc_fn, coro_size);
1985119851 ir_link_new_instruction(result, &instruction->base);
1985219852 TypeTableEntry *u8_ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
19853 result->value.type = get_maybe_type(ira->codegen, u8_ptr_type);
19853 result->value.type = get_optional_type(ira->codegen, u8_ptr_type);
1985419854 return result->value.type;
1985519855}
1985619856