Commit graph

356 commits

Author SHA1 Message Date
Bill Currie
bb4e9de0db fix a real oopsie with if (const) 2003-11-16 07:17:18 +00:00
Bill Currie
834ab26be5 remove some buggy debug code :P 2003-10-27 21:48:13 +00:00
Bill Currie
63414ea836 more gccisms in the error reporting (In function ...) 2003-10-25 04:35:47 +00:00
Bill Currie
58d0f188f1 recover from errors in bool expressions (ie, don't segfault) 2003-10-24 22:23:56 +00:00
Bill Currie
c76282c668 fix bools in function calls 2003-10-22 16:49:57 +00:00
Bill Currie
5f97de56d1 fix a few bugs 2003-10-22 09:14:53 +00:00
Bill Currie
969dad87eb fix a secfault in return_expr 2003-10-22 08:30:54 +00:00
Bill Currie
72ae59f882 short circuit logic can now be controlled (see man page) 2003-10-22 08:27:38 +00:00
Bill Currie
945006494f short circuit logic for && and || (as per C). forces standard precedence
(ie, breaks --traditional) when enabled (no choice at the moment, next fix)
2003-10-22 08:05:17 +00:00
Bill Currie
91207c0180 make void functions actually return float in traditional mode (qcc allowed
things like foo = void_function)
2003-09-23 16:57:53 +00:00
Bill Currie
387464a27c mangle precedence of = relative to && and || for --traditional (bletch).
also make noise when assigning to bad lvalues (eg !x = y)
2003-09-23 16:42:03 +00:00
Bill Currie
ba26628b80 --traditional now "fixes" (ie, breaks) operator precedence to match qcc
except for the relationship between "=" and "&&" and "||": not sure I want
to go that far towards bug compatability.
2003-09-22 22:15:31 +00:00
Bill Currie
11538d4745 access arrays in structs more efficiently (especially when using constant
indeces)
2003-09-02 17:41:16 +00:00
Bill Currie
6086aa2b99 allow casts between pointers and integers 2003-08-24 08:03:25 +00:00
Bill Currie
385a90e8fb correct pr_symtab_t to include the pointer to the array of selectors used
in the module. Unfortunatly, this requires a version bump on both qfo and
progs files due to the changes structure layout.
2003-08-23 06:15:19 +00:00
Bill Currie
b38486d405 make rel_def_op work properly 2003-08-22 19:48:14 +00:00
Bill Currie
d20b8bf0c1 pass NIL though ... safely 2003-08-22 06:04:31 +00:00
Bill Currie
204243fe95 better message type checking 2003-08-22 05:26:47 +00:00
Bill Currie
febc57e71b typecheck message params when possible 2003-08-22 04:08:33 +00:00
Bill Currie
11c7c27f70 better relocations: pointers to structure members now work 2003-08-21 02:21:30 +00:00
Bill Currie
a2300387de fix a bunch of segfaults 2003-08-20 22:36:02 +00:00
Bill Currie
93cafe878a convert NIL properly in function calls 2003-08-20 20:28:28 +00:00
Bill Currie
7d830ffc1f make @defs work properly and don't do uninitialized checks on structs 2003-08-20 19:58:41 +00:00
Bill Currie
aa712c0169 make [super foo] work in category methods 2003-08-18 06:11:41 +00:00
Bill Currie
329c91fce4 expr.c:
qcc actually had the precedence of "!x && y" correct, so don't invert
	the logic for it in traditional code.
qfcc.c:
	allow the .debug_file def to be emitted in traditional mode.
2003-08-05 17:48:16 +00:00
Bill Currie
dd9ab1e050 get unsigned mostly working 2003-08-01 21:20:04 +00:00
Bill Currie
ab94498503 heh, that was a symptom. forget &void :) 2003-07-30 21:55:32 +00:00
Bill Currie
8099f0d8f2 handle addresses of void defs 2003-07-30 20:57:50 +00:00
Bill Currie
6ecb707257 revamp the struct system so "struct foo;" does the right thing (ala C) 2003-07-30 04:11:45 +00:00
Bill Currie
5b9b11241b make method lookup work with id 2003-07-29 17:38:29 +00:00
Bill Currie
8966b0a533 get -/+ into selector name for "does not respond to" warning. 2003-07-27 19:47:14 +00:00
Bill Currie
778cd78c35 fix some namespace issues with names both being a field and an ivar 2003-07-23 18:28:31 +00:00
Bill Currie
dedb2fa6bf get [super ...] working correctly 2003-05-15 05:58:31 +00:00
Bill Currie
094c9c5cdb make derefencing a pointer without an offset more efficient 2003-05-13 19:49:23 +00:00
Bill Currie
f59f766af1 use the correct type when taking the address of a pointer derefernece 2003-05-13 19:42:14 +00:00
Bill Currie
6fb5acc868 more auto-inline avoidance 2003-05-07 02:45:17 +00:00
Bill Currie
b6b5089ccc add a "nosave" flag to defs making it easier to make defs that don't get
saved automaticly
2003-04-25 17:00:22 +00:00
Bill Currie
57254e5d33 fix a double ; 2003-04-23 06:17:36 +00:00
Bill Currie
8b24578547 print the operator for the precedence notice properly 2003-04-23 01:56:44 +00:00
Bill Currie
f7d806e8d5 can now handle > vector sized parameters 2003-04-22 20:11:16 +00:00
Bill Currie
2f6fc5d80c general revamp so params and the return value use proper defs rather than
hardcoded locations. this will allow use of quaternions in the future.
2003-04-22 15:29:32 +00:00
Bill Currie
eb099ae0d3 make qf gcc 3.3 clean 2003-04-17 00:01:48 +00:00
Bill Currie
55eb6c3ab1 plug a memory leak 2003-04-07 18:30:47 +00:00
Bill Currie
ee821705cc implement nested (and struct) block initializers 2003-04-07 17:44:18 +00:00
Bill Currie
87a31439e4 don't warn for ! precedence 2003-03-25 17:47:52 +00:00
Bill Currie
0550741fb9 catch ! == bogosity 2003-03-25 17:18:58 +00:00
Bill Currie
15781b2f19 make vector.x work in classes work and don't give an uninitialized warning
for vec.x = 0;
2003-03-12 21:58:24 +00:00
Bill Currie
627c6f70f5 allow casting between function types 2003-03-10 21:23:05 +00:00
Bill Currie
6b20862865 disable some debug 2003-03-04 21:13:10 +00:00
Bill Currie
ef762e21eb allow initialized globals (since they're constant) to be used in most places
constants are required (switch, initializing globals, enums)
2003-02-28 04:54:07 +00:00
Bill Currie
761a7546dd re-arrange things so __attribute__ and __builtin_expect are properly
autoconfiscated so rcsid will continue to work with gcc 3.3
2003-01-15 15:31:36 +00:00
Bill Currie
71196fedf6 make gcc more anal about prototypes, string constants and function
visibility (ie, global functions must have a prototype)
2003-01-06 18:28:13 +00:00
Bill Currie
2a5ac8c42d returning value for void function now a warning for traditional 2002-12-13 23:21:09 +00:00
Bill Currie
64a9a8199c allow if (void expr) (with warning) in traditional mode 2002-12-13 23:16:42 +00:00
Bill Currie
aec0c9eea1 make return type missmatch a warning for --traditional 2002-12-13 23:05:24 +00:00
Bill Currie
3c215ce13f getting closer to working categories 2002-11-14 18:17:43 +00:00
Bill Currie
7af99f422f expr.c:
fix a braino that caused only sizeof expr to work
linker.c:
	print an error message if unable to open the lib
qc-parse.y:
	revamp expression parsing so casting is done via (type)expr rather than
	type(expr)
	make it so pointers to pointers don't need ()s
2002-10-31 22:58:59 +00:00
Bill Currie
9a1223cae2 need 14, not 4 for precache_sound 2002-10-30 05:06:03 +00:00
Bill Currie
567b905590 copyright block work 2002-10-22 14:53:18 +00:00
Bill Currie
7bb6dd7197 make chained structure assignments (mostly) work. found a bug in the
handling of pointer immediates which needs fixing before this will work in
general
2002-10-20 02:35:12 +00:00
Bill Currie
6ece3bc481 don't use move for non-structs. it wasn't an optimisation anyway. this
fixes the internal error when compiling the quake1 progs
2002-10-20 01:25:15 +00:00
Bill Currie
54564a4726 structure copies now seem to work 2002-10-16 17:07:01 +00:00
Bill Currie
5eeb8bbda2 bah, bison decided to re-arange my tokens! 2002-10-16 06:31:00 +00:00
Bill Currie
6af57049d5 make pointers work a bit better 2002-10-16 02:04:06 +00:00
Bill Currie
f95510bd46 make vector.x work for structure fields (which actually makes vectors more
useful in structures:)
2002-10-09 20:35:25 +00:00
Bill Currie
7e4e1a1f96 partial support for accessing vector components as .x .y and .z rather than
_x _y and _z
2002-10-09 19:30:43 +00:00
Bill Currie
bca275944c record the type of the result of a bind expr 2002-10-08 18:20:09 +00:00
Bill Currie
eb4aa7ccec produce better code for v6 % 2002-09-13 17:38:19 +00:00
Bill Currie
308ff7163f emit.c:
implement % for v6 code. hacky, but it works :) (Closes: #29)
expr.c:
	emit the body of a block expresion before emitting its result (needed
	for v6 %)
2002-09-13 17:12:26 +00:00
Bill Currie
324b89696a create new_*_expr functions for all basic expression types except ex_poitner
and use them instead of new_expr and setting the fields each time. Serious
code cleanup :)
2002-09-11 16:21:26 +00:00
Bill Currie
2ba3585d06 fix a braino with ~float const 2002-09-05 17:40:14 +00:00
Bill Currie
1d35f4dd9e make ~ work for v6 progs by implementing ~x as -1 - x (will give bogus
results if x has fractional bits, but it's better than it was:)
2002-09-04 16:18:52 +00:00
Bill Currie
5da6fbe59c check for uninitialized variables used in function args 2002-08-29 03:06:00 +00:00
Bill Currie
371e92c448 finally fix chained function calls /properly/. need to make sure /all/ args
get their user count incremented, not just the head of the chain
2002-08-20 17:21:32 +00:00
Bill Currie
c927b2e834 quakefs.c:
allow . and .. in a path so long as the result doesn't escape from the
	game directory
cl_menu/Makefile.am:
	don't strip source paths
optoins.qc:
	use InputLine object
def.c:
	use notice to show stray temps
emit.c:
	make sure expression args get emitted for function calls
expr.c:
	'C' is a cast
	rewrite cast_expr to handle casted pointere derefs
2002-08-20 06:11:10 +00:00
Bill Currie
5d7135600e gah, that /did/ work, dunno what happend. must have done a tweak before
committing again :/ This currently produces some pseudo warnings about
dangling temps, but that's better than producing broken code
2002-08-20 02:52:04 +00:00
Bill Currie
b99a72e876 pr_obj.c:
call obj_find_message with super instead of class when doing a super
	lookup
client_menu.[ch]:
	use the InputLine object instead of directly using the api
InputLine.r:
	builint functions are = #0, not = 0 :P
function.[ch]:
	provide copy_params
method.[ch]
	provide copy_keywordargs
expr.c:
	call inc_users for the parm temp if it's a bind expression
	revers a copy of the selector when building the selector name so the
	selector doesn't get mangled
qc-parse.y:
	catch erronous func = const inintializers (should be func = #const)
2002-08-20 02:09:34 +00:00
Bill Currie
a94bdb199f @sizeof (foo) should work now 2002-08-18 04:08:02 +00:00
Bill Currie
8a431570b8 generate the selector name in the correct order for selector expressions 2002-08-16 19:50:16 +00:00
Bill Currie
3971786ee1 clean up a follow on error for calling an undefined function 2002-08-13 21:16:42 +00:00
Bill Currie
60520e7981 allow things like pointer == pointer for different pointer types that are in
the same heirarchy
2002-07-18 05:16:12 +00:00
Bill Currie
e72b25144e relocate the strings in an initialized array/struct 2002-07-17 18:49:58 +00:00
Bill Currie
8539d7987f make @self and @this work for separate compilation 2002-07-14 05:40:38 +00:00
Bill Currie
06390e10e6 more relocs fixups. my little OO hello world progs works now :) 2002-07-14 03:41:13 +00:00
Bill Currie
3cf754db30 keep the return def out of .qfo files (for now, anyway) 2002-07-12 15:54:46 +00:00
Bill Currie
8a402381e6 redo how progs strings are stored so multiple pools can exist 2002-07-05 20:02:10 +00:00
Bill Currie
46bad45c7a move s_file, pr_source_line and pr_error_count into pr, make the linker
errors more meaningful, and fix a blasted string.h issue (damn old gcc;P)
2002-07-03 21:32:03 +00:00
Bill Currie
102eab0d84 linker.[ch]:
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
2002-07-03 20:16:32 +00:00
Bill Currie
66aa36b73f start implementing storage classes (extern, static, etc) 2002-06-28 17:59:32 +00:00
Bill Currie
1a0b69e1d9 "qfcc *.qc" can now get through the prozac source withtout crashing (oodles
of compile errors, though:)
2002-06-28 16:38:05 +00:00
Bill Currie
001571e25a various memory saving tricks. seems to have not broken anything 2002-06-27 22:48:28 +00:00
Bill Currie
f8e4215ba9 implement compiler "notices": potentially important information that isn't
really a warning (unless requested) and can be silenced.
2002-06-20 19:29:06 +00:00
Bill Currie
3476138988 make --tradiontial cause "!foo & bar" evaluate as "!(foo & bar)" as per
qfcc's broken behaviour.
2002-06-20 18:51:46 +00:00
Bill Currie
e774943f24 va.[ch]:
new va function: nva which returns a strduped buffer
expr.c options.c:
	use nva instead of strdup (va (...
struct.c type.c:
	make type encoding work properly for structs
2002-06-13 16:39:33 +00:00
Bill Currie
5bbcbe0185 arrays seem to be working nicely now (menus work:) 2002-06-13 07:20:15 +00:00
Bill Currie
88fc0be127 arrays are /almost/ working again 2002-06-12 22:37:18 +00:00
Bill Currie
1f67ea412d add a global flag to def_t to make checking easier
rename pr.globals to pr.near_data and add pr.far_data
2002-06-10 20:54:22 +00:00
Bill Currie
7a13e6b362 find the rest (I hope!) of the mis-tested scopes 2002-06-10 19:26:54 +00:00
Bill Currie
58782333a9 give scopes types (static, params, locals for now) 2002-06-09 05:19:13 +00:00
Bill Currie
1e57351be1 there, no more PR_* functions or pr_* files :) 2002-06-09 04:30:02 +00:00
Bill Currie
943c2eefb3 redo def allocation to come from configurable `spaces' (locals, globals, far
globals, etc).
2002-06-09 03:57:20 +00:00
Bill Currie
00a54ad918 redo relocations 2002-06-07 17:29:30 +00:00
Bill Currie
f31705380f call malloc a little less often 2002-06-05 21:13:29 +00:00
Bill Currie
38d3a15413 d'oh, forgot to compile test :P 2002-06-05 19:31:43 +00:00
Bill Currie
cb395c5469 misc def improvments 2002-06-05 19:03:51 +00:00
Bill Currie
e17604f9c2 remove all arbitrary limits except for globals. they'll need a little more
work. Once they're done, it should take quite a big mod to crash qfcc due
to too many strings/statements/etc :)
2002-06-05 17:12:55 +00:00
Bill Currie
69605d0b19 even more cleanup 2002-06-04 21:23:39 +00:00
Bill Currie
06bddd3ee6 more cleanup 2002-06-04 18:44:03 +00:00
Bill Currie
7b993f97d2 more cleanups 2002-06-01 05:30:16 +00:00
Bill Currie
c4d0c574ee clean up qfcc.h a bit 2002-06-01 05:06:19 +00:00
Bill Currie
8f2d1fa2d9 more cmdlib cleanup 2002-06-01 04:41:25 +00:00
Bill Currie
b3adadc347 @this will provide an id field named ".this" (ie, .id .this (if .this would
parse in the first place:))
also kill build_type now that a field_type function is available in type.c
2002-05-31 16:58:42 +00:00
Bill Currie
3967f5cf95 type.h:
*type_method to type_Method
emit.c:
	support casting between pointers
expr.c:
	support casting between pointers
method.c:
	correct the type for _cmd
	type_method to type_Method.aux_type
qc-lex.l:
	Method type is a poniter to a method
qc-parse.y:
	support , args to messages (not fully implemented yet)
type.c:
	*type_method to type_Method and make type_Method a pointer to a method
2002-05-22 05:03:36 +00:00
Bill Currie
4315707008 class.c:
avoid possible segfault
expr.c:
	correct the return value type checking to handle super classes
2002-05-21 23:29:21 +00:00
Bill Currie
9f06f89d57 write out the module data needed for the obj runtime 2002-05-21 21:28:40 +00:00
Bill Currie
e11e2f3718 SELF -> @self (looks better (IMO:)) and make sure the .self def gets
generatoed and used when @self is seen
2002-05-18 00:30:14 +00:00
Bill Currie
451bfbddfe fix a snafu with current_class and get ivar access working properly (cross
fingers:)
2002-05-17 19:35:26 +00:00
Bill Currie
ef9f9cda2f pr_obj.h:
define the class info stuff
expr.h pr_def.c:
	fix a FIXME
class.c expr.c type.c:
	make id ev_pointer.ev_object rather than ev_pointer.ev_class
2002-05-17 17:37:44 +00:00
Bill Currie
6965642030 get ivars working better (need to get rid of self.) and [super ...] now
works.
2002-05-17 06:20:27 +00:00
Bill Currie
779174cb33 get object pointer assignmets working and some static typing as well 2002-05-16 20:20:23 +00:00
Bill Currie
73f4cb4c03 it seems object info emition works (needs more testing) 2002-05-15 23:24:19 +00:00
Bill Currie
6a5bbf6f0a memory allocation checking cleanup 2002-05-14 06:37:28 +00:00
Bill Currie
44dcf74627 strip the \n from all(?) of the Sys_Error calls (Sys_Error itself will be
adding \n).
2002-05-14 06:12:29 +00:00
Bill Currie
73e6cf062c implement type encoding 2002-05-10 23:19:57 +00:00
Bill Currie
2cd716176a more progress 2002-05-10 00:00:23 +00:00
Bill Currie
f2b8dc7e7e more progress 2002-05-09 20:12:28 +00:00
Bill Currie
961d84e569 clean up of qfcc.h and shuffle around the predefined types 2002-05-09 06:34:48 +00:00
Bill Currie
1b875c8b06 work on getting obj expressions going 2002-05-08 23:12:49 +00:00
Bill Currie
de86019d4b reverse the param order before building the function type and type check
varargs functions with specified params.
2002-05-08 17:33:28 +00:00
Bill Currie
b226d24b52 rework the param parsing to make selectors easier to handle 2002-05-08 05:15:19 +00:00
Bill Currie
54fb180fad expr.h:
__attribute__((const)) has rather nasty results when it's not true
expr.c:
	fix up some mis-timed ex_error checks
2002-05-02 05:03:57 +00:00
Bill Currie
05788e55e5 don't generate useless expression warnings when that expression was caused
by an error
2002-05-01 22:08:59 +00:00
Bill Currie
962dc8e46e rewrite the type and def parsing to allow more flexible types 2002-05-01 21:35:39 +00:00
Bill Currie
860e3ebb1d make unsigned arrays/pointers more useful by allowing them to be used as
unbounded arrays
2002-02-24 01:11:34 +00:00
Bill Currie
80723fdec7 o don't ice when ex_name or ex_nil expressions show up in emit_expr.
instead, treat as useless epxression.
 o  mark rvalue expressions as such
 o  increment the users of a managed temp def when in an rvalue expr
2002-02-21 20:34:04 +00:00
Bill Currie
d1fcfd1939 Implement --traditional so qfcc can be a nicer qcc. This disables several
keywords (quaternion integer function for break continue switch case default
NIL struct enum typedef) and converts some errors to warnings (assignment to
constants, insufficient function arguments, return; from non-void function,
anal function `pointer' type checks)
2002-02-18 06:23:59 +00:00
Bill Currie
3d9c8a9a60 get nil conversions working fully and things like !pointer 2002-01-30 22:17:55 +00:00
Bill Currie
64c5983742 enum support 2002-01-21 19:03:29 +00:00
Bill Currie
cef918df83 get array initialisation worrking 2002-01-18 08:26:37 +00:00
Bill Currie
d69762facd integer() and float() casts seem to work 2002-01-17 19:32:04 +00:00
Bill Currie
7227ab4363 qfcc.c:
add -P,--progs-src so you can specify the name of the progs.src file
rest:
	add/use print_type
2002-01-17 08:19:53 +00:00
Bill Currie
f591b27532 set the result of the block used for self.maxs = obj.origin; type expressions 2002-01-04 18:43:55 +00:00
Bill Currie
f392c395df fix some uninitialized warnings my gcc missed, but misty's got 2001-12-13 16:40:46 +00:00
Bill Currie
112f74a357 make integer constant division warnings optional 2001-12-12 22:00:42 +00:00
Bill Currie
195dd1032e clean up some dead code 2001-12-12 21:52:07 +00:00
Bill Currie
8ddce20949 pr_*: add storep.p so pointers can be stored into entities
emit.c: convert & (address) to . in unary .
        rewrite emit_assign_expr
expr.c: remove debug code and make unary . less agressive on address calcs
        also convert & (address) to . for lvals
2001-12-12 20:35:58 +00:00
Bill Currie
b56d7f3248 emit.c:
fix a missing else (should convert to switch)
expr.c:
	fix address_expr for binary expressions
	fix unary .
2001-12-12 18:34:41 +00:00
Bill Currie
f9149a0d6c finally get around to renaming type_name to pr_type_name 2001-12-12 17:15:09 +00:00
Bill Currie
cc34e5954f lots of work on better array/pointer/struct handline. doesn't quite work yet 2001-12-12 08:39:47 +00:00
Bill Currie
00b2a45ecd change the operator for "address" from "." to "&" so load.p can be implement.
this makes it so pointers in entities work.
2001-12-08 20:17:20 +00:00