Commit Graph

133 Commits

Author SHA1 Message Date
Bill Currie 4336fc2c73 Move method function defs into the far data space.
As they are never referenced directly by instructions, there's no need for
them to be in the near data space, taking precious def locations.
2011-02-15 15:33:18 +09:00
Bill Currie 5707888fcf Fix some error-recovery segfaults. 2011-02-14 23:10:46 +09:00
Bill Currie 181596f5bf Make relocation records store the space of the relocation.
The space is meaningless for op_* relocations as they are always in the
code space, but def_* relocations need to know which space holds the
location to be adjusted.
2011-02-12 22:34:38 +09:00
Bill Currie 681ded9375 Fix debug line number information. 2011-02-09 09:59:43 +09:00
Bill Currie 5eff00fdeb Fix debug information. 2011-02-09 08:47:01 +09:00
Bill Currie 8c6fc6fb03 Fix a double insertion of a symbol. 2011-02-08 08:44:08 +09:00
Bill Currie d564e6f017 Clean out the old debug prints from emit_function() 2011-02-07 08:46:12 +09:00
Bill Currie f2c272f0b8 Make adding a symbol to multiple tables an internal error. 2011-02-06 20:00:14 +09:00
Bill Currie f44a26e268 Fix type chaining when dealing with decls. 2011-02-03 21:32:58 +09:00
Bill Currie 7fb8c8247e Don't do a find_type on the parsed function.
This is needed for C style declarations, but breaks QuakeC style. The fix
is to do the find_type once the return type has been filled in.
2011-02-02 15:08:59 +09:00
Bill Currie d11d128c96 Avoid segfaulting on errors. 2011-02-01 21:18:39 +09:00
Bill Currie 80ce179bc2 Scan the param list for problems with void. 2011-02-01 21:18:08 +09:00
Bill Currie 80424f6ad5 Ensure functions are always properly terminated.
Control that reaches the end of a function must see a return statement.
2011-01-28 13:14:30 +09:00
Bill Currie 36c99a8da1 Get function def creation working again. 2011-01-26 14:48:22 +09:00
Bill Currie 6ce3c5a59a Get statments being emitted to the code segment.
The first function seems to work fine, but there's a problems with the
scope of params causing params to get their knickers in a twist (tangled
linked list).
2011-01-25 15:46:48 +09:00
Bill Currie 849d013f5e Allocate space for function parameters. 2011-01-25 15:43:57 +09:00
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 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 483cbeba03 Fix a few FIXMEs. 2011-01-24 21:13:37 +09:00
Bill Currie afc5b2827d Simplify def handling, use far data.
Since there is now a proper symbol table, defs are now just references to
memory locations and the symbol table takes care of duplicates.

Also, start using far data for ObjQC structures.

The qfo functions have been stubbed out until I figure out what to do with
object files in the new scheme.
2011-01-24 15:41:43 +09:00
Bill Currie b5424bca7d Start work on getting expressions converted to internal statements. 2011-01-19 15:47:45 +09:00
Bill Currie e08efe036b Move the constant expression values into their own struct. 2011-01-19 08:43:24 +09:00
Bill Currie ff6e1b4d6c Get functions attempting to generate code.
However, the statements are only printed as expressions.
2011-01-19 08:38:09 +09:00
Bill Currie 87ce9f5333 Get basic function creation working.
Even more FIXMEs, but the pascal parser can now create functions. The
function records even get emitted.
2011-01-18 12:47:13 +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 c4d19e6ebc Get __PRETTY_FUNCTION__ working for overloaded functions. 2011-01-13 16:22:27 +09:00
Bill Currie 0c9522b1ca Fix overloaded functions. 2011-01-13 16:21:31 +09:00
Bill Currie ac14db7b1b Create a function to ease param list building.
This is especially useful for QuakePascal, but it will mean I'll be able to
get rid of the parameter reversals in Ruamoko later on.
2011-01-13 14:45:53 +09:00
Bill Currie 638f4445cc More return code cleanup.
Don't use the true void return in traditional mode.
Prefer the true void return over "done" at the end of functions.
Don't emit the above if the last emitted statement is a return and there is
no label at the end of the function.
2011-01-13 00:46:46 +09:00
Bill Currie 75ec6bf244 Clean out some unnecessary types from the progs engine and clean up the mess.
This is a nasty commit, sorry, but 99% of the commit is interdependent.
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 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 f5706f9c44 Make control of expression dumping less of a hassle. 2010-12-19 11:15:13 +09:00
Bill Currie 799d46f83d Check for incomplete types and better param/return size checking. 2010-11-24 17:01:17 +09:00
Bill Currie e5e560cbaf Ensure struct params are small enough to fit in the param slots. 2010-11-24 17:01:17 +09: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 680bc22697 better error reporting for redefines 2007-05-13 09:02:51 +00:00
Bill Currie 642bb0f810 don't create a reloc for an external function 2007-04-09 14:06:12 +00:00
Bill Currie f6924f35e5 report the line of the previous declaration of the function 2007-04-06 12:02:34 +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 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 fc2413ff72 more quaternion work (should be working, haven't come up with tests yet) 2004-04-08 03:32:14 +00:00
Bill Currie 14e8bfe94b auto-init for uninitialized locals in traditional mode as requested by
Grievre
2004-02-21 05:52:05 +00:00
Bill Currie 0fe4c2a600 catch redefined functions 2004-02-11 01:53:17 +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 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 b6b5089ccc add a "nosave" flag to defs making it easier to make defs that don't get
saved automaticly
2003-04-25 17:00:22 +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 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 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 b0d568d85f local defs for debug info now work 2002-07-17 15:40:08 +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 e550ad670a more linking fixes, including seting up relocations. not quite working yet 2002-07-13 06:09:03 +00:00
Bill Currie c1894db59f split the emit stuf out of expr.h into emit.h 2002-07-08 18:53:07 +00:00
Bill Currie 8a402381e6 redo how progs strings are stored so multiple pools can exist 2002-07-05 20:02:10 +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 37d3fecd5d remove an unneeded field 2002-06-17 05:28:43 +00:00
Bill Currie 331df31f6a get the function number early so things don't get mixed up when new functions
get created while parsing a function
2002-06-11 06:54:32 +00:00
Bill Currie 0747bcb099 set the debug function number correctly 2002-06-10 18:39:06 +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 8aa98c0d20 fix several silly mistakes 2002-06-06 21:51:47 +00:00
Bill Currie 38d3a15413 d'oh, forgot to compile test :P 2002-06-05 19:31:43 +00:00
Bill Currie cb395c5469 misc def improvments 2002-06-05 19:03:51 +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 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 b1d1159ae2 allow methods to be builtins 2002-05-17 18:35:54 +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 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 b226d24b52 rework the param parsing to make selectors easier to handle 2002-05-08 05:15:19 +00:00