Commit graph

663 commits

Author SHA1 Message Date
Dale Weiler
5f2b7e3d57 fixed vector ops constant folding. 2013-07-31 17:05:43 +00:00
Dale Weiler
d0ee56f25f more fixes 2013-07-31 16:31:45 +00:00
Dale Weiler
fa5ad1212e Operator constant folding rewrite almost complete, just need to track down why two tests are failing. 2013-07-31 15:49:45 +00:00
Dale Weiler
920dbaf1e0 Work in progress constant-folding rewrite. 2013-07-31 09:04:19 +00:00
Dale Weiler
2c975fe48f I'm in a state of confusion as to why constant folding was never done on comparisions, now it is ;) 2013-07-30 17:27:54 +00:00
Dale Weiler
d6ca5673dc Use the _t consistency naming scheme. Also various cleanups. 2013-07-30 16:00:51 +00:00
Dale Weiler
c7679722fb Please the whitespace gods 2013-07-27 11:48:55 +00:00
Dale Weiler
8db9724c5d Revert "Smaller memory footprint, 4/8 bytes vs 12/24 for individual token lex_ctx's. Use to be a 'shallow' copy of the details in lex_file, now it's a pointer to the contents in lex_file."
This reverts commit cddf70f46b.
2013-07-26 16:17:41 +00:00
Dale Weiler
cddf70f46b Smaller memory footprint, 4/8 bytes vs 12/24 for individual token lex_ctx's. Use to be a 'shallow' copy of the details in lex_file, now it's a pointer to the contents in lex_file. 2013-07-26 16:09:26 +00:00
Dale Weiler
44d5481828 There was too many 16-sized buckets when compiling xonotic, increase the size: this is cheaper on memory and slightly faster. 2013-07-26 14:50:37 +00:00
Dale Weiler
764b9abaf4 Cleanups 2013-07-19 11:43:22 +00:00
Wolfgang Bumiller
17318af62f fix typo 2013-07-01 10:37:51 +02:00
Dale Weiler
063c50fce4 More bug fixes and dead code elimination 2013-06-22 01:23:59 +00:00
Dale Weiler
d39fb653aa Fix some more bugs, and use dup2 because dup leaks on some implementations. 2013-06-22 01:14:13 +00:00
Dale Weiler
fe296de42f Fix more bugs (mostly possible NULL pointer dereferences) 2013-06-21 23:26:49 +00:00
Dale Weiler
125d039e3d Fix some bugs 2013-06-21 23:16:00 +00:00
Dale Weiler
82fd7fcf68 Move code generator into ir_builder for earlier free. It's also a much more cleaner design than load parser->code for all ast/ir operations. We also have a proper chain'd design now (so making this a library will be easier). 2013-06-20 10:52:58 +00:00
Dale Weiler
e6c1d66c35 Merge branch 'master' into cooking
Conflicts:
	opts.def
