Commit Graph

301 Commits

Author SHA1 Message Date
Bill Currie a32384f16c report the name of the function using the most locals 2001-08-21 18:23:21 +00:00
Bill Currie 8d29efe552 remove a debug print 2001-08-21 17:22:55 +00:00
Bill Currie 2af74aedca fix a segfault due to type mangling for ... functions 2001-08-20 18:23:47 +00:00
Bill Currie cf4ca286f0 implement pre and post increment operators (++ and --) 2001-08-20 06:22:28 +00:00
Bill Currie cd59628199 move the chained funcion support out of emit_function_expr into funciton_expr 2001-08-20 04:56:00 +00:00
Bill Currie 9ee3450265 extend the hash api to more easily support general cases 2001-08-16 02:51:53 +00:00
Bill Currie d55199bece re-arrange the types of store and storep so things make a little more sense 2001-08-13 23:00:17 +00:00
Bill Currie c103adc17d clean up the code generated for a = b ? c : d 2001-08-12 02:38:12 +00:00
Bill Currie f343776b5a mark some jobs done, correct a typo and sort them by done, in progress, planned 2001-08-11 22:07:03 +00:00
Bill Currie 79ce6c56ca fix assignops with entity fields by cloning e1 rather than just re-using it 2001-08-11 22:02:59 +00:00
Bill Currie 248de6858d hopefully take care of freebsd 2001-08-11 21:46:02 +00:00
Bill Currie c2d3d8f3ab temp def expressions and ?:
seems to work :)
2001-08-11 21:15:24 +00:00
Bill Currie a8e858f77d fix a bug where every 2nd(?) arg was being skipped when setting up a function
call
2001-08-10 21:31:48 +00:00
Bill Currie 11381ce593 the usual 2001-08-10 21:19:36 +00:00
Adam Olsen caeb31e6ca start of the support for chained function calls. Actually, they
should work fine now, there's just some extra temp vars we want to
remove before we can consider it "done" :)
2001-08-10 20:35:42 +00:00
Bill Currie b44fd6ab91 move a var 2001-08-10 18:42:13 +00:00
Bill Currie 4388bf0519 good bye, old parser 2001-08-10 18:35:55 +00:00
Bill Currie 9e46265046 fix a silly error causing integer constants to not be re-used 2001-08-10 17:41:08 +00:00
Bill Currie a33c834a39 move SHL and SHR down in expr 2001-08-10 17:00:53 +00:00
Adam Olsen 6414897dae got a few new operators for qc :)
<< >> % which all act like their C counterparts
+= -= *= /= &= ^= |= <<= >>= %= which just expand into the obvious,
also like the C versions.
2001-08-10 16:17:00 +00:00
Bill Currie 27ccfa67c5 fix the efficiency of unary expressions as args to a function 2001-08-09 17:05:30 +00:00
Bill Currie 081d8f3c47 ^ and ~ operators for qc (^ from Rhamphoryncus) and clean up the punctuation
line in qc-lex.l (why didn't I think to do that in the first place?!?)
2001-08-09 16:34:46 +00:00
Bill Currie b341529fce more --id support 2001-08-07 16:50:22 +00:00
Adam Olsen c218ede288 Add support for checkfunction, which is a builtin that searches for
another builtin by name, and returns it.

Soon I'll change all our new builtins to by allocated dynamically, as
well as changing the number checkfunction uses, and happily break
everything that uses them :D
2001-08-04 09:11:50 +00:00
Bill Currie 1e1cb06a1f disable integers for --id. probably not thorough enough yet :/ 2001-08-03 07:47:15 +00:00
Bill Currie d89cd91e4b make the expressions in for (a;b;c) optional 2001-08-01 06:29:09 +00:00
Bill Currie f9d4351515 more jobs 2001-08-01 00:19:05 +00:00
Bill Currie bfb8eff2f0 signed_const isn't needed any more 2001-07-27 21:01:01 +00:00
Bill Currie ecc71c4a60 local var = expr; now works (globals must still be consants) 2001-07-27 20:55:14 +00:00
Bill Currie 28b1598e7e break the emit_* functions out of expr.c into emit.c 2001-07-26 05:15:34 +00:00
Bill Currie 7718ca4c96 various little cleanups 2001-07-26 05:08:27 +00:00
Bill Currie 95ad5aa329 integer type done 2001-07-26 04:34:10 +00:00
Bill Currie d44f60f17c drasticly simplify emit_assign_expr now that I have a much better
understanding of when an explicit assigment is needed. seems to work for
everything I throw at it.
Also, fix ! unary ops (caused by the - unary op fix:/)
2001-07-25 21:47:05 +00:00
Bill Currie 0c2cd8633c fix -expr handling. generates sucky code atm, but at least it's generating
code now:P
2001-07-25 18:36:36 +00:00
Bill Currie 620063628c typecheck values for [frame, think] on thost functions and fix some misplaced
immediate defs
2001-07-24 23:53:35 +00:00
Bill Currie 9ad075b02e make if/while/for use test_expr, make test_expr fix the new exp line/file,
fix some string const issues
2001-07-24 22:30:31 +00:00
Bill Currie 576123060a warn on passing integer constants into ... functions. Again, this will need
an option later
2001-07-24 20:43:18 +00:00
Bill Currie d9cde786b3 use ev_type_count instead of ev_void for bad types so things like void
functions being used in expressions don't cause ICEs
2001-07-24 19:51:44 +00:00
Bill Currie 6d1671950a expr.c:
warn for int const / int const. this will probably want an option for newer
	games
qfcc.c:
	clean up temp files when errors have occured
2001-07-24 04:45:53 +00:00
Bill Currie a47a4d8038 make print_expr's output readable by mere mortals 2001-07-23 06:15:33 +00:00
Bill Currie d2c266775c fix a seg on return type mismatch 2001-07-23 05:46:00 +00:00
Bill Currie 4b744b6be5 fix numberous integer <-> float errors
type check function args in the correct order
2001-07-23 05:31:49 +00:00
Bill Currie b8874cab1c function return checking 2001-07-23 02:27:46 +00:00
Bill Currie 50fadb6866 function arg type checking with int->float /constant/ cooecion. 2001-07-23 01:56:49 +00:00
Bill Currie c248372e20 Initial integer type support. qfcc /is/ partially broken when it comes to
integer constants and float function args/return values.

pr_comp.h:
	o  add the integer opcodes to pr_opcode_e
pr_edict.c:
	o  add "quaternion" and "integer" to type_name[]
	o  support quatnernion and integers types when printing values
	o  support the integer opcodes when bounds checking
pr_exec.c
	o  enable the integer opcodes
pr_opcode:
	o  add the integer opcodes to the opcode table
	o  logical operators all result in an integer rather than a value
expr.h:
	o  rename int_val to integer_val
qfcc.h:
	o  kill another magic number
expr.c:
	o  move the opcode to string conversion out of type_mismatch and into
	   get_op_string
	o  rename int_val to integer_val
	o  general integer type support.
	o  generate an internal comipiler error for null opcodes rather than
	   segging.
pr_imm.c:
	o  rename int_val to integer_val
	o  support integer constants, converting to float when needed.
pr_lex.c:
	o  magic number death and support quaternions and integers in type_size[]
qc-lex.l
	o  rename int_val to integer_val
	o  support quaternion and integer type keywords
qc-parse.y:
	o  rename int_val to integer_val
	o  use binary_expr instead of new_binary_expr for local initialized
	   variables
builtins.c:
	o  rename int_val to integer_val
	o  fix most (all?) of the INT related FIXMEs
defs.qc:
	o  use integer instead of float where it makes sense
main.c:
	o  read_result is now integer rather than float
main.qc:
	o  float -> integer where appropriate
	o  new test for int const to float arg
2001-07-23 01:31:22 +00:00
Bill Currie 55ac55c7ac rename ev_int and ex_int to ev_integer and ex_integer. create type_integer
and def_integer (do I need that?), clean up and or coment on XXX and FIXME
2001-07-22 06:59:12 +00:00
Bill Currie 7c16afe7e9 add a --no-cpp command line option so that cpp enabled qfcc can still compile
qfpreqcc progs
2001-07-20 05:22:44 +00:00
Bill Currie 00d409e80c fix constant folding for | 2001-07-19 03:00:35 +00:00
Bill Currie 09ae07f64e make --enable-cpp work when new-parser is left to default (which is on) 2001-07-19 03:00:08 +00:00
Bill Currie 47a6f2c9b5 pr_debug.c:
capitolise CRC and add a \n to the message
sv_progs.c (both nq and qw):
	don't bother checking the progdefs.h crc: it's just not needed any more
pr_imm.c:
	use r instead of rep when checking the hash tables.
main.c (quaq):
	make developer work and set com_filesize (otherwise, progs crc doesn't
	get set properly (com_filesize, not developer:))
2001-07-18 21:28:41 +00:00
Bill Currie 5c31fbf366 fix debug crc generation 2001-07-18 20:31:55 +00:00
Bill Currie 10ad8bebbd Make files.dat actually useful. I really dislike the hardcoding, but it /is/
useful. Also, fix a bug in PrecacheModel where it was checking MAX_SOUNDS and
numsounds instead of models.
2001-07-18 17:23:42 +00:00
Bill Currie c9af1575d3 fix emit_assign_expr to emit an explicit assignment statement whenever
emit_sub_expr returns a temporary def. this fixes a = b = c; expressions when
entities are involved.
2001-07-18 16:33:31 +00:00
Bill Currie 098305d649 fix (expr_type1 && expr_type2). this involed type completing expressions :/ 2001-07-18 06:37:14 +00:00
Jeff Teunissen ed0d1d8ba8 *** empty log message *** 2001-07-18 05:09:37 +00:00
Bill Currie f2731a7314 add cse opts 2001-07-18 02:08:32 +00:00
Jeff Teunissen 3e1bbd47df Add a TODO file for qfcc 2001-07-17 21:51:10 +00:00
Jeff Teunissen af366764de C preprocessor support for qfcc. Depends on the new parser. --enable-cpp
to activate.
2001-07-17 05:02:34 +00:00
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 eae97539c2 beginnings of debug info for progs 2001-07-13 06:08:50 +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 43ba9affaa remove the gcc 2.96 test 2001-07-09 17:12:09 +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
Jeff Teunissen 605df6ebb6 Change the bashism $() back to `` 2001-07-05 21:15:08 +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 05db0ed9d0 more format attributes 2001-07-03 20:56:01 +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 1e6fc51421 time to enable the new parser by default. 2001-06-29 00:12:11 +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 9f158b148e now cross builds out-of-the-box 2001-06-16 05:16:02 +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