Commit Graph

368 Commits

Author SHA1 Message Date
Bill Currie a648f043de Give functions their own defspace.
The defspace is propogated through the function's sub-scopes.
2011-01-25 12:34:45 +09:00
Bill Currie 34ffce50fa Ensure current_symtab gets set at the start of parsing.
current_symtab must be set even if the first thing encountered is a syntax
error.
2011-01-25 12:16:13 +09:00
Bill Currie 726f293d0d Allocate space for defs and handle basic initializations.
Block initializers (arrays and structs) are still broken.
2011-01-25 12:16:13 +09:00
Bill Currie 30701980bc Get QC cfunctions and defs working. 2011-01-25 12:16:13 +09:00
Bill Currie 0624408317 Move the diagnostic functions into their own file. 2011-01-24 21:54:57 +09:00
Bill Currie d618e51dc8 Move save_string and make_string into strpool
Might not be the perfect place, but at least they're strongly related.
2011-01-24 21:32:48 +09:00
Bill Currie 4ac80c2932 Get qfcc running again.
It segs when it tries to link, but that's because a real object file has
not been created yet. However, I can get my tree and flow diagrams :)
2011-01-22 15:52:57 +09:00
Bill Currie 5deda9c9b9 Clean out ex_def as ex_symbol replaces it. 2011-01-19 22:25:04 +09:00
Bill Currie e08efe036b Move the constant expression values into their own struct. 2011-01-19 08:43:24 +09:00
Bill Currie ea3895805b Rewrite much to use symbols and symtabs. Gut emit.c. Massive breakage.
That which isn't rewritten is horribly broken. However, this does include a
nice mechanism for building QC structs for emitting data.

emit.c has been gutted in the spirit of "throw one away".

There is much work to be done to get even variables emitted, let alone
code. Things should be a little more fun from here on.
2011-01-17 22:34:41 +09:00
Bill Currie ffea505678 Cleanup QC's constant handling based on QP. 2011-01-14 12:10:28 +09:00
Bill Currie c69ac1f56f Don't segfault when build_builtin_function detects an error. 2011-01-10 12:25:31 +09:00
Bill Currie 7971b0868e Break out the begin_function code into its own function. 2011-01-10 12:25:31 +09:00
Bill Currie fbdbcfada4 Remove deprecated @argc and @argv 2011-01-05 13:10:57 +09:00
Bill Currie 5627e43465 Use the method's selector rather than its def name in error messages. 2011-01-03 16:25:29 +09:00
Bill Currie a1f36a9944 Make new_function take a def rather than a name.
Moves into new_function some code that should have been there in the first
place.
2011-01-03 16:25:29 +09:00
Bill Currie 4c69a97ac7 Allow normal declarations within a class implementation.
I had always been under the assumption that such was illegal in
Objective-C, but after working on Forge, I now know otherwise.
2011-01-03 16:25:29 +09:00
Bill Currie dc5bafb8fb Minimal error recovery.
No more bailing on the first syntax error. While the recovery is not
perfect (things can get right twisted), qfcc will now continue parsing
after a syntax error.
2011-01-03 16:25:29 +09:00
Bill Currie a4635d79e8 Slightly more informative error locations.
Inside a class or protocol definition is not "at top level" ;)
2011-01-03 16:25:29 +09:00
Bill Currie f738ef5dba Remove redundant RETURN statement rule.
The same effect can be achieved with one rule using opt_expr.
2011-01-03 16:19:28 +09:00
Bill Currie 28740bb57f Add unsigned integer constant support. 2010-12-23 19:32:28 +09:00
Bill Currie 4481ba9b0d Allow explicit references to classes and categories.
Use "@reference ClassName;" or "@reference ClassName(CategoryName);" to
create a refence to the class or category, forcing the defining object file
to be linked into the program when the object file is part of a library.
2010-12-12 20:27:56 +09:00
Bill Currie 67beaf4487 Nil is a constant, so allow it in global initializers. 2010-11-24 17:01:18 +09:00
Bill Currie a623fb53a7 Proper support for empty structs and unions.
They now have a single private, void, unnamed member, resulting in a size of
1 word. This makes empty structs useful for typed opaque handles.
2010-11-24 17:01:17 +09:00
Bill Currie 51a32f4f87 minor comment about scoping in traditional mode 2010-02-22 13:44:52 +00:00
Bill Currie 56d01ce267 found an uncontrollable warning 2010-02-20 12:01:49 +00:00
Bill Currie 8abb9a69aa remove support for an optional = in struct/union declarations 2010-01-13 06:34:32 +00:00
Bill Currie ae4fc3147d allow '*pointer' expressions 2010-01-13 06:31:41 +00:00
Bill Currie c2dcc20d2a allow (constant) expressions in array declarators 2010-01-13 06:23:32 +00:00
Bill Currie dcf593291d fix for new bison (must be explicit with the type of $$ in mid-rule actions) 2009-12-21 05:53:00 +00:00
Bill Currie 9ac15436d9 More docs.
Enhance qfprogs qfo debugging.

