Implement string comparison

This commit is contained in:
2025-02-12 00:56:21 +01:00
parent 33aca4cc07
commit cd949c4be7
11 changed files with 287 additions and 321 deletions

View File

@ -1,5 +1,5 @@
/* Language-dependent hooks for Elna.
Copyright (C) 2006-2024 Free Software Foundation, Inc.
Copyright (C) 2025 Free Software Foundation, Inc.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see
#include "parser.hh"
tree elna_global_trees[ELNA_TI_MAX];
hash_map<nofree_string_hash, tree> *elna_global_decls = nullptr;
/* The resulting tree type. */
@ -53,7 +54,9 @@ union GTY ((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
static bool elna_langhook_init(void)
{
build_common_tree_nodes(false);
elna::gcc::init_ttree();
elna_global_decls = hash_map<nofree_string_hash, tree>::create_ggc(default_hash_map_size);
build_common_builtin_nodes();
@ -172,30 +175,32 @@ static bool global_bindings_p(void)
return current_function_decl == NULL_TREE;
}
tree getdecls(void)
static tree pushdecl(tree decl)
{
if (current_function_decl != NULL_TREE)
{
return f_binding_level->names;
}
return NULL_TREE;
}
tree pushdecl(tree decl)
{
if (current_function_decl != NULL_TREE)
{
TREE_CHAIN(decl) = f_binding_level->names;
f_binding_level->names = decl;
}
return decl;
}
static tree elna_langhook_builtin_function(tree decl)
{
elna_global_decls->put(IDENTIFIER_POINTER(DECL_NAME(decl)), decl);
return decl;
}
/* Creates an expression whose value is that of EXPR, converted to type TYPE.
This function implements all reasonable scalar conversions. */
tree convert(tree type, tree expr)
{
if (error_operand_p(type) || error_operand_p(expr))
{
return error_mark_node;
}
if (TREE_TYPE(expr) == type)
{
return expr;
}
return error_mark_node;
}
#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "GNU Elna"
@ -208,6 +213,9 @@ static tree elna_langhook_builtin_function(tree decl)
#undef LANG_HOOKS_TYPE_FOR_MODE
#define LANG_HOOKS_TYPE_FOR_MODE elna_langhook_type_for_mode
#undef LANG_HOOKS_GETDECLS
#define LANG_HOOKS_GETDECLS hook_tree_void_null
#undef LANG_HOOKS_BUILTIN_FUNCTION
#define LANG_HOOKS_BUILTIN_FUNCTION elna_langhook_builtin_function