Skip to content

Commit

Permalink
Merge pull request #402 from TimaFrolov/feature-files
Browse files Browse the repository at this point in the history
Make file size two instead of one
  • Loading branch information
TimaFrolov authored Sep 10, 2023
2 parents 35783b1 + c2d8dda commit e48c956
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions libs/compiler/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ static inline item_t functions_get(encoder *const enc, const size_t identifier)
return abs(displ);
}

static inline bool type_has_double_size(const encoder *const enc, const item_t type)
{
return (type_is_floating(enc->sx, type) || (type_is_pointer(enc->sx, type) && type_is_file(enc->sx, type_pointer_get_element_type(enc->sx, type))));
}


static void addr_begin_condition(encoder *const enc, const size_t addr)
{
Expand Down Expand Up @@ -440,7 +445,7 @@ static void emit_load_of_lvalue(encoder *const enc, lvalue value)
}
else
{
mem_add(enc, type_is_floating(enc->sx, value.type) ? IC_LOADD : IC_LOAD);
mem_add(enc, type_has_double_size(enc, value.type) ? IC_LOADD : IC_LOAD);
mem_add(enc, value.displ);
}

Expand Down Expand Up @@ -1188,7 +1193,7 @@ static void emit_assignment_expression(encoder *const enc, const node *const nd)
instruction = instruction_to_address_ver(instruction);
}

if (type_is_floating(enc->sx, type))
if (type_has_double_size(enc, type))
{
instruction = instruction_to_floating_ver(instruction);
}
Expand Down Expand Up @@ -1470,7 +1475,7 @@ static void emit_variable_declaration(encoder *const enc, const node *const nd)
}
else
{
mem_add(enc, type_is_floating(enc->sx, unqualified_type) ? IC_ASSIGN_R_V : IC_ASSIGN_V);
mem_add(enc, type_has_double_size(enc, unqualified_type) ? IC_ASSIGN_R_V : IC_ASSIGN_V);
mem_add(enc, displ);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/compiler/syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ size_t type_size(const syntax *const sx, const item_t type)
{
return (size_t)type_get(sx, (size_t)type + 1);
}
else if (type_is_floating(sx, type))
else if (type_is_floating(sx, type) || (type_is_floating(sx, type) || (type_is_pointer(sx, type) && type_is_file(sx, type_pointer_get_element_type(sx, type)))))
{
return 2;
}
Expand Down

0 comments on commit e48c956

Please sign in to comment.