projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
made the real decl_type a union
[m6w6/ext-psi]
/
src
/
parser.h
diff --git
a/src/parser.h
b/src/parser.h
index c9e9f752bb8f8747693229f4b79751f68f7aa1fa..105e974a32efd407f777c734ca39d6e4711e6d1c 100644
(file)
--- a/
src/parser.h
+++ b/
src/parser.h
@@
-66,11
+66,13
@@
typedef struct decl_type {
PSI_Token *token;
char *name;
token_t type;
PSI_Token *token;
char *name;
token_t type;
- struct decl_type *real;
- struct decl_struct *strct;
- struct decl_union *unn;
- struct decl_enum *enm;
- struct decl *func;
+ union {
+ struct decl_arg *def;
+ struct decl_struct *strct;
+ struct decl_union *unn;
+ struct decl_enum *enm;
+ struct decl *func;
+ } real;
} decl_type;
static inline decl_type *init_decl_type(token_t type, const char *name) {
} decl_type;
static inline decl_type *init_decl_type(token_t type, const char *name) {
@@
-80,11
+82,17
@@
static inline decl_type *init_decl_type(token_t type, const char *name) {
return t;
}
return t;
}
-static inline decl_type *real_decl_type(decl_type *type) {
- while (type->real) {
- type = type->real;
+static inline int weak_decl_type(decl_type *type) {
+ switch (type->type) {
+ case PSI_T_CHAR:
+ case PSI_T_SHORT:
+ case PSI_T_INT:
+ case PSI_T_LONG:
+ case PSI_T_NAME:
+ return type->type;
+ default:
+ return 0;
}
}
- return type;
}
static inline void free_decl(struct decl *decl);
}
static inline void free_decl(struct decl *decl);
@@
-93,7
+101,7
@@
static inline void free_decl_type(decl_type *type) {
free(type->token);
}
if (type->type == PSI_T_FUNCTION) {
free(type->token);
}
if (type->type == PSI_T_FUNCTION) {
- free_decl(type->func);
+ free_decl(type->
real.
func);
}
free(type->name);
free(type);
}
free(type->name);
free(type);
@@
-185,6
+193,13
@@
static inline void free_decl_arg(decl_arg *arg) {
free(arg);
}
free(arg);
}
+static inline decl_type *real_decl_type(decl_type *type) {
+ while (weak_decl_type(type)) {
+ type = type->real.def->type;
+ }
+ return type;
+}
+
typedef struct decl_typedefs {
size_t count;
decl_arg **list;
typedef struct decl_typedefs {
size_t count;
decl_arg **list;