Read the input filename from the command line

This commit is contained in:
2025-02-02 08:22:40 +01:00
parent b41d6fb907
commit 607bf09434
9 changed files with 213 additions and 182 deletions

View File

@ -1,6 +1,9 @@
#include "elna/gcc/elna-tree.h"
#include "elna/gcc/elna-diagnostic.h"
#include "stor-layout.h"
#include "fold-const.h"
#include "diagnostic-core.h"
tree elna_global_trees[ELNA_TI_MAX];
@ -20,12 +23,6 @@ namespace gcc
return TREE_CODE(type) == POINTER_TYPE;
}
bool is_string_type(tree type)
{
return is_pointer_type(type)
&& TYPE_MAIN_VARIANT(TREE_TYPE(type)) == char_type_node;
}
tree tree_chain_base::head()
{
return first;
@ -81,5 +78,43 @@ namespace gcc
return initial_table;
}
tree do_pointer_arithmetic(boot::binary_operator binary_operator, tree left, tree right)
{
tree result = error_mark_node;
tree convert_expression = fold_convert(sizetype, right);
if (binary_operator == boot::binary_operator::sum)
{
result = fold_build2(POINTER_PLUS_EXPR, TREE_TYPE(left), left, convert_expression);
}
else if (binary_operator == boot::binary_operator::subtraction)
{
convert_expression = fold_build1(NEGATE_EXPR, sizetype, convert_expression);
result = fold_build2(POINTER_PLUS_EXPR, TREE_TYPE(left), left, convert_expression);
}
return result;
}
tree build_binary_operation(bool condition, boot::binary_expression *expression,
tree_code operator_code, tree left, tree right, tree target_type)
{
location_t expression_location = get_location(&expression->position());
tree left_type = TREE_TYPE(left);
tree right_type = TREE_TYPE(right);
if (condition)
{
return build2_loc(expression_location, operator_code, target_type, left, right);
}
else
{
error_at(expression_location,
"invalid operands of type %s and %s for operator %s",
print_type(left_type), print_type(right_type),
elna::boot::print_binary_operator(expression->operation()));
return error_mark_node;
}
}
}
}