Skip to content

Commit

Permalink
Refactoring for structure implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tenpoku1000 committed May 15, 2022
1 parent 7da21a8 commit 143e688
Show file tree
Hide file tree
Showing 12 changed files with 1,477 additions and 1,380 deletions.
23 changes: 22 additions & 1 deletion src/lib/tp_compiler/tp_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,21 +518,36 @@ bool tp_make_C_IR_jump_statement(
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
TP_C_OBJECT* c_object
);
// Convert parse tree to C IR(declarations).
// Convert parse tree to C IR(declaration).
bool tp_make_C_IR_declaration(
TP_SYMBOL_TABLE* symbol_table,
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
TP_C_OBJECT* c_object
);
// Convert parse tree to C IR(declaration specifiers).
bool tp_make_C_IR_declaration_specifiers(
TP_SYMBOL_TABLE* symbol_table,
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
TP_C_OBJECT* c_object, TP_C_OBJECT* type
);
// Convert parse tree to C IR(type specifier).
bool tp_make_C_IR_type_specifier(
TP_SYMBOL_TABLE* symbol_table,
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
TP_C_OBJECT* c_object, TP_C_TYPE* type
);
// Convert parse tree to C IR(struct or union specifier).
bool tp_make_C_IR_struct_or_union_specifier(
TP_SYMBOL_TABLE* symbol_table,
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
TP_C_OBJECT* c_object, TP_C_TYPE* type
);
// C IR(type check).
bool tp_check_C_IR_type_specifier(
TP_SYMBOL_TABLE* symbol_table,
TP_GRAMMER_CONTEXT grammer_context, TP_C_OBJECT* type
);
// Convert parse tree to C IR(declarator).
bool tp_make_C_IR_declarator(
TP_SYMBOL_TABLE* symbol_table,
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
Expand All @@ -544,6 +559,12 @@ bool tp_make_C_IR_direct_declarator(
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
TP_C_OBJECT* c_object, TP_C_OBJECT* type
);
// Convert parse tree to C IR(parameter type list).
bool tp_make_C_IR_parameter_type_list(
TP_SYMBOL_TABLE* symbol_table,
TP_PARSE_TREE* parse_tree, TP_GRAMMER_CONTEXT grammer_context,
TP_C_OBJECT* c_object, TP_C_OBJECT* type
);
// Convert parse tree to C IR(initializer).
bool tp_make_C_IR_initializer(
TP_SYMBOL_TABLE* symbol_table,
Expand Down
7 changes: 6 additions & 1 deletion src/lib/tp_compiler/tp_compiler.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
<ClCompile Include="tp_make_x64_code\tp_make_x64_code_opcode_etc.c" />
<ClCompile Include="tp_make_x64_code\tp_make_x64_disasm.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_declarations.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_declaration.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_declaration_specifiers.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_declarator.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_direct_declarator.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_const_expr_eval.c" />
Expand All @@ -89,11 +90,15 @@
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_external_declarations.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_function_definition.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_initializer.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_parameter_type_list.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_statements.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_statements_expr.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_statements_iteration.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_statements_jump.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_struct_or_union_specifier.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_translation_unit.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_type_check.c" />
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_type_specifier.c" />
<ClCompile Include="tp_semantic_analysis\tp_semantic_analysis.c" />
<ClCompile Include="tp_semantic_analysis\tp_semantic_analysis_expr.c" />
<ClCompile Include="tp_utils\tp_file.c" />
Expand Down
17 changes: 16 additions & 1 deletion src/lib/tp_compiler/tp_compiler.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_declarations.c">
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_declaration.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_expr.c">
Expand Down Expand Up @@ -321,6 +321,21 @@
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_statements_iteration.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_type_specifier.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_struct_or_union_specifier.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_declaration_specifiers.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_type_check.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
<ClCompile Include="tp_semantic_analysis\tp_make_C_IR_parameter_type_list.c">
<Filter>ソース ファイル\tp_semantic_analysis</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="tp_compiler.h">
Expand Down
18 changes: 14 additions & 4 deletions src/lib/tp_compiler/tp_compiler_semantic_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,29 +367,39 @@ typedef struct tp_c_type_struct_content_ TP_C_TYPE_STRUCT_CONTENT;
typedef struct tp_c_type_struct_content_{
TP_C_TYPE* member_type_member;
TP_TOKEN* member_identifier; // NOTE: member_token must not free memory.
uint32_t member_bits;
size_t member_offset;
// ToDo:
// uint32_t member_bits;
rsize_t member_offset;
uint32_t member_alignment;
uint32_t member_padding_bytes;
rsize_t member_size;
TP_C_TYPE_STRUCT_CONTENT* member_next;
}TP_C_TYPE_STRUCT_CONTENT;

typedef struct tp_c_type_struct_{
rsize_t member_struct_member_num;
TP_C_TYPE_STRUCT_CONTENT* member_struct_content;
size_t member_align;
uint32_t member_alignment;
uint32_t member_padding_bytes;
rsize_t member_size;
}TP_C_TYPE_STRUCT;

typedef struct tp_c_type_union_content_ TP_C_TYPE_UNION_CONTENT;

typedef struct tp_c_type_union_content_{
TP_C_TYPE* member_type_member;
TP_TOKEN* member_identifier; // NOTE: member_token must not free memory.
uint32_t member_alignment;
rsize_t member_size;
TP_C_TYPE_UNION_CONTENT* member_next;
}TP_C_TYPE_UNION_CONTENT;

typedef struct tp_c_type_union_{
rsize_t member_union_member_num;
TP_C_TYPE_UNION_CONTENT* member_union_content;
size_t member_align;
uint32_t member_alignment;
uint32_t member_padding_bytes;
rsize_t member_size;
}TP_C_TYPE_UNION;

typedef struct tp_c_type_enum_content_ TP_C_TYPE_ENUM_CONTENT;
Expand Down
Loading

0 comments on commit 143e688

Please sign in to comment.