Commit graph

287 commits

Author SHA1 Message Date
Bill Currie
5f97de56d1 fix a few bugs 2003-10-22 09:14:53 +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
99034fef27 initialized locals aren't constant 2003-09-25 02:05:43 +00:00
Bill Currie
4ce81b28d7 remove nested scopes for traditional mode 2003-09-23 17:59:46 +00:00
Bill Currie
651fa8ca12 correct the operator precendece to match C. hopefully won't cause any
problems :)
2003-09-19 20:50:05 +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
dd9ab1e050 get unsigned mostly working 2003-08-01 21:20:04 +00:00
Bill Currie
0361cb261f fix an incorrect inherited attribute access caused by my "no ivars" fix
(part of the struct re-work)
2003-08-01 02:43:11 +00:00
Bill Currie
cc0d8b364d fix a couple "value computed is not used" not used warnings 2003-07-31 02:16:26 +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
1366ad4661 fix <protocol_list> 2003-07-25 20:34:24 +00:00
Bill Currie
627c6f70f5 allow casting between function types 2003-03-10 21:23:05 +00:00
Bill Currie
90752b33fe make TYPE (void) NAME valid (no args) 2003-02-28 23:36:56 +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
05fb5fe08b make syntax errors a little easier to understand 2003-02-25 07:48:12 +00:00
Bill Currie
599ae15490 give the hash functions more unique names 2003-02-22 22:38:55 +00:00
Bill Currie
2d766710b6 detect multiple initializations of globals 2003-01-29 22:29:37 +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
a4dfef63c3 make all files with rcsid include config.h 2003-01-14 20:18:29 +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
cb81f17697 bah, bloody bison inconsistencies 2002-11-15 17:12:16 +00:00
Bill Currie
3c215ce13f getting closer to working categories 2002-11-14 18:17:43 +00:00
Bill Currie
da334413b8 re-write category handling so it has a better chance of working (category
using code now compiles)
2002-11-12 19:52:43 +00:00
Bill Currie
749b56aae7 forgot to fix these when I did the copyrights 2002-11-06 16:32:28 +00:00
Bill Currie
43fa6a4002 inherited attributes rock :) (thanks, aho, ulman and sethi:) 2002-11-04 17:54:31 +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
7542a2457f replace @argc and @argv with @args.count and @args.list. @args is of type
@va_list making it possible (though not yet: need to implement structure
copy) to pass ... params around.
2002-10-16 02:28:08 +00:00
Bill Currie
3b3b90ef4a fix for new bison 2002-10-16 01:53:56 +00:00
Bill Currie
412db7e27d "for example" is more appropriate than "that is" 2002-09-16 15:42:11 +00:00
Bill Currie
d7eea11c91 static defs are initialized too 2002-09-12 18:30:24 +00:00
Bill Currie
842a9d2eb0 linker.c:
don't seg on uninitialized fields
qc-parse.y:
	support @extern and @static blocks (eg, @extern { ... };)
2002-09-12 17:13:19 +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
3e87e3ecdf allow ';' after @class ... 2002-08-20 21:13:18 +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
2f4094344b don't change the hidden parm type for protocol methods until they're used in a class 2002-08-13 21:18:17 +00:00
Bill Currie
7fcdef1943 make sure current_type is set properly for struct fields 2002-07-17 17:17:05 +00:00
Bill Currie
17cd41883e get the source line for the function from a more reliable location 2002-07-17 14:39:54 +00:00
Bill Currie
34da93f251 get line numbers working on link and fix a bug in the creation of aux
functions
2002-07-17 14:19:30 +00:00
Bill Currie
2cb6138f2b fix a silly segfault and make statement allocation saner 2002-07-08 20:31:59 +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
66aa36b73f start implementing storage classes (extern, static, etc) 2002-06-28 17:59:32 +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
9fee1d07dd initial work on actually writing .qfo files. seems to work, but only test.qfo
is ever writtin :)
2002-06-21 20:46:56 +00:00
Bill Currie
f8dee80355 add unions 2002-06-20 20:28:01 +00:00
Bill Currie
71c9cdcc08 create pointer types correctly 2002-06-13 04:40:09 +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
a771beed74 qfcc.c:
def->scope is always non-0
qc-parse.y:
	link defs from child scopes correctly
