statement printing now infers the type of a def from the instruction where

possible, thus allowing anonymous defs to print their contents.
This commit is contained in:
Bill Currie 2001-08-13 23:49:04 +00:00
parent d55199bece
commit 07a09e0812
3 changed files with 30 additions and 23 deletions

View File

@ -156,7 +156,7 @@ void ED_PrintNum (progs_t *pr, int ent);
void ED_Count (progs_t *pr); void ED_Count (progs_t *pr);
void PR_Profile (progs_t *pr); void PR_Profile (progs_t *pr);
char *PR_GlobalString (progs_t *pr, int ofs); char *PR_GlobalString (progs_t *pr, int ofs, etype_t type);
char *PR_GlobalStringNoContents (progs_t *pr, int ofs); char *PR_GlobalStringNoContents (progs_t *pr, int ofs);
pr_type_t *GetEdictFieldValue(progs_t *pr, edict_t *ed, const char *field); pr_type_t *GetEdictFieldValue(progs_t *pr, edict_t *ed, const char *field);

View File

@ -461,7 +461,7 @@ PR_UglyValueString (progs_t * pr, etype_t type, pr_type_t *val)
padded to 20 field width padded to 20 field width
*/ */
char * char *
PR_GlobalString (progs_t * pr, int ofs) PR_GlobalString (progs_t * pr, int ofs, etype_t type)
{ {
char *s; char *s;
int i; int i;
@ -474,12 +474,20 @@ PR_GlobalString (progs_t * pr, int ofs)
val = (void *) &pr->pr_globals[ofs]; val = (void *) &pr->pr_globals[ofs];
if (!def) if (!def)
def = ED_GlobalAtOfs (pr, ofs); def = ED_GlobalAtOfs (pr, ofs);
if (!def) if (!def && type == ev_void)
snprintf (line, sizeof (line), "%i(?)", ofs); snprintf (line, sizeof (line), "%i(?)", ofs);
else { else {
s = PR_ValueString (pr, def->type, val); char *name = "?";
snprintf (line, sizeof (line), "%i(%s)%s", ofs, char *oi = "";
PR_GetString (pr, def->s_name), s); if (def) {
if (type == ev_void)
type = def->type;
name = PR_GetString (pr, def->s_name);
if (type != def->type)
oi = "!";
}
s = PR_ValueString (pr, type, val);
snprintf (line, sizeof (line), "%i(%s%s)%s", ofs, oi, name, s);
} }
i = strlen (line); i = strlen (line);

View File

@ -56,7 +56,6 @@ extern cvar_t *pr_deadbeef;
void void
PR_PrintStatement (progs_t * pr, dstatement_t *s) PR_PrintStatement (progs_t * pr, dstatement_t *s)
{ {
int i;
int addr = s - pr->pr_statements; int addr = s - pr->pr_statements;
opcode_t *op; opcode_t *op;
@ -68,29 +67,29 @@ PR_PrintStatement (progs_t * pr, dstatement_t *s)
} }
Con_Printf ("%-7d ", addr); Con_Printf ("%-7d ", addr);
op = PR_Opcode (s->op); op = PR_Opcode (s->op);
if (op) { if (!op) {
Con_Printf ("%s ", op->opname); Con_Printf ("unknown opcode %d\n", s->op);
i = strlen (op->opname); return;
for (; i < 10; i++)
Con_Printf (" ");
} }
Con_Printf ("%-9s ", op->opname);
if (s->op == OP_IF || s->op == OP_IFNOT) if (s->op == OP_IF || s->op == OP_IFNOT)
Con_Printf ("%sbranch %i (%i)", Con_Printf ("%sbranch %i (%i)",
PR_GlobalString (pr, s->a), s->b, PR_GlobalString (pr, s->a, ev_integer), s->b, addr + s->b);
addr + s->b);
else if (s->op == OP_GOTO) { else if (s->op == OP_GOTO) {
Con_Printf ("branch %i (%i)", s->a, addr + s->a); Con_Printf ("branch %i (%i)", s->a, addr + s->a);
} else if ((unsigned int) (s->op - OP_STORE_F) < 6) { } else if (s->op == OP_RETURN || s->op == OP_DONE) {
Con_Printf ("%s", PR_GlobalString (pr, s->a)); Con_Printf ("%s", PR_GlobalString (pr, s->a, ev_void));
Con_Printf ("%s",
PR_GlobalStringNoContents (pr, s->b));
} else { } else {
if (s->a) if (op->type_a != ev_void)
Con_Printf ("%s", PR_GlobalString (pr, s->a)); Con_Printf ("%s", PR_GlobalString (pr, s->a, op->type_a));
if (s->b) if (op->type_b != ev_void) {
Con_Printf ("%s", PR_GlobalString (pr, s->b)); if (op->type_c != ev_void)
if (s->c) Con_Printf ("%s", PR_GlobalString (pr, s->b, op->type_b));
else
Con_Printf ("%s", PR_GlobalStringNoContents (pr, s->b));
}
if (op->type_c != ev_void)
Con_Printf ("%s", PR_GlobalStringNoContents (pr, s->c)); Con_Printf ("%s", PR_GlobalStringNoContents (pr, s->c));
} }
Con_Printf ("\n"); Con_Printf ("\n");