Make sure functions marked as extern don't emit anything. Fixes the segfault
when building klik.
2008-08-01 13:54:24 +00:00
Bill Currie 3e50aae01f "print" command for dumping values in the progs and add return type info to the debugging information 2007-09-15 07:47:31 +00:00
Bill Currie a521a78adb catch more uninitialized variables 2007-05-13 08:39:07 +00:00
Bill Currie b356f1cbd4 remove some debug 2007-05-13 07:06:59 +00:00
Bill Currie f4d40650f5 make initialized locals behave similarly to qcc in traditional mode (note, they're not exactly the same) 2007-05-13 06:21:54 +00:00
Bill Currie 0e78c3f6da make STORAGEX lower priority than UNARY so casts work 2007-05-07 23:44:45 +00:00
Bill Currie 9609fe8ca4 bloody hell 2007-05-07 15:04:06 +00:00
Bill Currie 839c00b97b back out the large packet/entity related patches. they've provent to be troublesome and it seems FTE has a better solution. 2007-05-07 14:58:53 +00:00
Bill Currie 8f365c4512 that wasn't supposed to go in 2007-05-07 12:18:54 +00:00
Bill Currie 72daa2fd2b add some sounds to the menus (not yet finished) 2007-05-07 12:17:12 +00:00
Bill Currie 7ba41632d9 snax's fixes to clean up most of the shift/reduce conflicts 2007-04-28 08:49:07 +00:00
Bill Currie e8e2d3a6e5 make "local" optional 2007-04-28 05:20:47 +00:00
Bill Currie cfeb14fecf warn when local variables are redecalred in the same scope. This won't normally cause problems, but it can save a lot of grief when converting traditional quakec code. 2007-04-12 09:39:42 +00:00
Bill Currie 30744a555e find the other place def_func relocs get emitted. I keep forgetting about the .y file when grepping source :P 2007-04-10 07:40:03 +00:00
Bill Currie 48fdd0cb26 record the params for builtins, too. 2007-04-09 06:16:34 +00:00
Bill Currie 25bf40a71a finish the break overloading and add some more tests (really need to get these automated) 2007-04-07 04:58:27 +00:00
Bill Currie a6388ee680 overload "break" and allow break to be used in --traditional 2007-04-06 11:46:21 +00:00
Bill Currie e9f49ca816 allow static local vars 2006-12-11 09:26:07 +00:00
Bill Currie 48f8bbd12e group the struct rules together 2006-12-02 06:49:55 +00:00
Bill Currie b6a4a520d5 silence bison's new warnings 2006-12-01 08:17:55 +00:00
Bill Currie 3fb03fc2be hah, should have been using __attribute__((used)) all that time (rather
than __attribute__((unused))). fixes the missing console in -x11
2005-08-04 15:27:09 +00:00
Bill Currie 0edd694bac fix a default action type clash in some versions of bison 2005-03-31 08:23:11 +00:00
Bill Currie 66257e3a88 run in fear, function overloading is here
This is an imperfect revision of history.
2004-11-13 11:50:00 +00:00
Bill Currie 64cc8c60d2 compile time protocol support seems to be complete now. fortunatly, protocols had never been written out so the corrections to the protocol related stuctures do not need a progs version bump. runtime protocol support hasn't been fully tested yet.
+load runtime support seems to be working.

This is an imperfect revision of history.
2004-11-11 00:34:00 +00:00
Bill Currie a3a2dd62e3 fix type of "self"
This is an imperfect revision of history.
2004-11-02 07:13:00 +00:00
Bill Currie a4dbdb4d06 whitespace
This is an imperfect revision of history.
2004-11-02 07:08:00 +00:00
Bill Currie fff41d664a detect re-declaring identifiers as different types (typedef, enum, var, etc)
This is an imperfect revision of history.
2004-11-02 07:02:00 +00:00
Bill Currie 332ec82495 update the scope of local defs to the parent scope when the creation scope
goes away (doesn't get updated to the global scope). fixes a bug where
local defs would be miscounted (and sometimes lost)
2004-04-09 03:47:41 +00:00
Bill Currie 25ac9cb07b fix "for (;;)" etc 2004-03-30 02:31:02 +00:00
Bill Currie 865b31caac make sure messages generated by issues within a function don't get
"At top level"
2004-02-13 04:57:15 +00:00
Bill Currie 69730cae8b fix some type classes in older bison 2004-02-12 01:37:27 +00:00
Bill Currie 02d89ee7d5 allow computed functions for "think" in state expressions 2004-02-11 08:09:10 +00:00
Bill Currie 1c090c38a3 allow non-const expressions for the frame number and make sure the time
step is a float (for state expressions)
2004-02-11 04:00:11 +00:00
Bill Currie 0fe4c2a600 catch redefined functions 2004-02-11 01:53:17 +00:00
Bill Currie c3f41e3e69 new opcode: state.f. same as state, but takes a 3rd float operand to
specify the step for calculating nextthink. accessed using
[frame, think, step] (state is [frame, think])
2004-02-11 01:43:33 +00:00
Bill Currie 1fc517f7db C style functions can now (optionally) be used (void foo ();) 2004-02-11 00:36:34 +00:00
Bill Currie e2602bc9d5 fix misparse of void () foo; 2004-02-10 23:49:45 +00:00
Bill Currie 7af8f8a6f6 ; at the end of a function is no longer required. void () foo = {} and
void () foo = {}; are both valid now.
2004-02-10 23:20:44 +00:00
Bill Currie 6e4c6478a1 getting closer to optional ; at the end of functions. also gets rid of the
need for the context-sensitivity hack used for distinquishing frunction
inits from struct/array inits
2004-02-10 03:25:24 +00:00
Bill Currie ddc44f33da compress the 4 method building rules into 2 2004-02-09 07:35:19 +00:00
Bill Currie 3f27042e8d forgot to look after current_storage with methods 2004-02-09 07:17:44 +00:00
Bill Currie 499dac6bb1 step one towards more flexible function declarations 2004-02-08 23:46:40 +00:00
Bill Currie ab4f0e7ca9 warn on return foo (); where foo returns void 2004-02-04 01:30:12 +00:00
Bill Currie 0f94dd95d2 make @class foo work when foo is already defined 2004-02-03 07:29:20 +00:00
Bill Currie ba901863d2 fix a missing ; 2004-01-27 04:41:20 +00:00
Bill Currie 897b49140a initialized locals are a little trickier... 2004-01-25 22:08:08 +00:00
Bill Currie 7423ee389d better timing for constant folding 2004-01-25 21:36:44 +00:00
Bill Currie 51b0a66ac7 better constant folding with auto-conversion between scalar types (might
make that optional for non-constants)
2004-01-25 08:55:03 +00:00
Bill Currie 802aacfaf4 allow constant expressions to be used for builtin numbers 2004-01-07 00:03:05 +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 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