Commit Graph

173 Commits

Author SHA1 Message Date
Bill Currie 5d5d3f1416 well, that explains the loss of line number onfo on return statements :P 2001-07-16 03:53:45 +00:00
Bill Currie cb80800732 fix debug line numbers for if and while. still `losing' them for return for
some reason.
2001-07-15 01:51:01 +00:00
Bill Currie a0ba8e534c s/IMMEDIATE/.imm/ for name of immediate defs. the latter is both shorter and
impossible to generate from qc
2001-07-15 01:50:10 +00:00
Bill Currie 2818d720c2 move the full info opcocde table from qfcc to gamecode (<KURGON>There can be
only one!</KURGON>:) and use the table in PR_PrintStatement. This means that
qfcc now links against libQFgamecode as well as libQFutil
2001-07-14 02:34:16 +00:00
Bill Currie ae9ee57666 change the type of opcode->type to etype_t, clean up the resulting mess, and
rename all of the opcodes to (eg) mul.f instead of MUL_F
2001-07-14 01:52:05 +00:00
Bill Currie 6c91ee29f0 fix a missed debug test 2001-07-14 01:47:45 +00:00
Bill Currie 7acbb3a0ea helps if I remember this :/ 2001-07-14 01:16:07 +00:00
Bill Currie 64e50e1ebd Basic debug info generation, just line numbers and local defs for each
function.
2001-07-14 01:15:40 +00:00
Bill Currie 8bbef35197 fix `a = b = b + c;' (probably d + c, too). Caused by forgetting to emit
an assignment for `a ='.
2001-07-12 18:56:43 +00:00
Bill Currie 8000c86e35 /much/ better type mismatch error reporting
eg:
./main.qc:55: type mismatch: float == entity
2001-07-09 18:17:04 +00:00
Bill Currie 1db6225ae7 make - - - - -2 work 2001-07-06 04:54:08 +00:00
Bill Currie 4673d701c9 fix the conflicts caused by -ve constants 2001-07-06 04:29:12 +00:00
Jeff Teunissen 35f5118803 warning/error message cleanups. Well, at least *I* think they make more
sense. :)
2001-07-06 02:43:39 +00:00
Bill Currie b1f264b203 using qfpreqcc is now vewy vewy qwiet ('e's 'unting wabbits) 2001-07-03 21:17:02 +00:00
Bill Currie 1edf1e0b39 format checking for error and warning + needed fixes
try to give name of object when calling non-function
2001-07-03 20:53:49 +00:00
Bill Currie ccc00b0608 fix segs on ondeclared identifiers 2001-07-03 20:42:07 +00:00
Bill Currie f2bb7ace41 add an option (--warn=error) to treat warnings as errors 2001-06-28 23:15:10 +00:00
Bill Currie 9c2398d923 stop processing files after errors have occured 2001-06-28 23:08:52 +00:00
Bill Currie 6dfee9968b /much/ better error handling 2001-06-28 21:26:40 +00:00
Bill Currie eef9e8e2dc be more accurate about the operator involved 2001-06-28 17:44:50 +00:00
Bill Currie 0271afbb10 warn about the dangers of (!foo & bar) 2001-06-28 15:20:31 +00:00
Bill Currie 01a9372add fix the corrupted locals problem (df->locals was getting set too early) 2001-06-28 02:58:45 +00:00
Bill Currie daf5fc96ea reset temps after emitting a function. it helps :) (fixes the wierd entity
errors)
2001-06-27 23:36:03 +00:00
Bill Currie 59ff35558f create empty defs for vertex and quaternion compontents 2001-06-27 22:24:28 +00:00
Bill Currie 768c4a49d3 fix . type checking 2001-06-27 21:43:10 +00:00
Bill Currie 774a1fe6cd fix // comments at end of file (ie, no trailing \n) 2001-06-27 20:47:41 +00:00
Bill Currie 9c30c0c455 make simple assignments (a = b;) generate code 2001-06-27 20:32:27 +00:00
Bill Currie 1eef491c1c handle -ve constants 2001-06-27 19:40:43 +00:00
Bill Currie 1fd4590212 report file as well 2001-06-27 18:15:24 +00:00
Bill Currie febb139a41 free temp defs at the end of each expr block. CustomTF has gone from 64 to 25
locals.
2001-06-27 17:11:21 +00:00
Bill Currie 9d2bf8df19 better function argument code generation 2001-06-27 16:43:56 +00:00
Bill Currie 504d03a21a expr.c:
fix a silly stanfu with goto
qc-parse.y:
	suffle the debug code
2001-06-27 05:45:20 +00:00
Bill Currie 673e6e66b7 turns out qcc wasn't so stupid about = vs ||/&& precedence after all (just
my interpretation of the code was:/) why oh why didn't John use bison or yacc
in the first place? :/
2001-06-27 00:10:34 +00:00
Bill Currie ff42e81127 remove some debug info 2001-06-26 23:51:15 +00:00
Bill Currie c629de9b3b function calls work now 2001-06-26 23:42:11 +00:00
Bill Currie 50ae388caa initialisations now seem to work, including cows (mooOOoo:) 2001-06-26 22:43:28 +00:00
Bill Currie c32bcb7262 immediates now seem to work 2001-06-26 22:07:09 +00:00
Bill Currie ce2f26f0b9 lables are working, but immediates and function return values are borked 2001-06-26 21:32:22 +00:00
Bill Currie 5785b93107 implement branches and top level call 2001-06-26 20:06:56 +00:00
Bill Currie 19a7285f6c implement state 2001-06-26 19:54:50 +00:00
Bill Currie aee129ca7d assignments now seem to work in that they no longer seg qfcc 2001-06-26 19:48:03 +00:00
Bill Currie 63ad87db68 return defs of the correct type 2001-06-26 17:34:21 +00:00
Bill Currie 69f869087b oops 2001-06-26 16:24:11 +00:00
Bill Currie d783a024b3 record an expression's line number and file and sort of handle state
expressions
2001-06-26 16:23:21 +00:00
Bill Currie 3242c04798 fix the redef error 2001-06-26 16:12:01 +00:00
Bill Currie c1753046a9 start on actually generating code. doesn't work yet (getting a weird type
redeclaration error and not all expressions are handled yet).
2001-06-26 07:21:20 +00:00
Bill Currie e99796c4cf new expression type: ex_block. forms a linked list of expressions for fast
appending and ease of manipulation.
2001-06-26 03:33:01 +00:00
Bill Currie 749d460041 duplicate code cleanup 2001-06-26 02:46:02 +00:00
Bill Currie 3fa3ab59a9 clean up error reporting a little 2001-06-25 23:42:49 +00:00
Bill Currie 625915288c hopefully make line directives work 2001-06-25 23:38:32 +00:00
Bill Currie 90b5c57266 fix lost initial char of string constants
make expression strings char * instead of string_t (don't put them into
pr_strings prematurely);
2001-06-25 22:53:15 +00:00
Bill Currie 53b66ef2e0 better label handling and strings are now completely parsed (including escapes) 2001-06-25 22:11:20 +00:00
Bill Currie 1779a124c5 expr.h:
nuke the ex_statement and estatement_[st] stuff
	add label_expr prototype
expr.c:
	ex_statement nukage
	correct new_expr's decl
	add label_expr to ease label creation
	don't crash when printing a null expression (bare return)
qc-parse.y:
	estatement_t nukage
	statement statements and statement_block are type expr
	generate `expressions' for statements

