authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-29 14:03:55+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-29 14:03:55+03:00
log66aa760f83529cf932d35090adfa6fb84264ff7a
tree7053c3e4c4a586a51718b335f8c12e4a5d259fd6
parentaf73462da46611ea9293f283ce8a6920ad73b10f

More FnDef TypeInfo generation.


2 files changed, 39 insertions(+), 1 deletions(-)

src/codegen.cpp+4
...@@ -6500,6 +6500,10 @@ static void define_builtin_compile_vars(CodeGen *g) {...@@ -6500,6 +6500,10 @@ static void define_builtin_compile_vars(CodeGen *g) {
6500 " fn_type: type,\n"6500 " fn_type: type,\n"
6501 " inline_type: Inline,\n"6501 " inline_type: Inline,\n"
6502 " calling_convention: CallingConvention,\n"6502 " calling_convention: CallingConvention,\n"
6503 " is_var_args: bool,\n"
6504 " is_extern: bool,\n"
6505 " is_export: bool,\n"
6506 " lib_name: ?[]const u8,\n"
6503 "\n"6507 "\n"
6504 " const Inline = enum {\n"6508 " const Inline = enum {\n"
6505 " Auto,\n"6509 " Auto,\n"
src/ir.cpp+35-1
...@@ -15920,7 +15920,7 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop...@@ -15920,7 +15920,7 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
15920 fn_def_val->data.x_struct.parent.data.p_union.union_val = &inner_fields[2];15920 fn_def_val->data.x_struct.parent.data.p_union.union_val = &inner_fields[2];
1592115921
15922 // @TODO Add fields15922 // @TODO Add fields
15923 ConstExprValue *fn_def_fields = create_const_vals(3);15923 ConstExprValue *fn_def_fields = create_const_vals(7);
15924 fn_def_val->data.x_struct.fields = fn_def_fields;15924 fn_def_val->data.x_struct.fields = fn_def_fields;
1592515925
15926 // fn_type: type15926 // fn_type: type
...@@ -15938,6 +15938,40 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop...@@ -15938,6 +15938,40 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
15938 fn_def_fields[2].special = ConstValSpecialStatic;15938 fn_def_fields[2].special = ConstValSpecialStatic;
15939 fn_def_fields[2].type = ir_type_info_get_type(ira, "CallingConvention");15939 fn_def_fields[2].type = ir_type_info_get_type(ira, "CallingConvention");
15940 bigint_init_unsigned(&fn_def_fields[2].data.x_enum_tag, fn_node->cc);15940 bigint_init_unsigned(&fn_def_fields[2].data.x_enum_tag, fn_node->cc);
15941 // is_var_args: bool
15942 ensure_field_index(fn_def_val->type, "is_var_args", 3);
15943 fn_def_fields[3].special = ConstValSpecialStatic;
15944 fn_def_fields[3].type = ira->codegen->builtin_types.entry_bool;
15945 fn_def_fields[3].data.x_bool = fn_node->is_var_args;
15946 // is_extern: bool
15947 ensure_field_index(fn_def_val->type, "is_extern", 4);
15948 fn_def_fields[4].special = ConstValSpecialStatic;
15949 fn_def_fields[4].type = ira->codegen->builtin_types.entry_bool;
15950 fn_def_fields[4].data.x_bool = fn_node->is_extern;
15951 // is_export: bool
15952 ensure_field_index(fn_def_val->type, "is_export", 5);
15953 fn_def_fields[5].special = ConstValSpecialStatic;
15954 fn_def_fields[5].type = ira->codegen->builtin_types.entry_bool;
15955 fn_def_fields[5].data.x_bool = fn_node->is_export;
15956 // lib_name: ?[]const u8
15957 ensure_field_index(fn_def_val->type, "lib_name", 6);
15958 fn_def_fields[6].special = ConstValSpecialStatic;
15959 fn_def_fields[6].type = get_maybe_type(ira->codegen,
15960 get_slice_type(ira->codegen, get_pointer_to_type(ira->codegen,
15961 ira->codegen->builtin_types.entry_u8, true)));
15962
15963
15964 if (fn_node->is_extern && buf_len(fn_node->lib_name) > 0)
15965 {
15966 fn_def_fields[6].data.x_maybe = create_const_vals(1);
15967 // @TODO Figure out if lib_name is always non-null for extern fns.
15968 ConstExprValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name);
15969 init_const_slice(ira->codegen, fn_def_fields[6].data.x_maybe, lib_name, 0, buf_len(fn_node->lib_name), true);
15970 }
15971 else
15972 {
15973 fn_def_fields[6].data.x_maybe = nullptr;
15974 }
1594115975
15942 inner_fields[2].data.x_union.payload = fn_def_val;15976 inner_fields[2].data.x_union.payload = fn_def_val;
15943 break;15977 break;