Commit Graph

223 Commits

Author SHA1 Message Date
Bill Currie 09405469f6 throw PR_BeginCompilation's arguments out the nearest airlock 2001-10-24 22:53:27 +00:00
Bill Currie 6553c81a41 proper scoping for QC ala C. 2001-10-24 06:39:49 +00:00
Bill Currie 5ca785e7e8 uninitialized variable detection. not perfect (lots of false negatives, but
fewer than before;) but prozac isn't giving any false positives.
2001-10-18 20:05:26 +00:00
Bill Currie 96e4e1a232 the beginning of unititialized var detection. first victim: functions.
--undefined-function-warning is now --no-undefined-function-warning and
the default is to detect called but undefined functions.
2001-10-18 17:41:22 +00:00
Bill Currie 952f029e6d rename def_t.initialized to def_t.constant 2001-10-18 17:15:05 +00:00
Bill Currie 79ac85b54f type checking now works much better and there is now a NIL builtin constant
which can be assigned (/only/) to anything.
2001-10-17 07:45:37 +00:00
Ragnvald Maartmann-Moe IV 2080ae7db6 Fix stamp ignorance. 2001-10-05 19:42:17 +00:00
Bill Currie dcb51dc586 expr.h:
get_type and extract_type prototypes and add extern for type_names
emit.c:
	use extract_type instead of get_type
expr.c:
	get_type now returns the type pointer rather than the qc type enum.
	extract_type uses get_type to return the qc type enum.
	make type_names global
	use get_type instead of ex_expr/ex_def to cover more cases
	clean up function call/return processing as a result of get_type
pr_opcode.c:
	use opcode_priority_type_table_ab when var_c is null and a minor
	cleanup in PR_Opcode_Find
