Commit graph

228 commits

Author SHA1 Message Date
Wolfgang (Blub) Bumiller
5022f716dc fix: check if parsing a variable initializer failed 2012-08-23 13:30:30 +02:00
Wolfgang (Blub) Bumiller
412446f42e -std=qcc now warns about variadic functions via -Wextensions 2012-08-23 11:33:50 +02:00
Wolfgang (Blub) Bumiller
f22112bcb8 Variadic functions: works for builtins, warns for implemenetd functions, -Wvariadic-function, on by default 2012-08-23 11:29:48 +02:00
Wolfgang (Blub) Bumiller
d4077f6884 Have the parser generate immediates AFTER generating the globals for correct def layout 2012-08-22 14:20:28 +02:00
Wolfgang (Blub) Bumiller
330a801ae9 Pop off all the locals after a function 2012-08-22 12:59:52 +02:00
Wolfgang (Blub) Bumiller
19b66800ae TYPE_FUNCTION values which are not constant are now allowed to be generated, they are function pointers. 2012-08-21 16:01:28 +02:00
Wolfgang (Blub) Bumiller
22896e5ef6 at last, the annoying missing ast_delete(typevar) 2012-08-21 11:21:05 +02:00
Wolfgang (Blub) Bumiller
d7f43dfa4d some more error situations where typevar wouldn't get freed 2012-08-21 11:18:40 +02:00
Wolfgang (Blub) Bumiller
8fcc528ffa new warning: -Wlocal-constants 2012-08-21 10:18:55 +02:00
Wolfgang (Blub) Bumiller
92e8f08df3 don't _move_ values out of immediates, it causes NULL strings to be code-generated 2012-08-21 10:08:17 +02:00
Wolfgang (Blub) Bumiller
02cc86db25 Since function prototypes now don't cause the function to become a constant, we cannot check for a constant in [frame,think] notations anymore 2012-08-20 18:27:27 +02:00
Wolfgang (Blub) Bumiller
0d64e555e2 Better handling of EOF - encountering EOF in parser_next will not return false yet, this is a more elegant way... 2012-08-20 18:15:31 +02:00
Wolfgang (Blub) Bumiller
5a0995c767 better handlign of a too early error condition 2012-08-20 18:14:02 +02:00
Wolfgang (Blub) Bumiller
198e35a823 Fix correction of parsiong of multiple variables: parse past the comma 2012-08-20 18:10:06 +02:00
Wolfgang (Blub) Bumiller
99bab76006 Creating the ast_function for a function only when encountering its body, so if no body is specified it works like a function pointer - just like QC wants it 2012-08-20 18:09:41 +02:00
Wolfgang (Blub) Bumiller
20448b93dc Corrected parsing of declarations of multiple variables 2012-08-20 17:59:19 +02:00
Wolfgang (Blub) Bumiller
f0f9680774 add the backticks for a warning 2012-08-19 20:41:31 +02:00
Wolfgang (Blub) Bumiller
af3d9e0bdf ir_value_set_string needs to use a strdup which doesn't return NULL for an emptystring 2012-08-19 20:35:51 +02:00
Wolfgang (Blub) Bumiller
c12e60a510 take 'warnreturn' into account, don't ignore the parsewarnin's Werror status 2012-08-19 20:32:07 +02:00
Wolfgang (Blub) Bumiller
7ef248aadb set -Wmissing-return-values to on by default, new warning: control reaches end of non-void... 2012-08-19 20:26:54 +02:00
Wolfgang (Blub) Bumiller
66ec592f94 parse_block gets a warn-return bool flag 2012-08-19 20:20:39 +02:00
Wolfgang (Blub) Bumiller
adda894976 have function declarations of functions with prototypes take over the actual declaration's body's context data 2012-08-19 19:39:58 +02:00
Wolfgang (Blub) Bumiller
481baeeedc relax parse_close_paren to allow values in parenthesis with no operators... duh 2012-08-19 19:35:45 +02:00
Wolfgang (Blub) Bumiller
a93ed6ae80 fix: use thinkfunc not nextthink, nextthink is set later 2012-08-19 19:25:37 +02:00
Wolfgang (Blub) Bumiller
bd64d7d7b4 Automatic prototyping of frame-functions 2012-08-19 19:24:43 +02:00
Wolfgang (Blub) Bumiller
dae13e87de First draft of handling the [frame,think] notation 2012-08-19 16:13:29 +02:00
Wolfgang (Blub) Bumiller
92d40e0925 Factoring out duplicate code into a function: create_vector_members; creating vector members for vector function parameters 2012-08-19 14:34:23 +02:00
Wolfgang (Blub) Bumiller
78d04a8352 implement correct behaviour for shadows locals 2012-08-18 21:56:42 +02:00
Wolfgang (Blub) Bumiller
ee3aaa58b3 -Wlocal-shadows - note that -std=gmqcc is very different from the rest 2012-08-18 21:54:19 +02:00
Wolfgang (Blub) Bumiller
deccf4e708 splitting parser_find_local up into find_local and find_param - find_local also takes a bool-ptr to tell the caller if it was a local or a global 2012-08-18 21:42:52 +02:00
Wolfgang (Blub) Bumiller
28891c5a37 quotes around the variable name in some messages 2012-08-18 21:35:47 +02:00
Wolfgang (Blub) Bumiller
cd820c831f remove trailing \n from 2 error messages 2012-08-18 21:32:29 +02:00
Wolfgang (Blub) Bumiller
83a758e446 set olddecl so we don't access a NULL value when a variable already exists 2012-08-18 21:31:53 +02:00
Wolfgang (Blub) Bumiller
fc1622140b oops - parsewarning returns true on -Werror, so we gotta invert here 2012-08-18 21:07:23 +02:00
Wolfgang (Blub) Bumiller
4d0be789ac -Wtoo-few-parameters on by deafult - for -std=gmqcc it's always an error 2012-08-18 21:04:16 +02:00
Wolfgang (Blub) Bumiller
6223d78ee3 -Wmissing-return-values, off by default, ignored with -std=gmqcc because in that standard it'll error 2012-08-18 20:19:43 +02:00
Wolfgang (Blub) Bumiller
588cd5018f data/vars.qc - when declaring a function, and it had a prototype - use the new parameter names instead of the ones from the prototype, otherwise things get messy 2012-08-18 20:16:51 +02:00
Wolfgang (Blub) Bumiller
7cc1609117 Disable the member-of namespace check when -std != gmqcc 2012-08-18 19:43:34 +02:00
Wolfgang (Blub) Bumiller
d88e3e8f24 move the member-of check for '.' to after applying the previous dot operators so we don't need parens around 'a.b' of 'a.b.c = x' 2012-08-18 19:42:38 +02:00
Wolfgang (Blub) Bumiller
586bb07c4d Use the current context, not the one from a NULL value... for ast_return 2012-08-18 18:00:20 +02:00
Wolfgang (Blub) Bumiller
701c387dbf parse 'return' without values better 2012-08-18 17:58:51 +02:00
Wolfgang (Blub) Bumiller
2cf4895cc7 Fixup some possibly uninitialized value when parsing 'return' 2012-08-18 17:48:29 +02:00
Wolfgang (Blub) Bumiller
0e3bc87c75 Don't re-add defs which had a prototype 2012-08-18 17:42:38 +02:00
Wolfgang (Blub) Bumiller
24a21d0816 ast_value_copy should copy the expression substructure as well - exposing ast_value_copy to the outside since the parser needs to copy complete types when multiple variables are declared with commas 2012-08-18 17:16:20 +02:00
Wolfgang (Blub) Bumiller
6daf47fc5b set parser->lex to NULL after closing 2012-08-18 16:42:17 +02:00
Wolfgang (Blub) Bumiller
16b5f28b40 don't deallocate the parser on a compile error -_- 2012-08-18 16:40:20 +02:00
Wolfgang (Blub) Bumiller
b6ab0207b1 ast_block_collect: add to ast_block->collect and set the node's .keep=true, those will now always be deleted by the ast_block dtor 2012-08-18 16:27:40 +02:00
Wolfgang (Blub) Bumiller
68e4a937f2 collect vector-member locals in ast_block->collect, like a garbage collection... 2012-08-18 16:24:26 +02:00
Wolfgang (Blub) Bumiller
897bd5727e Revert "let ast_node have a use-counter, helpful for the parser to delete unused fields which otherwise get lost in the void"
This reverts commit 25ffd11aa6.
2012-08-18 16:20:45 +02:00
Wolfgang (Blub) Bumiller
d4587e5667 Revert "delete ast_members from parser->locals when they were unused"
This reverts commit cdeffb6de9.
2012-08-18 16:20:23 +02:00
Wolfgang (Blub) Bumiller
cdeffb6de9 delete ast_members from parser->locals when they were unused 2012-08-18 16:20:17 +02:00
Wolfgang (Blub) Bumiller
25ffd11aa6 let ast_node have a use-counter, helpful for the parser to delete unused fields which otherwise get lost in the void 2012-08-18 16:16:43 +02:00
Wolfgang (Blub) Bumiller
d5e01ba904 clear all the remaining vectors in the parser 2012-08-18 15:59:29 +02:00
Wolfgang (Blub) Bumiller
2045321296 free parser->fields and parser->locals at parser_cleanup 2012-08-18 15:55:50 +02:00
Wolfgang (Blub) Bumiller
483ce89d78 Delete fields in parser_cleanup 2012-08-18 15:51:53 +02:00
Wolfgang (Blub) Bumiller
e2faedcca8 the opening paren is now an operator - to fix up the precedence rules, now 'anentity.afunction()' compiles 2012-08-18 15:25:45 +02:00
Wolfgang (Blub) Bumiller
267bb7d41e get rid of additional trailing \n on parseerror 2012-08-18 14:55:37 +02:00
Wolfgang (Blub) Bumiller
46b4eb1f46 WARN_ERROR -> opts_werror in parser.c 2012-08-18 14:51:12 +02:00
Wolfgang (Blub) Bumiller
7ecd9714b0 add the type of whatever is 'not a function' to that error message 2012-08-18 12:45:51 +02:00
Wolfgang (Blub) Bumiller
6b1a0541c9 parser_strdup to wrap util_strdup and actually dup empty strings 2012-08-18 12:26:21 +02:00
Wolfgang (Blub) Bumiller
e00c8da849 Added support for some modelgen/spritegen commands 2012-08-16 20:47:31 +02:00
Wolfgang (Blub) Bumiller
54dcbc22bf NOT for entity, function and string - we're not constant-folding it for functions and entities right now 2012-08-16 16:24:47 +02:00
Wolfgang (Blub) Bumiller
31a8cd80c8 unary NOT operator for float and vector 2012-08-16 16:21:19 +02:00
Wolfgang (Blub) Bumiller
1a3a0014c5 even in non-qcc mode we need to search the variables for fields because of field-pointers 2012-08-16 16:21:09 +02:00
Wolfgang (Blub) Bumiller
7c731b70cf verbose error about unhandled operators 2012-08-16 16:07:00 +02:00
Wolfgang (Blub) Bumiller
d81ef81246 Fix an error message 2012-08-16 15:59:09 +02:00
Wolfgang (Blub) Bumiller
ec439d7880 Allow fieldpointer parameters in functions, allow function fields again 2012-08-16 15:27:06 +02:00
Wolfgang (Blub) Bumiller
47243d0df1 allow redeclaration of fields, but warn about them 2012-08-16 15:14:39 +02:00
Wolfgang (Blub) Bumiller
5a383ac2b0 Reorganizing expression parsing to allow prefix-operators like unary minus 2012-08-16 15:11:03 +02:00
Wolfgang (Blub) Bumiller
c4730b405b unary - operator implemented, adding imm_vector_zero and imm_float_zero since those should be accessible quickly 2012-08-16 14:23:18 +02:00
Wolfgang (Blub) Bumiller
ba1886ad31 add some missing casts to some mem_a 2012-08-16 12:34:28 +02:00
Wolfgang (Blub) Bumiller
470fc68b06 don't try to access function-local functions outside of functions... 2012-08-16 11:36:16 +02:00
Wolfgang (Blub) Bumiller
2a7e7046d9 assigning values to constant globals 2012-08-16 11:33:29 +02:00
Wolfgang (Blub) Bumiller
b7f9b20a2b strpcy->memcpy 2012-08-15 17:01:16 +02:00
Wolfgang (Blub) Bumiller
42e2102839 remove MEM_VECTOR_INIT - the memset does it all, don't give a false sense of initialization since it wasn't complete anyway 2012-08-15 12:13:15 +02:00
Wolfgang (Blub) Bumiller
e5124ecf2f Fix memset on the parser... 2012-08-15 12:11:15 +02:00
Wolfgang (Blub) Bumiller
475cb97404 bit-and const-fold should use bitand not bitor 2012-08-14 23:52:57 +02:00
Wolfgang (Blub) Bumiller
c0ddb0908c constant folding for bit and logic ops, added some macros to shorten the code (by a lot) 2012-08-14 23:50:49 +02:00
Wolfgang (Blub) Bumiller
a5b3faae30 const folding for division 2012-08-14 23:43:08 +02:00
Wolfgang (Blub) Bumiller
b8d92dfa01 constant folding for +, - and * 2012-08-14 22:51:05 +02:00
Wolfgang (Blub) Bumiller
9ed9a0c669 get rid of more duplicate code 2012-08-14 22:34:20 +02:00
Wolfgang (Blub) Bumiller
de4fe00d2f Allow multiple fields to be declared using comma 2012-08-14 22:31:08 +02:00
Wolfgang (Blub) Bumiller
e9844d9abf vector fields now get _x, _y and _z too 2012-08-14 20:00:11 +02:00
Wolfgang (Blub) Bumiller
4c5c615f95 combine 2 ifs to shorten code a little 2012-08-14 17:48:22 +02:00
Wolfgang (Blub) Bumiller
8dd7943768 -= operator 2012-08-14 17:44:14 +02:00
Wolfgang (Blub) Bumiller
3ef6da8e5b error message replacement 2012-08-14 17:36:20 +02:00
Wolfgang (Blub) Bumiller
a574da7df8 += operator implemented 2012-08-14 17:30:55 +02:00
Wolfgang (Blub) Bumiller
3544cfa2b2 make the += operator use binstore actually, currently it was acting like a regular plus 2012-08-14 17:27:52 +02:00
Wolfgang (Blub) Bumiller
f39a47e4ed replacing lots of error messages 2012-08-14 17:27:26 +02:00
Wolfgang (Blub) Bumiller
7506817224 shush typo 2012-08-14 17:17:35 +02:00
Wolfgang (Blub) Bumiller
c4cd49a408 different warning message 2012-08-14 17:08:00 +02:00
Wolfgang (Blub) Bumiller
ca1c9b921d another -Wextensions situation: -std=qcc has no for loops 2012-08-14 16:59:14 +02:00
Wolfgang (Blub) Bumiller
16093adb09 fixup do-while parsing, expect a semicolon afterwards 2012-08-14 16:42:29 +02:00
Wolfgang (Blub) Bumiller
339c0e5870 do-while loops 2012-08-14 16:38:11 +02:00
Wolfgang (Blub) Bumiller
4d47c40cb9 parsewarning() now gets GMQCC_WARN since parsewarning returns whether or not the warning was treated as an error, thus we need to bail if it returns true 2012-08-14 16:26:42 +02:00
Wolfgang (Blub) Bumiller
2d9623cbe8 the 'local' keyword now also introduces the declaration of a local variable 2012-08-14 16:22:38 +02:00
Wolfgang (Blub) Bumiller
107100c666 -dump option, by default the IR is not dumped anymore 2012-08-14 16:19:23 +02:00
Wolfgang (Blub) Bumiller
1638cc9f01 -Wextensions for -std=qcc: warn about missing 'local' keyword when declaring a variable without it 2012-08-14 16:17:09 +02:00
Wolfgang (Blub) Bumiller
cc48802685 eof after parsing the semicolon of a function declaration shouldn't be an error... 2012-08-14 16:14:26 +02:00
Wolfgang (Blub) Bumiller
78d223fdcb Getting rid of some debug output 2012-08-14 16:12:12 +02:00