mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 01:11:18 +00:00
@this will provide an id field named ".this" (ie, .id .this (if .this would
parse in the first place:)) also kill build_type now that a field_type function is available in type.c
This commit is contained in:
parent
cf9e1de5a6
commit
b3adadc347
6 changed files with 29 additions and 20 deletions
|
@ -135,6 +135,7 @@ expr_t *new_bind_expr (expr_t *e1, expr_t *e2);
|
|||
expr_t *new_name_expr (const char *name);
|
||||
expr_t *new_def_expr (def_t *def);
|
||||
expr_t *new_self_expr (void);
|
||||
expr_t *new_this_expr (void);
|
||||
|
||||
void inc_users (expr_t *e);
|
||||
void convert_name (expr_t *e);
|
||||
|
|
|
@ -65,6 +65,7 @@ struct dstring_s;
|
|||
type_t *find_type (type_t *new);
|
||||
void new_typedef (const char *name, type_t *type);
|
||||
type_t *get_typedef (const char *name);
|
||||
type_t *field_type (type_t *aux);
|
||||
type_t *pointer_type (type_t *aux);
|
||||
type_t *array_type (type_t *aux, int size);
|
||||
void print_type (type_t *type);
|
||||
|
|
|
@ -481,6 +481,16 @@ new_self_expr (void)
|
|||
return new_def_expr (def);
|
||||
}
|
||||
|
||||
expr_t *
|
||||
new_this_expr (void)
|
||||
{
|
||||
type_t *type = field_type (&type_id);
|
||||
def_t *def = PR_GetDef (type, ".this", 0, &numpr_globals);
|
||||
|
||||
PR_DefInitialized (def);
|
||||
return new_def_expr (def);
|
||||
}
|
||||
|
||||
expr_t *
|
||||
append_expr (expr_t *block, expr_t *e)
|
||||
{
|
||||
|
|
|
@ -279,6 +279,7 @@ static keyword_t keywords[] = {
|
|||
{"@public", PUBLIC, 0, 0, PROG_VERSION},
|
||||
{"@selector", SELECTOR, 0, 0, PROG_VERSION},
|
||||
{"@self", SELF, 0, 0, PROG_VERSION},
|
||||
{"@this", THIS, 0, 0, PROG_VERSION},
|
||||
{"@argc", ARGC, 0, 0, PROG_VERSION},
|
||||
{"@argv", ARGV, 0, 0, PROG_VERSION},
|
||||
};
|
||||
|
|
|
@ -64,8 +64,6 @@ parse_error (void)
|
|||
|
||||
int yylex (void);
|
||||
|
||||
type_t *build_type (int is_field, type_t *type);
|
||||
|
||||
hashtab_t *save_local_inits (def_t *scope);
|
||||
hashtab_t *merge_local_inits (hashtab_t *dl_1, hashtab_t *dl_2);
|
||||
void restore_local_inits (hashtab_t *def_list);
|
||||
|
@ -112,7 +110,7 @@ void free_local_inits (hashtab_t *def_list);
|
|||
|
||||
%token LOCAL RETURN WHILE DO IF ELSE FOR BREAK CONTINUE ELLIPSIS NIL
|
||||
%token IFBE IFB IFAE IFA
|
||||
%token SWITCH CASE DEFAULT STRUCT ENUM TYPEDEF SUPER SELF
|
||||
%token SWITCH CASE DEFAULT STRUCT ENUM TYPEDEF SUPER SELF THIS
|
||||
%token ARGC ARGV
|
||||
%token ELE_START
|
||||
%token <type> TYPE
|
||||
|
@ -244,16 +242,16 @@ enum
|
|||
;
|
||||
|
||||
type
|
||||
: '.' type { $$ = build_type (1, $2); }
|
||||
: '.' type { $$ = field_type ($2); }
|
||||
| non_field_type { $$ = $1; }
|
||||
| non_field_type function_decl
|
||||
{
|
||||
current_params = $2;
|
||||
$$ = build_type (0, parse_params ($1, $2));
|
||||
$$ = parse_params ($1, $2);
|
||||
}
|
||||
| non_field_type array_decl
|
||||
{
|
||||
$$ = build_type (0, array_type ($1, $2));
|
||||
$$ = array_type ($1, $2);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -783,6 +781,7 @@ expr
|
|||
| ARGC { $$ = new_name_expr (".argc"); }
|
||||
| ARGV { $$ = new_name_expr (".argv"); }
|
||||
| SELF { $$ = new_self_expr (); }
|
||||
| THIS { $$ = new_this_expr (); }
|
||||
| const { $$ = $1; }
|
||||
| '(' expr ')' { $$ = $2; $$->paren = 1; }
|
||||
;
|
||||
|
@ -1292,20 +1291,6 @@ obj_string
|
|||
|
||||
%%
|
||||
|
||||
type_t *
|
||||
build_type (int is_field, type_t *type)
|
||||
{
|
||||
if (is_field) {
|
||||
type_t new;
|
||||
memset (&new, 0, sizeof (new));
|
||||
new.type = ev_field;
|
||||
new.aux_type = type;
|
||||
return find_type (&new);
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
def_t *def;
|
||||
int state;
|
||||
|
|
|
@ -175,6 +175,17 @@ get_typedef (const char *name)
|
|||
return td->type;
|
||||
}
|
||||
|
||||
type_t *
|
||||
field_type (type_t *aux)
|
||||
{
|
||||
type_t new;
|
||||
|
||||
memset (&new, 0, sizeof (new));
|
||||
new.type = ev_field;
|
||||
new.aux_type = aux;
|
||||
return find_type (&new);
|
||||
}
|
||||
|
||||
type_t *
|
||||
pointer_type (type_t *aux)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue