2002-06-04 18:44:03 +00:00
|
|
|
/*
|
|
|
|
qfcc.h
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
QuakeForge Code Compiler (main program)
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Copyright (C) 1996-1997 id Software, Inc.
|
|
|
|
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
|
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2002-06-04 18:44:03 +00:00
|
|
|
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
|
2001-12-08 20:40:50 +00:00
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
*/
|
|
|
|
|
2001-12-08 20:40:50 +00:00
|
|
|
#ifndef __qfcc_h
|
|
|
|
#define __qfcc_h
|
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** \defgroup qfcc QuakeC compiler
|
|
|
|
*/
|
|
|
|
|
2002-06-28 16:00:01 +00:00
|
|
|
#include <stdio.h>
|
2020-04-03 05:27:22 +00:00
|
|
|
#include "QF/darray.h"
|
2022-01-08 15:26:52 +00:00
|
|
|
#include "QF/progs/pr_comp.h"
|
2001-06-05 08:09:12 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** \defgroup qfcc_general General functions
|
|
|
|
\ingroup qfcc
|
|
|
|
*/
|
2020-02-11 06:20:49 +00:00
|
|
|
///@{
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2007-03-31 15:27:36 +00:00
|
|
|
typedef struct srcline_s srcline_t;
|
|
|
|
struct srcline_s {
|
|
|
|
srcline_t *next;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_string_t source_file;
|
2007-03-31 15:27:36 +00:00
|
|
|
int source_line;
|
|
|
|
};
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Output generated by prog parsing.
|
|
|
|
*/
|
2002-06-22 05:10:34 +00:00
|
|
|
typedef struct pr_info_s {
|
2002-06-04 18:44:03 +00:00
|
|
|
struct type_s *types;
|
2002-06-05 17:12:55 +00:00
|
|
|
|
2002-06-06 21:51:47 +00:00
|
|
|
struct function_s *func_head;
|
|
|
|
struct function_s **func_tail;
|
2002-06-05 17:12:55 +00:00
|
|
|
dfunction_t *functions;
|
|
|
|
int num_functions;
|
|
|
|
|
2011-02-20 23:41:03 +00:00
|
|
|
struct strpool_s *strings; ///< progs string data
|
|
|
|
struct codespace_s *code; ///< progs code data
|
|
|
|
struct defspace_s *near_data; ///< data directly addressable by
|
|
|
|
///< statments (address < 64k)
|
|
|
|
struct defspace_s *far_data; ///< data that might not be directly
|
|
|
|
///< addressabe by statements (address
|
|
|
|
///< possibly > 64k)
|
|
|
|
struct defspace_s *entity_data; ///< entity field address space. no
|
2011-02-22 06:41:35 +00:00
|
|
|
///< data is stored in the progs file
|
2011-02-20 23:41:03 +00:00
|
|
|
struct defspace_s *type_data; ///< encoded type information.
|
2020-04-03 05:27:22 +00:00
|
|
|
struct defspace_s *debug_data; ///< additional debug data.
|
|
|
|
struct strpool_s *comp_file_set;
|
|
|
|
struct DARRAY_TYPE (const char *) comp_files;
|
|
|
|
const char *comp_dir;
|
|
|
|
const char *unit_name;
|
2002-07-03 21:32:03 +00:00
|
|
|
|
2011-01-19 13:19:26 +00:00
|
|
|
struct symtab_s *symtab;
|
2011-03-06 06:38:19 +00:00
|
|
|
struct symtab_s *entity_fields;
|
2011-01-19 13:19:26 +00:00
|
|
|
|
2007-03-31 15:27:36 +00:00
|
|
|
srcline_t *srcline_stack;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_string_t source_file;
|
2002-07-03 21:32:03 +00:00
|
|
|
int source_line;
|
|
|
|
int error_count;
|
2002-07-11 22:38:23 +00:00
|
|
|
|
|
|
|
struct reloc_s *relocs;
|
2002-07-17 14:19:30 +00:00
|
|
|
|
|
|
|
struct pr_auxfunction_s *auxfunctions;
|
|
|
|
int auxfunctions_size;
|
|
|
|
int num_auxfunctions;
|
|
|
|
|
|
|
|
struct pr_lineno_s *linenos;
|
|
|
|
int linenos_size;
|
|
|
|
int num_linenos;
|
2001-02-24 06:58:54 +00:00
|
|
|
} pr_info_t;
|
|
|
|
|
|
|
|
extern pr_info_t pr;
|
|
|
|
|
2011-01-24 06:41:43 +00:00
|
|
|
#define GETSTR(s) (pr.strings->strings + (s))
|
2022-04-26 06:10:00 +00:00
|
|
|
#define D_PACKED(t,d) (*(t *) &(d)->space->data[(d)->offset])
|
|
|
|
#define D_var(t, d) D_PACKED (pr_##t##_t, d)
|
|
|
|
#define D_DOUBLE(d) D_var (double, d)
|
2011-01-24 06:41:43 +00:00
|
|
|
#define D_FLOAT(d) D_var (float, d)
|
2022-01-18 04:21:06 +00:00
|
|
|
#define D_INT(d) D_var (int, d)
|
2022-04-26 06:10:00 +00:00
|
|
|
#define D_VECTOR(d) (&D_var (float, d))
|
|
|
|
#define D_QUAT(d) (&D_var (float, d))
|
2011-03-04 12:28:12 +00:00
|
|
|
#define D_STRING(d) D_var (string, d)
|
|
|
|
#define D_GETSTR(d) GETSTR (D_STRING (d))
|
2011-01-24 06:41:43 +00:00
|
|
|
#define D_FUNCTION(d) D_var (func, d)
|
2022-04-26 06:10:00 +00:00
|
|
|
#define D_POINTER(t,d) (&D_PACKED (t, d))
|
2011-01-24 06:41:43 +00:00
|
|
|
#define D_STRUCT(t,d) (*D_POINTER (t, d))
|
|
|
|
|
|
|
|
#define G_POINTER(s,t,o) ((t *)((s)->data + o))
|
|
|
|
#define G_STRUCT(s,t,o) (*G_POINTER (s, t, o))
|
|
|
|
|
|
|
|
#define POINTER_OFS(s,p) ((pr_type_t *) (p) - (s)->data)
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2020-03-28 09:52:57 +00:00
|
|
|
const char *file_basename (const char *filename, int keepdot) __attribute__((pure));
|
2001-06-08 06:32:15 +00:00
|
|
|
|
2012-10-26 07:01:41 +00:00
|
|
|
extern FILE *qc_yyin;
|
|
|
|
extern FILE *qp_yyin;
|
|
|
|
int qc_yyparse (void);
|
|
|
|
int qp_yyparse (void);
|
|
|
|
extern int qc_yydebug;
|
|
|
|
extern int qp_yydebug;
|
2002-06-27 22:48:28 +00:00
|
|
|
|
2003-02-24 21:51:08 +00:00
|
|
|
#ifdef _WIN32
|
2003-02-26 05:01:18 +00:00
|
|
|
char *fix_backslash (char *path);
|
2003-02-24 21:51:08 +00:00
|
|
|
#define NORMALIZE(x) fix_backslash (x)
|
|
|
|
#else
|
|
|
|
#define NORMALIZE(x) x
|
|
|
|
#endif
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Round \a x up to the next multiple of \a a.
|
|
|
|
\note \a a must be a power of two or this will break.
|
|
|
|
\note There are no side effects on \a x.
|
|
|
|
\param x The value to be rounded up.
|
|
|
|
\param a The rounding factor.
|
|
|
|
\return The rounded value.
|
|
|
|
*/
|
2002-07-11 20:16:03 +00:00
|
|
|
#define RUP(x,a) (((x) + ((a) - 1)) & ~((a) - 1))
|
2002-07-11 17:06:15 +00:00
|
|
|
|
2020-02-11 06:20:49 +00:00
|
|
|
///@}
|
2008-08-01 00:47:38 +00:00
|
|
|
|
2001-12-08 20:40:50 +00:00
|
|
|
#endif//__qfcc_h
|