2002-06-10 19:07:32 +00:00
Bill Currie
e47570db69 must remember to test compile in the optimising tree :P 2002-06-09 16:34:50 +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
f31705380f call malloc a little less often 2002-06-05 21:13:29 +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
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
3c7fb6a312 fix some missing ;s 2002-05-30 21:18:58 +00:00
Bill Currie
34ec521198 vararg functions can now be imlemented in qc using @argc (number of params
passed through ...) and @argv (array of vectors, one for each ... param)
2002-05-22 20:43:29 +00:00
Bill Currie
60457ee7b8 clean up some expr creaion 2002-05-22 17:18:48 +00:00
Bill Currie
5b590c9301 that seems to have got the type parsing right. (void []) () foo will work
and .float () foo works too
2002-05-22 17:13:52 +00:00
Bill Currie
ddcaef5b0b that didn't work so well :/
back it out for now till I figure out how to get it parsing .float () foo
correctly
2002-05-22 16:38:29 +00:00
Bill Currie
51fbbb7c5c qc-parse.y:
allow complex types for function return values
type.c:
	fix a missing break and an unneeded printout
2002-05-22 16:29:24 +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
2a73235d35 fix some method bugs 2002-05-21 22:51:46 +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
5be384da63 create a `SELF' keyword so the global self entity can be handled sanely.
Not fully implemented yet.
2002-05-17 20:25:46 +00:00
Bill Currie
dc5cd8460e `super' is now a keyword 2002-05-17 19:47:15 +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
b1d1159ae2 allow methods to be builtins 2002-05-17 18:35:54 +00:00
Bill Currie
97170e97b5 setup the default visibility properly 2002-05-17 17:58:57 +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
7cdbef2b11 make class_def return a correct def 2002-05-16 22:33:11 +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
308fa78fc6 lots of obj work 2002-05-15 19:10:23 +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
2c0a20a887 fix the mis-generation of code for state-functions 2002-05-13 20:11:33 +00:00
Bill Currie
b418701637 missing ; 2002-05-10 02:11:23 +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
7f47447492 getting closer to emiting ObjQC code 2002-05-08 21:24:24 +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
b03bfa7a6e start working on the code generation for the Obj stuff 2002-05-08 05:55:57 +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
d5b637ae06 first stab at implementing ObjC like features. The parser doesn't generate
any code for the new features yet (I need to learn more about how objc
/works/) but nothing seems to have been broken.
2002-05-07 16:55:54 +00:00
Bill Currie
067359b39d d'oh, missed a ; 2002-05-01 21:42:29 +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
98fea9ff55 remove some debug code and fix some missing ;s 2002-04-27 02:51:00 +00:00
Bill Currie
1f468e2508 fix a silly parse snafu 2002-04-26 21:49:35 +00:00
Bill Currie
aa006ecf64 qfcc now supports implicit string constant concatentation. 2002-04-26 21:42:50 +00:00
Bill Currie
4f7245d634 allow type (parm, parm, ...) to compile (the parms aren't type checked yet) 2002-04-26 21:28:06 +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
e38259e01f warn when a top-level local shadows a parameter 2002-02-19 00:16:56 +00:00
Bill Currie
6a393d175e implement typedef 2002-01-23 20:50:25 +00:00
Bill Currie
2ce5a91373 allow enum {...} name; but ignore name (eases C <-> QC header compat) 2002-01-21 19:09:23 +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
08c1d57c53 fix a param scoping error 2002-01-17 16:59:00 +00:00
Bill Currie
718a64343b more old-code cleanup. move PR_LexString into make_string 2002-01-04 18:27:01 +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
b03a1bee42 ok, structures seem to generate correct code now 2001-12-08 08:19:48 +00:00
Bill Currie
0c2f36f9a3 some dead code cleanup 2001-12-06 20:05:49 +00:00
Bill Currie
7d9266a3f0 beginnings of array support. no array initialization yet and foo[i] = bar is
broken.
2001-11-15 00:46:36 +00:00
Bill Currie
ed331517b3 more grammar re-work preparing for arrays and structs 2001-11-14 22:31:57 +00:00
Bill Currie
a2bfff5dc4 simplify the type rule 2001-11-14 07:16:58 +00:00
Bill Currie
d27cd9cc21 s/type_size/pr_type_size/
remove the redundant type_size from qfcc
2001-11-12 23:56:46 +00:00
Bill Currie
928d343295 pr_comp.h:
o	add ev_uniteger to the types enum
	o	add opcodes for ifbe, ifb, ifae, ifa, jump, lt.ui, gt.ui, le.ui, ge.ui
progs.h:
	o	add uinteger accessors
pr_exec.c:
	o	implement ifbe, ifb, ifae, ifa, jump, lt.ui, gt.ui, le.ui, ge.ui
pr_opcode.c:
	o	add opcodes for ifbe, ifb, ifae, ifa, jump, lt.ui, gt.ui, le.ui, ge.ui
expr.h:
	o	prototype inc_users
qfcc.h:
	o	add externs for op_ifbe, op_ifb, op_ifae and op_ifa
emit.c:
	o	don't bother emiting an assignment to a temp def that's only used once
		(ie, it's never read, only written to)
	o	support the new if* instructions
expr.c:
	o	support the new if* insructions
	o	dectect expression loops in append_expr
	o	support unsigned integers
	o	re-work temp def usage counting
pr_def.c
	o	debugging for temp def usage counts
pr_opcode.c:
	o	support the new if* instructions
qc-parse.y:
	o	provide defines for IFBE IFB IFAE IFA
switch.c:
	o	do binary searches for strings, floats and ints if there are more than
		8 cases in a switch. Strings need more testing.
2001-11-09 00:58:16 +00:00
Jeff Teunissen
581411e9e2 qfcc: Preparation for getopt. 2001-10-26 06:43:56 +00:00
Bill Currie
f029687ff0 switch statement. could do with lots of improvements, but this should be a
good start.
2001-10-25 06:41:52 +00:00
Adam Olsen
3bba5398ba - audit malloc usage. now everything checks the return value :) 2001-10-24 22:50:06 +00:00
Bill Currie
133ce647fb implement break and continue. only loops covered for now, but that's because
switch isn't implemented yet
2001-10-24 18:57:29 +00:00
Bill Currie
743bc5178b fix uninitialized variable detection for nested scopes 2001-10-24 15:21:21 +00:00
Bill Currie
6553c81a41 proper scoping for QC ala C. 2001-10-24 06:39:49 +00:00
Bill Currie
2ef8adea09 handle more conditional code and check for unitied vars in the test of if ()
etc
2001-10-19 05:16:24 +00:00
Bill Currie
16c334b6b9 uninit var detection seems to work for if and if else 2001-10-19 03:22:04 +00:00
Bill Currie
3572a6be28 change def_list from def_t ** to hashtab_t * and comment out some debug code 2001-10-19 00:45:56 +00:00
Bill Currie
237d238a65 beginnings of "if" uninitialized variable support. doesn't make any
difference yet
2001-10-18 23:06:39 +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
Bill Currie
7407e4f1b7 and some more 2001-09-28 07:09:38 +00:00
Bill Currie
7aec6e253a unused local variable detection 2001-09-22 23:41:47 +00:00
Bill Currie
9f715ae9f8 more small old-parser cleanups 2001-09-15 20:31:17 +00:00
Bill Currie
cf4ca286f0 implement pre and post increment operators (++ and --) 2001-08-20 06:22:28 +00:00
Bill Currie
c2d3d8f3ab temp def expressions and ?:
seems to work :)
2001-08-11 21:15:24 +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
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
d89cd91e4b make the expressions in for (a;b;c) optional 2001-08-01 06:29:09 +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
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
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
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
6c91ee29f0 fix a missed debug test 2001-07-14 01:47:45 +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
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