Commit graph

358 commits

Author SHA1 Message Date
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
Wolfgang (Blub) Bumiller
6fc00e523d All ir_instrs now get their lex-context, so that we can create an LNO file with -flno 2012-11-30 18:20:02 +01:00
Wolfgang (Blub) Bumiller
bda5ff4213 update other value/const check for array indexing 2012-11-30 16:28:09 +01:00
Wolfgang (Blub) Bumiller
696a8629b3 Don't treat initialized non-consts as static array indices 2012-11-30 16:25:18 +01:00
Wolfgang (Blub) Bumiller
9f1aa1490a out-of-bounds indexing check on static array indexing 2012-11-30 16:23:34 +01:00
Wolfgang (Blub) Bumiller
600ecda860 Set the full const/var qualifier; only generate warnings about unimplemented functions if they have no qualifier at all 2012-11-30 14:05:25 +01:00
Wolfgang (Blub) Bumiller
5e23e8296d don't just store a 'bool constant' in the ast/ir, store the complete qualifier: 'int cvq', moved CV_ defines into gmqcc.h 2012-11-30 13:47:28 +01:00
Wolfgang (Blub) Bumiller
39b8d8431c Actually generate the missing return instruction 2012-11-30 12:35:33 +01:00
Wolfgang (Blub) Bumiller
9841bc2f0d ast_loop with no condition and no incrementor are 'for(;;)' and need to loop endlessly instead of once... 2012-11-30 12:28:51 +01:00
Wolfgang (Blub) Bumiller
42376513e7 Still need to generate the jump... 2012-11-30 12:23:27 +01:00
Wolfgang (Blub) Bumiller
a19849099c ast_ifthen will not create dead blocks anymore 2012-11-30 12:21:10 +01:00
Wolfgang (Blub) Bumiller
a58061464e actually removing -Wmissing-return-values from parser.c and enabling the ast code for it 2012-11-30 12:11:36 +01:00
Wolfgang (Blub) Bumiller
8e1ce2ab5e generic compile_error/compile_warning functions in con.c, issuing end-of-non-void warning from within the ast now 2012-11-26 16:12:40 +01:00
Wolfgang (Blub) Bumiller
ec2ff09eff operator &~= must not cause the generated binstore to free the destination twice 2012-11-26 00:15:07 +01:00
Wolfgang (Blub) Bumiller
1c9de6763f Same as earlier: remember the outgoing block of a condition in a ternary since it could be different due to shortened logic 2012-11-25 23:54:15 +01:00
Wolfgang (Blub) Bumiller
bf244fc960 ast_breakcont_codegen: error when a target is missing instead of segfaulting trying to access it anyway 2012-11-25 23:51:39 +01:00
Wolfgang (Blub) Bumiller
0564e701c0 endlessloops don't have any other block which could be a continue-target-block, so use the body itself to not continue to NULL 2012-11-25 23:50:42 +01:00
Wolfgang (Blub) Bumiller
23e0637e85 ir_function_create_block now takes a lex_ctx instead of copying from the function; ast_ternary: need to remember the _end_ block of the 2 expressions because that's where the jump is actually supposed to be 2012-11-25 23:48:29 +01:00
Wolfgang (Blub) Bumiller
d70fcdec42 don't set the request-Lvalue flag for an array index 2012-11-25 23:35:49 +01:00
Wolfgang (Blub) Bumiller
7c241da548 more verbose errors in the ast when an ir-create fails 2012-11-25 23:32:10 +01:00
Wolfgang (Blub) Bumiller
0301ea7818 Don't error about creating an unreachable statement if the node we're about to generate is an ast_label 2012-11-25 21:59:57 +01:00
Wolfgang (Blub) Bumiller
24f9b63475 parsing goto 2012-11-25 21:53:14 +01:00
Wolfgang (Blub) Bumiller
f431b7a693 Support codegen of ast_label and ast_goto in any order 2012-11-25 21:40:26 +01:00
Wolfgang (Blub) Bumiller
474d8bd6f0 ast_label, and labels later used for goto 2012-11-25 21:27:14 +01:00
Wolfgang (Blub) Bumiller
39f572fe99 constant flag, -finitialized-nonconstants to turn initialized globals into mutable variables 2012-11-25 19:35:00 +01:00
Wolfgang (Blub) Bumiller
6e400ca81f ast: isconst->hasvalue, const keyword will set the const flag 2012-11-25 19:30:10 +01:00
Wolfgang (Blub) Bumiller
ca033e5acd Some side-effect propagation for better warnings, so that comma-operators with assignments in them don't cause the -Weffectless-statement warning, and fixing ternary precedence for fte operator list 2012-11-25 19:19:36 +01:00
Wolfgang (Blub) Bumiller
613e1e7247 Change the parser to use the hashtable functions 2012-11-25 13:23:37 +01:00
Wolfgang (Blub) Bumiller
5897f0439c A nice internal error 2012-11-23 22:15:17 +01:00
Dale Weiler
46fff99fad ast_binstore_codegen initialize left ir value to null for output left side used for lvalue to prevent clang from warning. Also fixed uninitialized bug in hashtable implementation 2012-11-23 06:26:19 +00:00
Wolfgang (Blub) Bumiller
fafc755274 Fixing up ast_binstore_codegen to handle array updates 2012-11-22 22:42:47 +01:00
Wolfgang (Blub) Bumiller
ed53040907 Fix unused parameters in ast.c 2012-11-22 21:39:30 +01:00
Wolfgang (Blub) Bumiller
55915b5217 initialize some values 2012-11-22 21:10:34 +01:00
Wolfgang (Blub) Bumiller
f719a81e2a Fixing short-logic for 'if': it wanted to add the jump to the wrong block 2012-11-22 20:29:55 +01:00
Wolfgang (Blub) Bumiller
ba9217e576 make ast_function_label also work when -dumpfin is used instead of -dump 2012-11-21 21:59:25 +01:00
Wolfgang (Blub) Bumiller
e20184ae59 ast_ternary needs to adopt the output type 2012-11-21 20:57:00 +01:00
Wolfgang (Blub) Bumiller
be52ca3879 More verbose error for invalid parameter types 2012-11-21 20:53:00 +01:00
Wolfgang (Blub) Bumiller
a7fb45f102 removed phi_out from ast_ternary since we have a place in ast_expression_common for this kind of value 2012-11-21 20:13:31 +01:00
Wolfgang (Blub) Bumiller
268ad7db53 Fix wrong merge_id 2012-11-21 19:55:12 +01:00
Wolfgang (Blub) Bumiller
de5592dfc5 -fperl-logic, off by default, so casting to boolean now 2012-11-21 19:40:11 +01:00
Wolfgang (Blub) Bumiller
ebc6954bf5 casting explicitly to boolean values in early out logic 2012-11-21 19:36:28 +01:00
Wolfgang (Blub) Bumiller
bd1bc0dc59 Actually it's likely... 2012-11-21 17:42:44 +01:00
Wolfgang (Blub) Bumiller
b1425dfcf1 'likely' hint for IFs 2012-11-21 17:37:45 +01:00
Wolfgang (Blub) Bumiller
ca2b414c7c experimental -fshort-logic, currently perl-like - might have to use NOT(NOT(x)) to fix this 2012-11-21 16:08:08 +01:00
Wolfgang (Blub) Bumiller
5c52e817ea Add the missing jump from after the actual last case 2012-11-19 22:17:24 +01:00
Wolfgang (Blub) Bumiller
986d58877f Enter the outgoing block after a switch 2012-11-19 22:08:38 +01:00
Wolfgang (Blub) Bumiller
2a55dd7234 fix bnot_id 2012-11-19 22:06:23 +01:00
Wolfgang (Blub) Bumiller
06ba28f2a0 ast_switch 2012-11-19 21:17:44 +01:00
Wolfgang (Blub) Bumiller
8ac689c03a Error in the ast already about unreachable statements and don't upset the IR 2012-11-19 19:42:25 +01:00
Wolfgang (Blub) Bumiller
ea75003cf4 break and continue support 2012-11-19 19:39:52 +01:00
Wolfgang (Blub) Bumiller
d1640f177f Free the 3 actual vectors, not the first 3 times 2012-11-15 21:40:32 +01:00
Wolfgang (Blub) Bumiller
906f319673 Replaced it all... 2012-11-15 18:32:09 +01:00
Dale Weiler
2e84cc0b41 Use new console system everywhere. 2012-11-15 00:28:46 +00:00
Wolfgang (Blub) Bumiller
b61ae53ecd fix wrong const qualifier 2012-11-13 00:11:07 +01:00
Wolfgang (Blub) Bumiller
d60a76abd1 allowing inexing of array-fields 2012-11-12 23:35:47 +01:00
Wolfgang (Blub) Bumiller
0340a6a6e7 support for ast_entfield nodes with specific output types, fixing array-field instantiating code to print the correct name on error 2012-11-12 22:39:43 +01:00
Wolfgang (Blub) Bumiller
0224de02d5 add an asterror message for ast_entfield_new with a wrong type 2012-11-12 22:33:34 +01:00
Wolfgang (Blub) Bumiller
d959c71be6 genearting field arrays 2012-11-12 20:33:49 +01:00
Wolfgang (Blub) Bumiller
83438d9833 call ir_function_finalize on array accessors otherwise they'll blow up stuff 2012-11-11 23:46:03 +01:00
Wolfgang (Blub) Bumiller
bde2175779 Generating function-local arrays 2012-11-11 23:31:57 +01:00
Wolfgang (Blub) Bumiller
a0b6008c2e fix an uninitialized value 2012-11-11 21:32:04 +01:00
Wolfgang (Blub) Bumiller
a78cdd5366 calling the array setter when required 2012-11-11 21:27:02 +01:00
Wolfgang (Blub) Bumiller
feec2d74ee Fix array-index codegen conditions 2012-11-11 19:02:50 +01:00
Wolfgang (Blub) Bumiller
30d87ee837 get-accessor calling in ast_array_index_codegen 2012-11-11 16:32:59 +01:00
Wolfgang (Blub) Bumiller
1ab303c528 Store accessors in the ast_value for access from within the ast - generate accessors after generating all the globals to not mess up the order of globals in the output 2012-11-11 16:22:09 +01:00
Wolfgang (Blub) Bumiller
7d9568f806 array accessor function genaration 2012-11-11 16:06:27 +01:00
Wolfgang (Blub) Bumiller
25ad091866 ast->ir for TYPE_ARRAY globals 2012-11-11 12:14:44 +01:00
Wolfgang (Blub) Bumiller
a7d3a2d6ea adding opts_max_array_size with a default of 1024, adding some TODO errors for arrays in the AST 2012-11-11 11:09:36 +01:00
Wolfgang (Blub) Bumiller
62d062f860 for arrays, ast_value will contain several ir_values, ir_v will point to the [0] element 2012-11-11 10:51:40 +01:00
Wolfgang (Blub) Bumiller
42b9848375 Locals of type .vector will now also properly generate all 3 locals 2012-11-11 10:13:01 +01:00
Wolfgang (Blub) Bumiller
a27750966f globals of type .vector will now properly generate 3 globals 2012-11-11 10:13:00 +01:00
Wolfgang (Blub) Bumiller
52daf02444 Support in the AST for TYPE_FIELD globals which are no actual fields 2012-11-11 10:13:00 +01:00
Wolfgang (Blub) Bumiller
e143db0cae gcc lost it's magic analyzer and now complains about uninitialized stuff... <sadface> 2012-11-04 11:41:44 +01:00
Wolfgang (Blub) Bumiller
62f55d5155 Error when lvalues are requested where that's not possible 2012-10-30 21:15:42 +01:00
Wolfgang (Blub) Bumiller
bd739528ad ast_call_check_types should not check more parameters than actually available in both the call and the function type - fixes a crash introduced by this on variadic functions 2012-10-29 14:35:50 +01:00
Wolfgang (Blub) Bumiller
f56c5f425a ast_type_to_string function 2012-10-28 20:30:55 +01:00
Wolfgang (Blub) Bumiller
90571a6151 ast_store needs to take over the type of its destination 2012-10-28 20:02:57 +01:00
Wolfgang (Blub) Bumiller
478a9249a0 add error for function parameters of invalid types 2012-10-28 15:44:27 +01:00
Wolfgang (Blub) Bumiller
1fc8c2f697 copy the function context over to its ir_value as well 2012-08-24 19:49:12 +02:00
Wolfgang (Blub) Bumiller
8e990b65f3 Not labeling temps/blocks if opts_dump isn't specified 2012-08-24 18:10:41 +02:00
Wolfgang (Blub) Bumiller
7fec608417 better labelling in ast_function_labeling, this time the number is even printed forward rather than backward... ;) 2012-08-24 18:08:28 +02:00
Wolfgang (Blub) Bumiller
c84830bdee Warna bout unused variables - -Wunused-variable, on by default 2012-08-23 20:25:54 +02:00
Wolfgang (Blub) Bumiller
f9746a59ae it's not the IR's job to fail when a local of the same name is created twice... 2012-08-23 17:22:13 +02:00
Wolfgang (Blub) Bumiller
39a62f495c removing some extra newlines in ast error messages 2012-08-23 17:16:07 +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
426cab1f24 ast_ifthen_codegen: the merge-jumps for an if's branches need to be added to the endblock of the branch, not the beginning 2012-08-21 18:25:41 +02:00
Wolfgang (Blub) Bumiller
a4c6382fa4 more context copies 2012-08-19 20:43:34 +02:00
Wolfgang (Blub) Bumiller
53b9906242 have the ir take over some more context data from the ast 2012-08-19 20:43:04 +02:00
Wolfgang (Blub) Bumiller
1cc3705da4 Don't have the ast's codegen error on missing returns 2012-08-19 20:28:14 +02:00
Wolfgang (Blub) Bumiller
4254845227 same as before for loops: don't try creating a jump if the body ends in a return 2012-08-19 19:45:53 +02:00
Wolfgang (Blub) Bumiller
49cd86e8ed don't try to create jumps in ifs if the block is already done 2012-08-19 19:43:41 +02:00
Wolfgang (Blub) Bumiller
cadf877eb4 provide the context to ir_functions 2012-08-19 19:37:46 +02:00
Wolfgang (Blub) Bumiller
bd64d7d7b4 Automatic prototyping of frame-functions 2012-08-19 19:24:43 +02:00
Wolfgang (Blub) Bumiller
20635c5ae4 ast_type_adopt - ast_entfield now adopts the full type of the field 2012-08-18 20:30:24 +02:00
Wolfgang (Blub) Bumiller
99fe673f0a ast_unary needs to set its type 2012-08-18 20:02:18 +02:00
Wolfgang (Blub) Bumiller
40fe52e665 ast_call: adopt the funciton's return type 2012-08-18 19:37:51 +02:00
Wolfgang (Blub) Bumiller
b7b0fcdc94 ast_return_delete: check if self->operand is actually set before ast_unref-ing it 2012-08-18 18:01:52 +02:00
Wolfgang (Blub) Bumiller
6d84010dc4 ast_return should accept NULL as value to create a simple 'return' without a value 2012-08-18 17:58:38 +02:00
Wolfgang (Blub) Bumiller
e239d2a33b set expression.next to NULL in ast_block_set_type if it won't be set to a new value 2012-08-18 17:46:02 +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
3effcd2342 initialize the ast_expression node in ast_shallow_type properly as well 2012-08-18 16:58:17 +02:00