a full parse tree for each function is now generated. there are several
special expression opcodes for statements:
	d	done    \
	r	return  -> unary: expression to return or null
	i	if      binary:   evaluated expression, destination label
	n	ifnot   binary:   evaluated expression, destination label
	c	call    binary:   function def, args (expr list, rev order)
	s	state   binary:   frame const, function def
	g	goto    unary:    destination label
	l	label   unary:    label number
in a top level expression, l (label) defines the label, otherwise it is a
reference.
2001-06-25 20:52:04 +00:00
Bill Currie 2d87eeb57d functions are now initialized, but no code is yet generated 2001-06-25 18:23:29 +00:00
Bill Currie df897255ff make usage of the new parser easier to configure 2001-06-25 18:22:53 +00:00
Bill Currie ab051248e8 expr.h:
add prototype for print_expr
expr.c:
	add print_expr
	correct string accessors
	currect the result type for unary operators
qc-lex.l:
	correct string, vector and quaternion parsing
qc-parse.y:
	precedence corrections and more function scope work

CustomTF gets through the parsing again.
2001-06-25 17:15:56 +00:00
Bill Currie c12ac3278e a little progress on functions 2001-06-21 07:08:34 +00:00
Bill Currie ae98ed8603 field types are parsed correctly, but parameters have been lost for the
moment
2001-06-20 23:32:13 +00:00
Bill Currie aac91d8cd6 more expression handling. turns out I'm mis-parsing field types, so that's next 2001-06-20 21:18:04 +00:00
Jeff Teunissen ba17807833 whitespace. 2001-06-20 19:53:37 +00:00
Bill Currie 226b40483d beginnings of expression and statement processing 2001-06-20 07:02:36 +00:00
Bill Currie 56aafce20c qfcc.h:
rearrange def_t a little and add def_next (leaving next free for other
	uses)
