/* ============ PR_PrintDefs ============ */ void PR_PrintDefs (void) { def_t *d; for (d=pr.def_head.next ; d ; d=d->next) PR_PrintOfs (d->ofs); }
/* ============ PR_GetDef A new def will be allocated if it can't be found ============ */ def_t *PR_GetDef (type_t *type, char *name, def_t *scope, def_t *visscope, bool isParm) { def_t *def; char element[MAX_NAME]; int hash; hash = Com_HashKey (name); // see if the name is already in use def = PR_FindDef2 (name, scope, hash); if (def) { if (def->scope != scope) { if (!opt_idcomp) goto allocNew; // a local def overrides global (ok) else PR_Warning (WARN_HIGH, "'%s' already declared on global scope", name); } if (def->type != type) PR_ParseError ("type mismatch on redeclaration of %s", name); if (def->isParm && !isParm) if (!opt_idcomp) PR_ParseError ("redefinition of formal parameter '%s'", name); else PR_Warning (WARN_HIGH, "redefinition of formal parameter '%s'", name); // fixup visibility scope if (def->visscope) def->visscope = visscope; return def; } // allocate a new def allocNew: def = PR_NewDef (hash); def->name = (char *) malloc (strlen(name)+1); strcpy (def->name, name); def->type = type; def->isParm = isParm; def->scope = scope; def->visscope = visscope; if (numpr_globals + type_size[type->type] > MAX_REGS) Error ("numpr_globals > MAX_REGS"); def->ofs = numpr_globals; pr_global_defs[numpr_globals] = def; // // make automatic defs for the vectors elements // .origin can be accessed as .origin_x, .origin_y, and .origin_z // if (type->type == ev_vector) { sprintf (element, "%s_x",name); PR_GetDef (&type_float, element, scope, visscope, isParm); sprintf (element, "%s_y",name); PR_GetDef (&type_float, element, scope, visscope, isParm); sprintf (element, "%s_z",name); PR_GetDef (&type_float, element, scope, visscope, isParm); } else numpr_globals += type_size[type->type]; if (type->type == ev_field) { assert (scope == NULL && visscope == NULL); *(int *)&pr_globals[def->ofs] = pr.size_fields; if (type->aux_type->type == ev_vector) { sprintf (element, "%s_x",name); PR_GetDef (&type_floatfield, element, NULL, NULL, isParm); sprintf (element, "%s_y",name); PR_GetDef (&type_floatfield, element, NULL, NULL, isParm); sprintf (element, "%s_z",name); PR_GetDef (&type_floatfield, element, NULL, NULL, isParm); } else pr.size_fields += type_size[type->aux_type->type]; } if (opt_dumpasm) PR_PrintOfs (def->ofs); return def; }