分类: LINUX
2011-05-12 18:23:31
- address_space
- -------------------------------------
- ->ident-list.h
- IDENT(address_space);
- -->
- #define IDENT(n) __IDENT(n## _ident, #n, 0)
- =====================================
- address_space
- -------------------------------------
- ->parse.c
- static struct init_keyword {
- const char *name;
- enum namespace ns;
- unsigned long modifiers;
- struct symbol_op *op;
- struct symbol *type;
- } keyword_table[] = {
- /* .... */
- { "address_space",NS_KEYWORD, .op = &address_space_op },
- /* ... */
- };
- 这是关键字,有什么操作呢?关注symbol_op结构的address_space_op:
- =====================================
- address_space_op
- -------------------------------------
- -->parse.c
- static struct symbol_op address_space_op = {
- .attribute = attribute_address_space,
- };
- =====================================
- attribute_address_space
- -------------------------------------
- --->parse.c
- static attr_t attribute_address_space ;
- struct symbol_op
- -------------------------------------
- --->symbol.h
- struct symbol_op {
- /* ..... */
- /* keywords */
- struct token *(*attribute)(struct token *token,
- struct symbol *attr, struct decl_state *ctx);
- /* ..... */
- };
- =====================================
- attr_t
- -------------------------------------
- ---->parse.c
- typedef struct token *attr_t(struct token *,
- struct symbol *, struct decl_state *);
- attribute_address_space
- -------------------------------------
- ---->parse.c
- static struct token *
- attribute_address_space(struct token *token,
- struct symbol *attr, struct decl_state *ctx)
- {
- struct expression *expr = NULL;
- int as;
- token = expect(token, '(', "after address_space attribute");
- token = conditional_expression(token, &expr);
- if (expr) {
- as = const_expression_value(expr);
- if (Waddress_space && as)
- ctx->ctype.as = as;
- }
- token = expect(token, ')', "after address_space attribute");
- return token;
- }
- =====================================