Commit graph

555 commits

Author SHA1 Message Date
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
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
Dale Weiler
6fc141733f Support for aliases to aliases too. 2013-02-06 08:43:11 +00:00
Dale Weiler
060bc0be10 Some sanity checks for aliases (undeclared variable checks, and incompatible types in alias checks.) 2013-02-06 05:51:05 +00:00
Dale Weiler
3dc8e9bb9c add todo 2013-02-06 05:38:34 +00:00
Dale Weiler
e464cc1ea6 Implemented generalized attribute aliases. You can now alias functions, locals, or globals with [[alias("old_name")]] type new_name; 2013-02-06 05:30:09 +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
Dale Weiler
e2c424d607 Merge branch 'cooking' of github.com:graphitemaster/gmqcc into cooking 2013-02-05 16:35:12 +00:00