Commit graph

358 commits

Author SHA1 Message Date
Wolfgang Bumiller
8ce331b563 allow array size to be inferred from the initializer 2013-06-12 15:47:11 +02:00
Wolfgang Bumiller
dc91918c1f error about too many elements in initializer; added test for initialized arrays: arrays2.tmpl/qc 2013-06-12 14:41:38 +02:00
Wolfgang Bumiller
bc4a66e9f7 setting initializing values 2013-06-12 14:32:34 +02:00
Dale Weiler
11179a2a71 Major header reworking, this respects the namespaces properly. Makes object dependency more obvious, allows for better make caches, and prevents misuse of library features, i.e use con_* instead of printf. 2013-06-04 02:47:07 +00:00
Wolfgang Bumiller
ba781c53ef now a bare 'return;' is not required anymore if return has been assigned anywhere 2013-05-29 17:08:03 +02:00
Wolfgang Bumiller
9167de1631 fixing that comment... 2013-05-29 16:56:39 +02:00
Wolfgang Bumiller
afdc0c9dc8 assignable return value now lives in ast_function, as globals can get overwritten randomly; removed parser_find_retval; updated parse_return 2013-05-29 16:51:59 +02:00
Dale Weiler
db6ca6c5f8 Make static 2013-05-29 11:32:42 +00:00
Dale Weiler
6d6a2efada Experimental support for implicit return assignments. This closes #107. To enable return assignment support use -freturn-assignments. This allows you to do the following in QC code. T name() { return = expr_eval_T; return; /* returns expr_eval_T */ }. It allows for concise code and to rid locals in functions. It also saves a tremendous amount of space since only types of certian globals need to be allocated for returns. 2013-05-29 11:13:42 +00:00
Dale Weiler
2923b718e1 Merge branch 'union-replacement' into cooking
Conflicts:
	ast.c
