mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-28 05:01:28 +00:00
Make an array of statements for the function.
With this, sets can be used to represent statements.
This commit is contained in:
parent
98245f6d00
commit
acedc65de1
3 changed files with 23 additions and 11 deletions
|
@ -88,6 +88,8 @@ typedef struct function_s {
|
|||
*/
|
||||
struct daglabel_s **vars;
|
||||
int num_vars; ///< total number of variables referenced
|
||||
struct statement_s **statements;
|
||||
int num_statements;
|
||||
} function_t;
|
||||
|
||||
extern function_t *current_func;
|
||||
|
|
|
@ -66,7 +66,8 @@ typedef struct statement_s {
|
|||
operand_t *opa;
|
||||
operand_t *opb;
|
||||
operand_t *opc;
|
||||
struct expr_s *expr; ///< source expression for this statement
|
||||
struct expr_s *expr; ///< source expression for this statement
|
||||
int number; ///< number of this statement in function
|
||||
} statement_t;
|
||||
|
||||
typedef struct sblock_s {
|
||||
|
|
|
@ -192,25 +192,34 @@ flow_build_vars (function_t *func)
|
|||
sblock_t *sblock;
|
||||
statement_t *s;
|
||||
int num_vars;
|
||||
int num_statements = 0;
|
||||
|
||||
for (num_vars = 0, sblock = func->sblock; sblock; sblock = sblock->next) {
|
||||
for (s = sblock->statements; s; s = s->next) {
|
||||
num_vars += count_operand (s->opa);
|
||||
num_vars += count_operand (s->opb);
|
||||
num_vars += count_operand (s->opc);
|
||||
s->number = num_statements++;
|
||||
}
|
||||
}
|
||||
if (!num_vars)
|
||||
return;
|
||||
if (num_vars) {
|
||||
func->vars = malloc (num_vars * sizeof (daglabel_t *));
|
||||
|
||||
func->vars = malloc (num_vars * sizeof (daglabel_t *));
|
||||
|
||||
func->num_vars = 0; // incremented by add_operand
|
||||
for (sblock = func->sblock; sblock; sblock = sblock->next) {
|
||||
for (s = sblock->statements; s; s = s->next) {
|
||||
add_operand (func, s->opa);
|
||||
add_operand (func, s->opb);
|
||||
add_operand (func, s->opc);
|
||||
func->num_vars = 0; // incremented by add_operand
|
||||
for (sblock = func->sblock; sblock; sblock = sblock->next) {
|
||||
for (s = sblock->statements; s; s = s->next) {
|
||||
add_operand (func, s->opa);
|
||||
add_operand (func, s->opb);
|
||||
add_operand (func, s->opc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num_statements) {
|
||||
func->statements = malloc (num_statements * sizeof (statement_t *));
|
||||
func->num_statements = num_statements;
|
||||
for (sblock = func->sblock; sblock; sblock = sblock->next) {
|
||||
for (s = sblock->statements; s; s = s->next)
|
||||
func->statements[s->number] = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue