2002-06-04 18:44:03 +00:00
|
|
|
/*
|
|
|
|
def.h
|
|
|
|
|
|
|
|
#DESCRIPTION#
|
|
|
|
|
|
|
|
Copyright (C) 2001 #AUTHOR#
|
|
|
|
|
|
|
|
Author: #AUTHOR#
|
|
|
|
Date: #DATE#
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __def_h
|
|
|
|
#define __def_h
|
|
|
|
|
|
|
|
#include "QF/pr_comp.h"
|
|
|
|
#include "QF/pr_debug.h"
|
|
|
|
|
|
|
|
typedef struct def_s {
|
|
|
|
struct type_s *type;
|
|
|
|
const char *name;
|
|
|
|
int ofs;
|
2002-06-07 21:17:51 +00:00
|
|
|
|
2002-06-07 17:29:30 +00:00
|
|
|
struct reloc_s *refs; // for relocations
|
2002-06-04 18:44:03 +00:00
|
|
|
|
2002-06-09 03:57:20 +00:00
|
|
|
unsigned initialized:1; // for uninit var detection
|
|
|
|
unsigned constant:1; // 1 when a declaration included "= immediate"
|
2002-06-04 18:44:03 +00:00
|
|
|
unsigned freed:1; // already freed from the scope
|
|
|
|
unsigned removed:1; // already removed from the symbol table
|
|
|
|
unsigned used:1; // unused local detection
|
|
|
|
unsigned absolute:1; // don't relocate (for temps for shorts)
|
|
|
|
unsigned managed:1; // managed temp
|
2002-06-28 17:59:32 +00:00
|
|
|
unsigned global:1; // globally declared def
|
|
|
|
unsigned external:1; // externally declared def
|
2002-07-12 06:17:24 +00:00
|
|
|
unsigned local:1; // function local def
|
2002-06-09 03:57:20 +00:00
|
|
|
|
2002-06-04 18:44:03 +00:00
|
|
|
string_t file; // source file
|
|
|
|
int line; // source line
|
|
|
|
|
|
|
|
int users; // ref counted temps
|
|
|
|
struct expr_s *expr; // temp expr using this def
|
|
|
|
|
2002-06-09 03:57:20 +00:00
|
|
|
struct def_s *def_next; // next def in scope
|
2002-06-04 18:44:03 +00:00
|
|
|
struct def_s *next; // general purpose linking
|
2002-06-09 03:57:20 +00:00
|
|
|
struct scope_s *scope; // scope the var was defined in
|
2002-06-10 23:14:32 +00:00
|
|
|
struct defspace_s *space;
|
2002-06-04 18:44:03 +00:00
|
|
|
struct def_s *parent; // vector/quaternion member
|
2002-06-09 03:57:20 +00:00
|
|
|
|
2002-06-21 20:46:56 +00:00
|
|
|
int obj_def; // index to def in qfo defs
|
|
|
|
|
2002-06-09 03:57:20 +00:00
|
|
|
void *return_addr; // who allocated this
|
2002-06-04 18:44:03 +00:00
|
|
|
} def_t;
|
|
|
|
|
2002-06-09 03:57:20 +00:00
|
|
|
typedef struct defspace_s {
|
|
|
|
struct defspace_s *next;
|
2002-06-10 23:14:32 +00:00
|
|
|
struct locref_s *free_locs;
|
2002-06-09 03:57:20 +00:00
|
|
|
pr_type_t *data;
|
|
|
|
int size;
|
|
|
|
int max_size;
|
|
|
|
int (*grow) (struct defspace_s *space);
|
|
|
|
} defspace_t;
|
|
|
|
|
2002-06-09 05:19:13 +00:00
|
|
|
typedef enum {
|
2002-06-10 20:54:22 +00:00
|
|
|
sc_global,
|
2002-06-09 05:19:13 +00:00
|
|
|
sc_params,
|
|
|
|
sc_local,
|
|
|
|
} scope_type;
|
|
|
|
|
2002-06-09 03:57:20 +00:00
|
|
|
typedef struct scope_s {
|
|
|
|
struct scope_s *next;
|
2002-06-09 05:19:13 +00:00
|
|
|
scope_type type;
|
2002-06-09 03:57:20 +00:00
|
|
|
defspace_t *space;
|
|
|
|
def_t *head;
|
|
|
|
def_t **tail;
|
|
|
|
int num_defs;
|
|
|
|
struct scope_s *parent;
|
|
|
|
} scope_t;
|
|
|
|
|
2002-06-28 17:59:32 +00:00
|
|
|
typedef enum {
|
|
|
|
st_none,
|
|
|
|
st_global,
|
|
|
|
st_extern,
|
|
|
|
st_static,
|
|
|
|
st_local
|
|
|
|
} storage_class_t;
|
|
|
|
|
2002-06-04 18:44:03 +00:00
|
|
|
extern def_t def_ret, def_parms[MAX_PARMS];
|
|
|
|
extern def_t def_void;
|
|
|
|
extern def_t def_function;
|
|
|
|
|
2002-06-09 05:19:13 +00:00
|
|
|
scope_t *new_scope (scope_type type, defspace_t *space, scope_t *parent);
|
2002-06-09 03:57:20 +00:00
|
|
|
defspace_t *new_defspace (void);
|
2002-07-11 15:42:20 +00:00
|
|
|
void defspace_adddata (defspace_t *space, pr_type_t *data, int size);
|
2002-06-09 03:57:20 +00:00
|
|
|
|
2002-06-09 04:30:02 +00:00
|
|
|
def_t *get_def (struct type_s *type, const char *name, scope_t *scope,
|
2002-06-28 17:59:32 +00:00
|
|
|
storage_class_t storage);
|
2002-06-09 04:30:02 +00:00
|
|
|
def_t *new_def (struct type_s *type, const char *name, scope_t *scope);
|
|
|
|
int new_location (struct type_s *type, defspace_t *space);
|
|
|
|
void free_location (def_t *def);
|
|
|
|
def_t *get_tempdef (struct type_s *type, scope_t *scope);
|
|
|
|
void free_tempdefs ();
|
|
|
|
void reset_tempdefs ();
|
|
|
|
void flush_scope (scope_t *scope, int force_used);
|
|
|
|
void def_initialized (def_t *d);
|
2002-06-04 21:54:47 +00:00
|
|
|
|
2002-06-28 16:00:01 +00:00
|
|
|
void clear_defs (void);
|
2002-06-04 21:54:47 +00:00
|
|
|
|
2002-06-04 18:44:03 +00:00
|
|
|
#endif//__def_h
|