mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Add a class type to symbols and rework the CLASS_NAME handling.
This fixes the problem with [Array alloc] producing a warning about Class not repsonding to -alloc.
This commit is contained in:
parent
3f690eacb1
commit
0b5565396b
6 changed files with 16 additions and 6 deletions
|
@ -54,6 +54,7 @@ typedef enum {
|
|||
sy_type, ///< symbol refers to a type
|
||||
sy_expr, ///< symbol refers to an expression
|
||||
sy_func, ///< symbol refers to a function
|
||||
sy_class, ///< symbol refers to a class
|
||||
} sy_type_e;
|
||||
|
||||
typedef struct symbol_s {
|
||||
|
|
|
@ -351,6 +351,7 @@ get_class (symbol_t *sym, int create)
|
|||
if (sym) {
|
||||
Hash_Add (class_hash, c);
|
||||
sym->type = c->type;
|
||||
sym->sy_type = sy_class;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ get_operand_def (expr_t *expr, operand_t *op)
|
|||
return get_value_def (&op->o.symbol->s.value, op->type);
|
||||
case sy_type:
|
||||
case sy_expr:
|
||||
case sy_class:
|
||||
internal_error (expr, "invalid operand type");
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -2264,6 +2264,8 @@ is_lvalue (expr_t *e)
|
|||
return 0;
|
||||
case sy_func:
|
||||
return 0;
|
||||
case sy_class:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (e->type == ex_temp)
|
||||
|
@ -2554,7 +2556,7 @@ message_expr (expr_t *receiver, keywordarg_t *message)
|
|||
int self = 0, super = 0, class_msg = 0;
|
||||
type_t *rec_type;
|
||||
type_t *return_type;
|
||||
class_t *class;
|
||||
class_t *class = 0;
|
||||
method_t *method;
|
||||
expr_t *send_msg;
|
||||
|
||||
|
@ -2572,8 +2574,11 @@ message_expr (expr_t *receiver, keywordarg_t *message)
|
|||
if (receiver->type == ex_symbol) {
|
||||
if (strcmp (receiver->e.symbol->name, "self") == 0)
|
||||
self = 1;
|
||||
if (get_class (receiver->e.symbol, 0))
|
||||
if (receiver->e.symbol->sy_type == sy_class) {
|
||||
class = receiver->e.symbol->type->t.class;
|
||||
class_msg = 1;
|
||||
receiver = new_symbol_expr (class_pointer_symbol (class));
|
||||
}
|
||||
}
|
||||
rec_type = get_type (receiver);
|
||||
|
||||
|
@ -2586,11 +2591,13 @@ message_expr (expr_t *receiver, keywordarg_t *message)
|
|||
return error (receiver, "not a class/object");
|
||||
|
||||
if (self) {
|
||||
class = extract_class (current_class);
|
||||
if (!class)
|
||||
class = extract_class (current_class);
|
||||
if (rec_type == class_Class.type)
|
||||
class_msg = 1;
|
||||
} else {
|
||||
class = rec_type->t.class;
|
||||
if (!class)
|
||||
class = rec_type->t.class;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ keyword_or_id (char *token)
|
|||
yylval.symbol = sym;
|
||||
if (sym->sy_type == sy_type)
|
||||
return TYPE_NAME;
|
||||
if (sym->type && is_class (sym->type))
|
||||
if (sym->sy_type == sy_class)
|
||||
return CLASS_NAME;
|
||||
return NAME;
|
||||
}
|
||||
|
|
|
@ -1569,7 +1569,7 @@ receiver
|
|||
: fexpr
|
||||
| CLASS_NAME
|
||||
{
|
||||
$$ = new_symbol_expr (class_pointer_symbol ($1->type->t.class));
|
||||
$$ = new_symbol_expr ($1);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue