mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-06 05:01:26 +00:00
102eab0d84
start working on the linker. class.[ch]: redo class defs so the pointer works (needs relocs still) obj_file.h: add prototype for read_obj_file, QFO_* data access macros and include pr_debug.h type.[ch]: separate type system initialisation and recording of the standard types so find_type works properly in multiple compilation def.c: don't mark static defs as initialized expr.c: proper class pointer def stuff immediate.c: clean out dead vars/code obj_file.c: allocate space for the line info and bail if the file can't be opened. qfcc.c: register the standard types for each compile pass and start linking the files
134 lines
3 KiB
C
134 lines
3 KiB
C
/*
|
|
obj_file.h
|
|
|
|
object file support
|
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
Date: 2002/6/16
|
|
|
|
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 __obj_file_h
|
|
#define __obj_file_h
|
|
|
|
#include "QF/pr_comp.h"
|
|
#include "QF/pr_debug.h"
|
|
|
|
#define QFO "QFO"
|
|
#define QFO_VERSION 0x00001001 // MMmmmRRR 0.001.001 (hex)
|
|
|
|
typedef struct qfo_header_s {
|
|
char qfo[4];
|
|
int version;
|
|
int code_size;
|
|
int data_size;
|
|
int far_data_size;
|
|
int strings_size;
|
|
int num_relocs;
|
|
int num_defs;
|
|
int num_functions;
|
|
int num_lines;
|
|
} qfo_header_t;
|
|
|
|
typedef struct qfo_def_s {
|
|
etype_t basic_type;
|
|
string_t full_type;
|
|
string_t name;
|
|
int ofs;
|
|
|
|
int relocs;
|
|
int num_relocs;
|
|
|
|
unsigned flags;
|
|
|
|
string_t file;
|
|
int line;
|
|
} qfo_def_t;
|
|
|
|
#define QFOD_INITIALIZED (1u<<0)
|
|
#define QFOD_CONSTANT (1u<<1)
|
|
#define QFOD_ABSOLUTE (1u<<2)
|
|
#define QFOD_GLOBAL (1u<<3)
|
|
#define QFOD_EXTERNAL (1u<<4)
|
|
|
|
typedef struct qfo_function_s {
|
|
string_t name;
|
|
string_t file;
|
|
int line;
|
|
|
|
int builtin;
|
|
int code;
|
|
|
|
int def;
|
|
|
|
int locals_size;
|
|
int local_defs;
|
|
int num_local_defs;
|
|
|
|
int line_info;
|
|
|
|
int num_parms;
|
|
byte parm_size[MAX_PARMS];
|
|
|
|
int relocs;
|
|
int num_relocs;
|
|
} qfo_function_t;
|
|
|
|
typedef struct qfo_reloc_s {
|
|
int ofs;
|
|
int type;
|
|
} qfo_reloc_t;
|
|
|
|
typedef struct qfo_s {
|
|
dstatement_t *code;
|
|
int code_size;
|
|
pr_type_t *data;
|
|
int data_size;
|
|
pr_type_t *far_data;
|
|
int far_data_size;
|
|
char *strings;
|
|
int strings_size;
|
|
qfo_reloc_t *relocs;
|
|
int num_relocs;
|
|
qfo_def_t *defs;
|
|
int num_defs;
|
|
qfo_function_t *functions;
|
|
int num_functions;
|
|
pr_lineno_t *lines;
|
|
int num_lines;
|
|
} qfo_t;
|
|
|
|
#define QFO_var(q, t, o) ((q)->data[o].t##_var)
|
|
#define QFO_FLOAT(q, o) QFO_var (q, float, o)
|
|
#define QFO_INT(q, o) QFO_var (q, integer, o)
|
|
#define QFO_VECTOR(q, o) QFO_var (q, vector, o)
|
|
#define QFO_STRING(q, o) (pr.strings + QFO_var (q, string, o))
|
|
#define QFO_FUNCTION(q, o) QFO_var (q, func, o)
|
|
#define QFO_POINTER(q, t,o) ((t *)((q)->data + o))
|
|
#define QFO_STRUCT(q, t,o) (*QFO_POINTER (q, t, o))
|
|
|
|
int write_obj_file (const char *filename);
|
|
qfo_t *read_obj_file (const char *filename);
|
|
|
|
#endif//__obj_file_h
|