widl: Factor out the finding of a registered type to reduce code duplication.
This commit is contained in:
parent
e8a023f9f8
commit
50e54c0c15
@ -1900,16 +1900,22 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
type_t *find_type(const char *name, int t)
|
static type_t *find_type_helper(const char *name, int t)
|
||||||
{
|
{
|
||||||
struct rtype *cur = type_hash[hash_ident(name)];
|
struct rtype *cur = type_hash[hash_ident(name)];
|
||||||
while (cur && (cur->t != t || strcmp(cur->name, name)))
|
while (cur && (cur->t != t || strcmp(cur->name, name)))
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
if (!cur) {
|
return cur ? cur->type : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
type_t *find_type(const char *name, int t)
|
||||||
|
{
|
||||||
|
type_t *type = find_type_helper(name, t);
|
||||||
|
if (!type) {
|
||||||
error_loc("type '%s' not found\n", name);
|
error_loc("type '%s' not found\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return cur->type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static type_t *find_type2(char *name, int t)
|
static type_t *find_type2(char *name, int t)
|
||||||
@ -1921,25 +1927,18 @@ static type_t *find_type2(char *name, int t)
|
|||||||
|
|
||||||
int is_type(const char *name)
|
int is_type(const char *name)
|
||||||
{
|
{
|
||||||
struct rtype *cur = type_hash[hash_ident(name)];
|
return find_type_helper(name, 0) != NULL;
|
||||||
while (cur && (cur->t || strcmp(cur->name, name)))
|
|
||||||
cur = cur->next;
|
|
||||||
if (cur) return TRUE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static type_t *get_type(unsigned char type, char *name, int t)
|
static type_t *get_type(unsigned char type, char *name, int t)
|
||||||
{
|
{
|
||||||
struct rtype *cur = NULL;
|
|
||||||
type_t *tp;
|
type_t *tp;
|
||||||
if (name) {
|
if (name) {
|
||||||
cur = type_hash[hash_ident(name)];
|
tp = find_type_helper(name, t);
|
||||||
while (cur && (cur->t != t || strcmp(cur->name, name)))
|
if (tp) {
|
||||||
cur = cur->next;
|
free(name);
|
||||||
}
|
return tp;
|
||||||
if (cur) {
|
}
|
||||||
free(name);
|
|
||||||
return cur->type;
|
|
||||||
}
|
}
|
||||||
tp = make_type(type, NULL);
|
tp = make_type(type, NULL);
|
||||||
tp->name = name;
|
tp->name = name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user