pr_def.c:
	use def_next instead of next to link /all/ of the named defs
qfcc.c:
	ditto
2001-06-20 03:05:50 +00:00
Bill Currie 327e95a3c8 gcc 3.0 fixes 2001-06-20 02:07:20 +00:00
Bill Currie 90a0cdfedf now seems to get through CustomTF properly, but better def handling is needed 2001-06-19 23:35:09 +00:00
Adam Olsen 67e4fa85bf add support for \<, \>, and \^ to qfcc. \< bolds all characters (toggles bold really) until \>, and \^ bolds (toggles) the next character. 2001-06-19 23:27:07 +00:00
Bill Currie 20bf698330 fix \x handling for 0-9 2001-06-19 22:26:16 +00:00
Bill Currie f50ce04ccb d'oh, forgot to add 10 for a-f and A-F 2001-06-19 22:13:35 +00:00
Bill Currie af701d74cd fix infinite loop for \x... 2001-06-19 21:45:57 +00:00
Bill Currie 2647e63810 finally fix the tupe corruption. 2001-06-19 16:01:38 +00:00
Bill Currie bdc0ba32ca pr_lex.c:
add PR_PrintType (and lotsa debug to PR_FindType)
qc-parse.y:
	fix up one bit of type corruption, only to find another :/
2001-06-19 07:28:50 +00:00
Bill Currie 89fecd7cee slowly getting there with defs processing. still borked 2001-06-18 22:51:49 +00:00
Bill Currie 7254dc0052 rename filelength to FileLength to avoid a name clash in windows 2001-06-16 04:27:22 +00:00
Bill Currie b595f0122f got function params scope sort of sorted out 2001-06-15 20:38:57 +00:00
Bill Currie eeaab95be5 beginnings of expression and def handling. 2001-06-15 19:38:43 +00:00
Bill Currie 373ea8132a more work on the code generation and make generally usable again by disabling
the new stuff
2001-06-15 07:16:18 +00:00
Bill Currie f9baacd440 beginnings of code generation. hangs :) 2001-06-14 21:49:47 +00:00
Bill Currie d7ebba6a74 parses CustomTF now, but no code generation 2001-06-13 18:35:41 +00:00
Bill Currie c89da89b69 almost parses CustomTF ($macro junk next) 2001-06-13 07:16:39 +00:00
Bill Currie 2c26de2c2b oops 2001-06-12 22:26:52 +00:00
Bill Currie 72b93d0062 more stuff 2001-06-12 22:26:10 +00:00
Bill Currie 489ddbc7a7 getting closer. soon timie to start putting real code in there 2001-06-12 21:06:28 +00:00
Bill Currie 7d52f12248 clean up C warnings 2001-06-12 20:24:02 +00:00
Bill Currie 3be018e1f9 beginnings of a bison grammar for qc 2001-06-12 19:44:26 +00:00
Bill Currie c0654f3541 miss tagged string != string 2001-06-12 15:29:05 +00:00
Bill Currie aa825853bf full \ handling in strings (including \e for escape (why C doesn't have that
is beyond me))
2001-06-11 23:37:01 +00:00
Bill Currie dfb6062f9d fix an out-by-one for line directives at the beginning of the file 2001-06-11 17:51:09 +00:00
Bill Currie c732d098f4 add '# 1 "foo.qcc" ...' (flags ignored) processing to qfcc so preprocessed
output can make sense.
2001-06-11 15:43:06 +00:00
Bill Currie bbc97079e0 pr_comp.h:
define PROG_ID_VERSION as 6 and redefine PROG_VERSION as 0x00fff001
	(0.fff.001) for the new qc features.