2013-06-17 20:14:26 +00:00
Dale Weiler
7e76b42f11 Merge branch 'master' of github.com:graphitemaster/gmqcc 2013-06-17 20:12:02 +00:00
Dale Weiler
23cb7f4e09 Fix some bugs 2013-06-17 20:11:37 +00:00
Wolfgang Bumiller
f8db5a7c6d reclassify_token should only deal with tokens < TOKEN_START... should fix #113 2013-06-16 09:56:21 +02:00
Wolfgang Bumiller
e6bb7697f9 reclassify_token should only deal with tokens < TOKEN_START... should fix #113 2013-06-16 09:53:11 +02:00
Dale Weiler
82e92811e4 Uhh forgot to save file 2013-06-16 03:46:07 +00:00
Dale Weiler
9a6316221c Fix memleak 2013-06-16 03:45:06 +00:00
Dale Weiler
17ae2dbe4d Make ^ legal for vector ^ vector, and vector ^ float (read the huge comment that explains why and what this does). Currently only works for constants (don't know how to do expression for multiple vector components yet). 2013-06-16 02:17:29 +00:00
Dale Weiler
5694c77d16 I added it for a reason, because I was smart. I forgot about it because of life :( 2013-06-15 11:04:08 +00:00
Dale Weiler
0c58509417 This is easier 2013-06-15 09:53:12 +00:00
Dale Weiler
202fc67f93 Correct order 2013-06-15 09:52:22 +00:00
Dale Weiler
b9cf1f1262 Fix bug 2013-06-15 09:50:02 +00:00
Dale Weiler
a8fddbb7d3 Implemented bitwise xor operator. 2013-06-15 09:48:40 +00:00
Dale Weiler
04406b191f Less terse, it confuses people. 2013-06-15 08:56:34 +00:00
Wolfgang Bumiller
290d065a79 again with the comments... 2013-06-15 09:49:15 +02:00
Wolfgang Bumiller
179da9241c working on vararg piping: detecting several error cases, adding -Wunsafe-types and -funsafe-varargs 2013-06-15 09:46:44 +02:00
Dale Weiler
7115176c0e Strlen idiot 2013-06-15 07:42:01 +00:00
Dale Weiler
fee7794789 Limit corrections on strings to <= 16 bytes. Otherwise memory usage spikes instantly on errors, and causes Windows DEP to kill gmqcc. 2013-06-15 07:40:42 +00:00
Dale Weiler
5012616cb0 Limit corrections on strings to <= 16 bytes. Otherwise memory usage spikes instantly on errors, and causes Windows DEP to kill gmqcc. 2013-06-15 07:39:36 +00:00
Dale Weiler
8afd373e4f Fixed whitespace 2013-06-14 21:36:16 +00:00
Dale Weiler
17fd017d6f Revert "Actually works now"
This reverts commit daa1487aef.
2013-06-13 22:23:07 +00:00
Dale Weiler
daa1487aef Actually works now 2013-06-13 22:20:17 +00:00
Wolfgang Bumiller
f023b7097f fix pedantic compile issue 2013-06-12 16:04:40 +02:00
Wolfgang Bumiller
2c59385633 fixing double-free in initialzied string arrays, using them in the testcase 2013-06-12 15:53:07 +02:00
Wolfgang Bumiller
8ce331b563 allow array size to be inferred from the initializer 2013-06-12 15:47:11 +02:00
Wolfgang Bumiller
633d2ba8a4 make the ast use the initlist 2013-06-12 14:36:59 +02:00
Wolfgang Bumiller
7a36a8bdd8 parsing array initializers 2013-06-12 14:32:12 +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
b2348e1de0 remove the ast tree earlier - saves over 3% peak memory usage 2013-06-02 12:35:53 +02:00
Wolfgang Bumiller
d85e86141c fix a leak on a parse-error 2013-06-01 23:36:05 +02:00
Dale Weiler
062180e9a8 Fix some possible memleaks. 2013-06-01 20:18:53 +00:00
Wolfgang Bumiller
9f2b9e1b46 Merge branch 'master' into cooking 2013-06-01 20:12:27 +02:00
Wolfgang Bumiller
ff63e5bd73 fix the INCLUDE_DEF flag getting applied regardless of dotranslate... 2013-06-01 20:12:14 +02:00
Wolfgang Bumiller
1dce501b70 Merge branch 'master' into cooking 2013-06-01 18:16:56 +02:00
Wolfgang Bumiller
ed585f8c04 fix: dotranslate now sets AST_FLAG_INCLUDE_DEF to not get removed by -Ostrip-constant-names 2013-06-01 18:16:50 +02:00
Wolfgang Bumiller
5aba29006b return assignment factorial test 2013-05-29 16:58:18 +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
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
d45956f55e Fix that memory leak that I spent hours trying to find months ago and didn't succeed at. 2013-05-29 03:35:51 +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
Dale Weiler
e02ebfe486 Result of shift operation on signed integers is bad. 2013-05-29 02:24:12 +00:00
Wolfgang Bumiller
d70b571769 killing the union types 2013-05-11 22:34:01 +02:00
Wolfgang Bumiller
a0fa90ddd5 less confusing 2013-05-07 20:35:20 +02:00
Wolfgang Bumiller
802005f571 be more strict here 2013-05-07 20:13:19 +02:00
Wolfgang Bumiller
c5225b2fa1 fixing a few leaks - code_write doesn't delete the code object anymore, code_cleanup has to be called 2013-05-07 19:56:41 +02:00
Wolfgang Bumiller
8c8ae71d65 changing a few ast_delete to ast_unref in places where the to-be-deleted maybe coming from some other place 2013-05-07 19:39:10 +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
b3e9ef3ad9 an = before an { is also always required when the declared variable is not a function; adding because of planned array initializers 2013-04-26 10:31:38 +02:00
Wolfgang Bumiller
d4f8e4a0dd solve it, not hide it 2013-04-25 19:18:50 +02:00
Wolfgang Bumiller
35692c0b57 Revert "Just fucking initialize everything"
This reverts commit aed2b1031c.
2013-04-25 19:18:11 +02:00
Dale Weiler
aed2b1031c Just fucking initialize everything 2013-04-25 17:11:15 +00:00
Dale Weiler
68ca2c4962 Pushing the -fexpressions-for-builtins stuff and the modff for catching fractional-part builtin numbers. 2013-04-25 17:08:02 +00:00
Wolfgang Bumiller
ce73074d51 this allows builtin numbers to be constant expressions, not just constants 2013-04-25 18:47:54 +02:00
Dale Weiler
9fee84f250 less globals 2013-04-25 12:08:13 +00:00
Dale Weiler
785ab7c072 No more globals for codegen 2013-04-25 09:35:30 +00: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
Wolfgang Bumiller
dcd65f18f8 recognize the simple case of __FUNC__ in the parser 2013-04-24 11:21:10 +02:00
Dale Weiler
8bee9a6819 fix the intrinsic fail 2013-04-24 09:18:24 +00:00
Dale Weiler
dc8523c650 Merge branch 'master' into cooking 2013-04-24 01:46:53 +00:00
Dale Weiler
489ad486bc Get it compiling in visual studio again. 2013-04-24 01:43:53 +00:00
Dale Weiler
10738da2fb Make it compile as C++ code too 2013-04-23 22:50:47 +00:00
Wolfgang Bumiller
f6d554874b initialize the vector member array so that 'cleanup' won't delete uninitialized pointers 2013-04-23 16:54:05 +02:00
Dale Weiler
160e7cf7ee Remove trailing whitespace 2013-04-21 10:24:55 +00:00
Wolfgang Bumiller
46752af74b parser_const_string now uses hashtables; hashtables may want to dup an empty string without it becoming NULL - also replacing ir_strdup with the new util_ one 2013-04-17 18:23:30 +02:00
Dale Weiler
1f0a1b8140 Perliminary parser reworking, required for the proposed multithreading. 2013-04-17 00:52:52 +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
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
cbeac3e5f2 Implemented smart intrinsic / builtin system. When you use trivial math functions like "pow", if they don't exist as a builtin, the compiler will implement its own versions, likewise, if a compiler builtin depends on a function that exists, it will use it, likewise if it doesn't it will implement it. If you explicitally use __builtin_ (prefixed) versions, the compiler again will select the best option it can, be it a combination of both builtins and compiler builtins, all compiler builtins, OR, all builtins (most performant). 2013-03-09 08:53:39 +00:00
Dale Weiler
d8d78f61a7 Implemented "reverse" enum attribute, e.g enum : reverse { A, B, C, D } -> A,B,C,D = 3,2,1,0 2013-03-09 05:07:14 +00:00
Dale Weiler
662612d66f Better diagnostic when "floor" cannot be found. 2013-03-08 09:23:35 +00:00
Dale Weiler
f19adcd1b3 Implemented __builtin_mod, and % operator. Added floor builtin to the standalone executor. Mod works so long as the compiler can find a suitable definition of "float floor(float)", otherwise it prints a diagnostic and gives up (original id1 Quake had floor so we can depend on it). 2013-03-08 09:17:54 +00:00
Dale Weiler
b971ddec3a Implemented concept of enumeration attributes (can be further extended, but currently only "flag" is implemented as an attribute). An enumeration with a flag attribute will act as a "flagged enumeration", one that automatically handles exponentiation of the constants defined inside it, i.e enum : flag { A, B, C }, A,B,C will equal 2, 4, 8. 2013-03-08 08:01:45 +00:00
Dale Weiler
479f3b9343 Implemented __builtin_exp 2013-03-08 03:46:25 +00:00
Dale Weiler
12340a6bd0 Actually generate an ast_call for __builtin_pow for the ** operator, otherwise the operator yeilds a ast_function, making "a ** b" not work, but since it's a function, allows **(a, b). Also added tests for exponentiation operator. 2013-03-07 23:05:40 +00:00
Dale Weiler
d3c7b6fb39 Implement exponentiation operator ** as well as __builtin_pow (used for exponentiation operator). Use of exponentiation operator with constants results in const folded (precomputed at compile time exponentiation), otherwise runtime exponentiation with some clever loops (slow!). 2013-03-07 21:31:19 +00:00
Dale Weiler
eb0e3c2898 Make it compile as C++ code again. 2013-02-06 10:36:27 +00:00
Wolfgang Bumiller
9bc774dcd3 find aliases in parser_find_global instead of parser_sya_operand 2013-02-06 10:55:06 +01:00
Dale Weiler
cb1a6a6a6b Store the ast nodes for aliases 2013-02-06 09:44:23 +00:00
Dale Weiler
1e60bafcdc Aliases to aliases is a bad idea, revert. Added better tests to show unused aliases 2013-02-06 09:28:42 +00:00
Dale Weiler
21e890602d Fix alias bug. Implemented support for aliases of vectors (x, y, z components). Also made aliases corrector resident (e.g alias to vector foo, named bop, indexing bol_x [instead of bop_x] will result in a correction suggestion of bop_x now). 2013-02-06 09:09:47 +00:00