2001-10-02 18:55:52 +00:00
Bill Currie 7aec6e253a unused local variable detection 2001-09-22 23:41:47 +00:00
Bill Currie ea451ab02d Remove unnecessary temps from function return values. This has one
*/CRITICAL/* implication: DO NOT /EVER/ RELY ON EVALUATION ORDER. This
isn't /really/ that bad: evaluation order will be consistent for similar
expressions, but for (eg) foo() + bar()*2, bar will be called first.
2001-08-24 21:47:52 +00:00
Bill Currie 4c48851096 fix a buffer overflow in new_label_expr
use reference counting for temp defs and call PR_FreeTempDefs at the end
of emit_sub_expr as well as emit_expr.
fix a (relatively harmless) bug in type processesing of foo.bar =
2001-08-22 21:55:01 +00:00
Bill Currie cf4ca286f0 implement pre and post increment operators (++ and --) 2001-08-20 06:22:28 +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
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
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 28b1598e7e break the emit_* functions out of expr.c into emit.c 2001-07-26 05:15:34 +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 b8874cab1c function return checking 2001-07-23 02:27:46 +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 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 098305d649 fix (expr_type1 && expr_type2). this involed type completing expressions :/ 2001-07-18 06:37:14 +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 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 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 f2bb7ace41 add an option (--warn=error) to treat warnings as errors 2001-06-28 23:15:10 +00:00
Bill Currie 6dfee9968b /much/ better error handling 2001-06-28 21:26:40 +00:00
Bill Currie 0271afbb10 warn about the dangers of (!foo & bar) 2001-06-28 15:20:31 +00:00
Bill Currie 50ae388caa initialisations now seem to work, including cows (mooOOoo:) 2001-06-26 22:43:28 +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 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 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 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 aac91d8cd6 more expression handling. turns out I'm mis-parsing field types, so that's next 2001-06-20 21:18:04 +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 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 eeaab95be5 beginnings of expression and def handling. 2001-06-15 19:38:43 +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 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 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 55d58f8d46 ignore .vimrc 2001-06-04 18:33:50 +00:00
Bill Currie 42c880ab8a formatting cleanup 2001-06-04 18:33:32 +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 e339e82c01 hash.h is now const correct as is a lot of qfcc 2001-06-04 04:52:14 +00:00
Bill Currie ddcd172a03 re-write the opcode selection to be a hash table lookup and statment generation
to get the opcode from the table record rather than the location within the
table (ewww). gives a nice speed boost /and/ makes the opcode table easier to
maintain.
2001-06-04 02:41:45 +00:00
Bill Currie 09118bc01e pr_comp.h:
add OP_ADD_S. WARNING!!! this /will/ move.
progs.h:
	add prototype for PR_PrintStatement
pr_edict.c:
	add OP_ADD_S support in the progs checker
pr_exec.c:
	implement OP_ADD_S
tools/qfcc/include/.gitignore:
	add config.h.in
qfcc.h:
	nuke PR_NameImmediate and change PR_ParseImmediate's prototype (see
	pr_imm.c)
pr_comp.c:
	add ADD_S, adjust for PR_ParseImmediate's prototype, make
	PR_ParseExpression work with non-sequential opcodes (slow, will work on
	that next). Fix up initialised global parsing.
pr_imm.c:
	nuke PR_NameImmediate. didn't work well and wasn't such a good idea anyway.
	PR_ParseImmediate now accepts a def_t * arg. if null, will allocate a
	new global def, otherwise it will initialize the def passed in.
qwaq/main.c:
	sports some debugging code (dumps info about the progs it's running)
qwaq/main.qc:
	better ADD_S testing
2001-06-03 17:36:49 +00:00
Bill Currie 297f7c0567 this shouldn't be here 2001-06-02 05:23:00 +00:00
Bill Currie f896506835 heh, seem to have forgotten this 2001-04-02 21:30:16 +00:00
Bill Currie 02b09f4e5c no more redundant strings. costs ~7ms, though, but HALVING the strofs size
in frikbot seems worth it.
2001-04-01 06:40:51 +00:00
Bill Currie 59e55834ed Another massive speadup caused by using hash tables to lookup already
generated immediate values. frikbot now compiles in just over 1s on my
machine.
2001-04-01 06:01:02 +00:00
Bill Currie 43ea8f4fc0 Rip out I_FloatTime from cmdlib.
Use Sys_DoubleTime instead of I_FloatTime and print out ms for compilation
2001-04-01 03:33:11 +00:00
Bill Currie ec16ffaa65 move to using hash tables for variable lookups.
WARNING: this fixes a scope bug in qcc and thus you WILL get different (but
now correct) code for the following:

float foo;

void () bar =
{
	local float foo;
	foo = 0;
}

ie, the local foo will, as is correct, now be a separate var to the global
foo.
2001-04-01 02:12:57 +00:00
Bill Currie 8866d86fba rip out the crc code in favour of libqfutil 2001-03-28 23:40:54 +00:00
Bill Currie cb5c262ffc qtypes.h:
remove includes of qdefs.h and compat.h
pr_comp.h:
	merge pr_comp.h from quake and qfcc, removing the copy in qfcc
cmdlib.[ch]:
	nuke the endian code.
qendian.c:
	initialise the LittleLong etc pointers at compile time rather than run
	time
com.c (both nq and qw):
	nuke the LittleLong etc init code
everything else:
	fix up after the qtypes.h cleanup
2001-03-28 17:17:56 +00:00
Bill Currie c34868c117 attack cmdlib with a chainsaw. All unused functions are gone. 2001-03-26 21:02:18 +00:00
Bill Currie 135e533e77 raise some limits so customtf will build. this is NOT the right solution :( 2001-03-26 05:33:02 +00:00
Bill Currie 6247233e0e when checking a token, they type of the token must be taken into account. 2001-03-14 04:14:09 +00:00
Bill Currie 32d14bac22 ignore generated files 2001-03-12 21:16:26 +00:00
Jeff Teunissen 2dd03876af QFCC -- the QuakeForge Code Compiler -- an autoconfiscated qcc.
It sucks, but it works, and will form the basis for something that Does
Not Suck.
2001-02-24 06:58:54 +00:00