pr_edict.c:
	support version 6 and version 0.fff.001 progs
qfcc.h:
	add version field to options_t
	add min_version field to opcode_t
pr_opcode.c:
	set the minumum version of each opcode (gee, that table is getting ugly)
	filter out opcodes with too high a min_version when initializing the opcode
	hash tables.
qfcc.c:
	update help output.
	accept --id to limit code generation to id compatable (ver 6) progs.
	default progs generation to 0.fff.001
2001-06-09 06:25:33 +00:00
Bill Currie 0186732130 make initialized local variables work /properly/
local float urk = 0;
STORE_F    46(IMMEDIATE)  0.0   55(?)
2001-06-08 20:13:10 +00:00
Bill Currie 7ef4c2776e Immidiate sharing now /works/ (shaved off two pr_globals from CustomTF, too:).
Detect assignments to initialized globals and give an error, unless the --cow
(copy on write) option is given, and then allocate a new global for the var,
clear its initialized flag.
Relocate all globals.
2001-06-08 06:32:15 +00:00
Bill Currie 867260d27d report the size of the locals pool 2001-06-06 00:34:35 +00:00
Bill Currie c3cdfce12b don't bother writing out local defs as they mess up progs dumping now that
they overlap
2001-06-06 00:12:10 +00:00
Bill Currie d86ed9a3b9 relocate the locals defs as well as their references 2001-06-05 23:52:34 +00:00
Bill Currie bbb37d0080 customTF is now down to 4989 pr_globals. all parameters, local veriables and
termporary variables sit in one pool of memory (at the end of the globals)
thus drasticly reducing globals requirements. This works because the whole
lot is declared to be in the function's local variable space which is copied
to the locals stack in the progs engine.
2001-06-05 08:09:12 +00:00
Bill Currie a26f799de4 allocate temps based on size rather than type (get better re-usage this way)
put temps onto the local scope.
2001-06-05 05:22:11 +00:00
Bill Currie 17e19f3892 regain about 5000 globals for customTF, but this fixes possible breakage with
premature temp var re-usage (ie, it puts the temps back into the locals space).
2001-06-04 22:35:54 +00:00
Bill Currie e090f3c9e3 do proper temp def handling so we don'e use any where near as many defs for
temporary variables (customTF went from 35941 to 12587 pr_globals).
2001-06-04 17:52:50 +00:00
Bill Currie 53e9fb65d1 prepare PR_Statement for proper temporary usage 2001-06-04 05:45:51 +00:00
Bill Currie e339e82c01 hash.h is now const correct as is a lot of qfcc 2001-06-04 04:52:14 +00:00
Bill Currie 4aa47d728a use the correct STORE_ op for function arges, rather than STORE_V. Should
speed up progs in general.
2001-06-04 03:57:15 +00:00