2013-05-29 03:43:49 +00:00
Dale Weiler
f892b32335 Major export cleanup. Anything that was exported but wasn't used outside where it was implemented has been turned into static, and their exports have been removed. This actually makes the compiler compile slightly faster. 2013-05-29 03:29:04 +00:00
Wolfgang Bumiller
d70b571769 killing the union types 2013-05-11 22:34:01 +02:00
Wolfgang Bumiller
9f8bee4bf1 ast_value now has an initializer list array, still unused but it's there for later 2013-04-26 10:47:55 +02:00
Wolfgang Bumiller
3a4aba0b31 Grrrr 2013-04-24 17:47:42 +02:00
Wolfgang Bumiller
66305c676a Allow string concatenation in the parser as well, for now only for immediate strings and __FUNC__, maybe later -fpermissive or somethign could allow it on const-delcared string variables 2013-04-24 17:27:04 +02:00
Dale Weiler
489ad486bc Get it compiling in visual studio again. 2013-04-24 01:43:53 +00:00
Dale Weiler
160e7cf7ee Remove trailing whitespace 2013-04-21 10:24:55 +00:00
Wolfgang Bumiller
1f667c4b35 ast_expression_delete: delete varparam if it is set - fixes another leak 2013-04-15 21:05:59 +02:00
Wolfgang Bumiller
d5e90a17f9 fix memleak in ast_local_codegen 2013-04-15 20:56:48 +02:00
Dale Weiler
ef528d6710 Added tracing to strdup for allocations, fixed some memleaks, this isn't pretty (trying to track down some weird memory leak issues) 2013-04-14 23:51:16 +00:00
Dale Weiler
ccc2eb3298 More function flatening 2013-04-14 01:14:14 +00:00
Dale Weiler
48d6375817 flatten the use of strcpy, 90% of the cases we already knew the length of the string either at compile-time, or already within the scope we where, thus letting us use strncpy, which can be further optimized (unrolled if static) 2013-04-14 01:00:25 +00:00
Dale Weiler
0367a6175d Add some ice 2013-03-07 22:52:03 +00:00
Dale Weiler
52ffc6db10 Merge branch 'cooking' of github.com:graphitemaster/gmqcc into cooking 2013-02-05 17:16:09 +00:00
Dale Weiler
b3e87c3280 ast referencing 2013-02-05 17:14:56 +00:00
Wolfgang Bumiller
4b5afe3456 ast_array_index_codegen: never regenerate code 2013-02-05 17:54:14 +01:00
Wolfgang Bumiller
72106b0982 removing some left-over alloc checks 2013-02-05 17:34:40 +01:00
Wolfgang Bumiller
e662efae61 fix: rotate_entfield_array_index_nodes deleting the old array caused expressions to be deleted recursively 2013-02-03 23:38:06 +01:00
Dale Weiler
b9f46f4ef7 Not an assembler instruction, but virtual instruction used by the IR. 2013-01-30 06:31:24 +00:00
Dale Weiler
36c5722273 Rename 2013-01-30 05:35:07 +00:00
Dale Weiler
d201cfe6b4 Work in progress options cleanup. 2013-01-30 05:24:30 +00:00
Wolfgang Bumiller
1410840ef6 Make the varargs counter more stable, it'll now work with a function pointer with a different number of fixed params 2013-01-17 10:30:32 +01:00
Wolfgang Bumiller
00a9d2a9e3 fixing a possible NULL deref 2013-01-16 20:32:37 +01:00
Wolfgang Bumiller
d7f4e981a3 fix: missing-return check: vec_size(entries) is 0 on the entry-block, also check if it's the first block 2013-01-14 10:56:56 +01:00
Wolfgang Bumiller
5887afae62 copying the output type on ast_array_index_codegen 2013-01-12 15:49:04 +01:00
Wolfgang Bumiller
a01388ea7d Copying arg counter into the local 2013-01-12 15:06:19 +01:00
Wolfgang Bumiller
2a4ea74a97 ir_function stores max_varargs now 2013-01-12 14:01:16 +01:00
Wolfgang Bumiller
973122ed9b ast_call now has a va_count which causes a store to reserved:va_count before the call 2013-01-12 13:29:47 +01:00
Wolfgang Bumiller
6dfdf69a8e vararg accessor generation 2013-01-12 13:01:20 +01:00
Wolfgang Bumiller
c69ba2c734 parsing of vararg-counter 2013-01-12 11:29:03 +01:00
Wolfgang Bumiller
6a248e2498 type restricted varargs 2013-01-12 11:10:29 +01:00
Wolfgang Bumiller
ca947d782c Declaration of type-restricted varargs 2013-01-12 11:03:17 +01:00
Wolfgang Bumiller
6df3c625b0 Added a flag to both ast and ir which enforces the generation of a globaldef for a value 2013-01-11 19:15:59 +01:00
Wolfgang Bumiller
cf293bc669 handling the ast-destruction in computed goto 2013-01-03 13:21:11 +01:00
Wolfgang Bumiller
ae09831227 Introducing TYPE_NOEXPR so that these undefined labels cannot be used on the expression side of goto ternary expressions; ast_label now is TYPE_NOEXPR; we may consider setting ast_ifthen to that too unless we want ifthen to return a value... 2013-01-03 12:49:21 +01:00
Wolfgang Bumiller
e146fd121c parse_expression now takes a boolean flag on whether or not it should be creating ast_labels for undefined identifiers; creating the label later will pick it up and set its undefined flag to false 2013-01-03 12:46:33 +01:00
Dale Weiler
29db4a44ed Happy new years! 2013-01-01 05:08:55 +00:00
Wolfgang Bumiller
5a5cb74db2 add codegen_output_type to ast_binary_codegen 2012-12-31 13:20:08 +01:00
Wolfgang Bumiller
26d43e650f Adding some more internal-error messages where they were missing; fixed ast_ternary_codegen to use the ast_node's type instead of the ir generated ones to avoid erroring on TYPE_NIL 2012-12-31 12:08:47 +01:00
Wolfgang Bumiller
a170154927 nil in ternary, and fix ternary to honor -fcorrect-logic/-ftrue/false-empty-strings 2012-12-31 11:45:00 +01:00
Wolfgang Bumiller
4d5153854b This should actually cover all nil cases 2012-12-31 11:34:29 +01:00
Wolfgang Bumiller
819ed10f29 nil check in paramter type checking 2012-12-31 11:30:02 +01:00
Dale Weiler
46374e94ca Add support for user defined messages for [[deprecated]] generalized attribute 2012-12-30 09:58:52 +00:00
Wolfgang Bumiller
755ee5462f Properly support globals initialized to nil 2012-12-29 21:15:59 +01:00
Wolfgang Bumiller
33be9d4559 Don't allow code like: v * '0 1 0' = 3; to actually work... 2012-12-29 15:13:54 +01:00
Wolfgang Bumiller
73bc4cc3e4 -Ovector-components 2012-12-29 15:05:04 +01:00
Wolfgang Bumiller
40b2a26e89 TYPE_NIL, builder->nil, ast_value_codegen for TYPE_NIL 2012-12-28 18:05:28 +01:00
Wolfgang Bumiller
a60d0182db finish parsing of labeled loops; ast support added 2012-12-28 00:04:09 +01:00
Wolfgang Bumiller
ebb7cb2ae3 parsing of loop labels 2012-12-27 23:43:20 +01:00
Wolfgang Bumiller
d4483bfda6 -Oglobal-temps 2012-12-26 23:18:45 +01:00
Wolfgang Bumiller
2b468cb0ee Added the 'static' keyword.
Implements #71
2012-12-24 11:30:58 +01:00
Wolfgang Bumiller
7998a98818 ir_function now has a flags field - flags are: IR_FLAG_HAS_{ARRAYS,UNINITIALIZED,GOTO} 2012-12-23 16:21:38 +01:00
Dale Weiler
c3964cf29d Make compiler and virtual-machine compile as C++ code, also removed gmqcc_voidptr hack. 2012-12-23 07:51:19 +00:00
Wolfgang Bumiller
eb952f1199 fix -fshort-logic to cast to true boolean values 2012-12-22 20:05:15 +01:00
Wolfgang Bumiller
0fe71af4ce -fcorrect-logic now handles only vectors 2012-12-22 17:18:37 +01:00
Dale Weiler
fa401b6f56 Cleanups and make compile with clang again with no warnings. 2012-12-22 08:22:50 +00:00
Wolfgang Bumiller
5375400e85 minor: fix ast_function_label 2012-12-20 23:27:23 +01:00
Wolfgang Bumiller
8d86d7d1c1 Don't check for is_return but for final at the end of a function so that if 'goto' is the last expression we don't try to append a return 2012-12-20 21:05:29 +01:00
Wolfgang Bumiller
a985a5cab1 while/for/do now all use process_condition, ast_loop got 2 new parameters for more efficient translation 2012-12-20 20:22:31 +01:00
Wolfgang Bumiller
d72cb42b08 process_condition function used by parse_if - need to still add it to loops 2012-12-20 19:51:30 +01:00
Wolfgang Bumiller
eb8dc60981 Turn -fallow-unreachable-code into a -Wunreachable-code 2012-12-20 16:29:32 +01:00
Wolfgang Bumiller
4ef0e8c66e -g sets opts.g and -debug causes blocks to be labeled 2012-12-20 16:04:10 +01:00
Wolfgang Bumiller
bb356bffa5 that should have gone into the second to last commit 2012-12-20 15:27:15 +01:00
Wolfgang Bumiller
3119a95a89 -fallow-unreachable-code 2012-12-20 14:41:16 +01:00
Wolfgang (Blub) Bumiller
c8e163b0df ast_call now passes AST_FLAG_NORETURN on to the IR 2012-12-19 20:47:01 +01:00
Wolfgang (Blub) Bumiller
ba434c8e22 removing ast_expression_common.variadic, adding ast_expression_common.flags, added AST_FLAG_VARIADIC and AST_FLAG_NORETURN 2012-12-19 20:45:48 +01:00
Wolfgang (Blub) Bumiller
384446316a VINSTR_NRCALL, translated like any other call for now; to be used to mark a call which never returns, ie the error builtin 2012-12-19 20:38:32 +01:00
Rudolf Polzer
acf4da9385 Fixes for some minor bugs clang-analyzer and cppcheck found
Signed-off-by: Dale Weiler <killfieldengine@gmail.com>
2012-12-18 16:54:51 +00:00
Wolfgang (Blub) Bumiller
2a61a65ce0 -fperl-logic now doesn't allow logic ops with operands of different types, but therefore uses the correct output type 2012-12-18 16:56:22 +01:00
Dale Weiler
4b3e2571af Cleanups of compiler option configuration. Added ini/cfg parser system as well. 2012-12-18 04:57:17 +00:00
Wolfgang (Blub) Bumiller
68e4fb87d8 Fixed a bug in the generation of default switch cases: they can now fall through correctly 2012-12-17 17:01:07 +01:00
Wolfgang (Blub) Bumiller
ac18d58ffc Copy over the array-count in ast_type_adopt/ast_type_copy 2012-12-17 16:00:08 +01:00
Wolfgang (Blub) Bumiller
c2857a22e3 Let's still initialize the 'count' member... 2012-12-17 16:00:08 +01:00
Wolfgang (Blub) Bumiller
eab1050ba4 Fix: check error before calling codegen_output_type 2012-12-17 15:43:14 +01:00
Wolfgang (Blub) Bumiller
f9b1d057b5 Moving all the global opts_ variables into a struct, now there's one global 'opts' struct 2012-12-06 13:23:53 +01:00
Wolfgang (Blub) Bumiller
94560d1873 -Ominor -> -Opeephole; added -Olocaltemps flag; using a less space-wasting temp-allocation in general 2012-12-06 13:08:46 +01:00
Wolfgang (Blub) Bumiller
2eea7b03c0 get rid of some code duplication, and fix some wrong type adoptions in the ast 2012-12-05 16:22:32 +01:00
Wolfgang (Blub) Bumiller
8777624fe2 ast_block_add_expr now lets the block fully adopt the type of the added expression 2012-12-05 12:57:00 +01:00
Wolfgang (Blub) Bumiller
0c8bacd134 ast_ternary_codegen: use codegen_outpu_type 2012-12-04 14:11:49 +01:00
Wolfgang (Blub) Bumiller
6b575372cc Don't warn about uninitialized stuff in accessors - remove the liferanges calculated when finalizing accessors, this would add invalid liferanges to function-local arrays and thus suppress warnings randomly 2012-12-02 18:09:59 +01:00
Wolfgang (Blub) Bumiller
c926c4cb59 Sanity check in ast_generate_accessors 2012-12-02 18:02:44 +01:00
Wolfgang (Blub) Bumiller
02ec45363e Get rid of some code duplication 2012-12-02 17:57:08 +01:00
Wolfgang (Blub) Bumiller
07f4e6309d Some of the output types were superfluous; others are now put into a function to take care of it 2012-12-01 16:39:29 +01:00
Wolfgang (Blub) Bumiller
de837f2380 Add some more output and field types so you can now properly call 'get_a_function_which_gives_a_function()()()' without return values getting lost 2012-12-01 16:11:04 +01:00
Wolfgang (Blub) Bumiller
dfd8f14116 function pointer's output types need to be set for the IR to know 2012-12-01 15:23:40 +01:00
Wolfgang (Blub) Bumiller
d148cfdcd5 bodyless loops still have to loop 2012-11-30 21:34:49 +01:00
Wolfgang (Blub) Bumiller
2a3e7c1cff field constants - revert globals generated after fields 2012-11-30 21:11:25 +01:00
Wolfgang (Blub) Bumiller
316298650e remember if an ast_value is a field-declaration, build fields before globals 2012-11-30 21:03:57 +01:00
Wolfgang (Blub) Bumiller
1a264e5576 additional info in an internal error 2012-11-30 20:40:48 +01:00
Wolfgang (Blub) Bumiller
b3a9c4e8d9 Use the field parameter type on the raw paramter type list for their sizes. 2012-11-30 20:33:40 +01:00