Commit Graph

62 Commits

Author SHA1 Message Date
Jeremiah Orians ae9e700592
Release_1.9.0 2021-10-03 09:34:22 -04:00
Andrius Štikonas 56ee526c4c Implement support for large immediates on RISC-V. 2021-10-03 11:37:03 +01:00
Jeremiah Orians 5e74995c13
Catch truncated function calls and truncated array statements 2021-10-02 22:02:39 -04:00
Jeremiah Orians 0577243444
Fix Problem with global arrays #18 2021-10-02 10:38:04 -04:00
Andrius Štikonas ae48dbd6cb Add riscv64 port. 2021-10-02 11:59:21 +01:00
Jeremiah Orians 7fb9d682ec
Update M2libc to enable RISC-V Development 2021-09-30 20:10:28 -04:00
Jeremiah Orians 745998ac13
Fix global array initialization to allocate the correct amount of memory 2021-06-26 11:58:13 -04:00
Jeremiah Orians 99df87bc0d
Breakup program to reduce complexity and risk of errors 2021-06-26 11:51:54 -04:00
Jeremiah Orians b37dfc7b12
Report proper error message for negative global array values. Thank you melg8 2021-06-26 10:53:45 -04:00
Jeremiah Orians 51dfec1791
Fixed Global buffer overflow in collect_weird_string thanks to Melg8 2021-06-23 18:57:56 -04:00
Jeremiah Orians a3c14bcd1b
Fixed Memory leak, thanks melg8 2021-06-23 07:58:11 -04:00
Jeremiah Orians 8bc09f2b2e
Fixed hang on large global arrays. Thanks melg8 2021-06-23 07:32:40 -04:00
Jeremiah Orians da542698e7
Fix all special cases where line number was wrong 2021-05-28 23:27:17 -04:00
Jeremiah Orians cece07145c
Update checksums to reflect new cc_types.c code in test1000 2021-05-02 10:52:29 -04:00
Jeremiah Orians d80d8a652b
Move more functionality into M2libc 2021-04-03 22:41:52 -04:00
Jeremiah Orians 46cf81af83
Replace file_print with fputs 2021-04-03 18:56:55 -04:00
Jeremiah Orians b0b440c2df
Update M2libc to fix fflushing of buffers at exit or return from main 2021-02-21 21:00:34 -05:00
Jeremiah Orians 5f8484e683
Move self-hosting test to use M2libc 2021-02-17 21:40:59 -05:00
Jeremiah Orians a9d88e8e6c
Add support for -D variable and -D variable=value 2021-02-05 21:34:00 -05:00
Jeremiah Orians 8007ae9ce6
Add support for #if defined(__M2__) to enable M2-Planet specific functionality 2021-02-05 20:39:54 -05:00
Jeremiah Orians 6f8e2eb905
Removed need for fixup 2021-02-02 23:39:27 -05:00
Jeremiah Orians c5068b227a
Add support for &global_variable 2021-01-28 22:22:08 -05:00
Sanne Wouda 0e3d5b609a Add support for global char foo[12]; definitions
- only enabled in --bootstrap-mode

- allocates space for both the char array and the pointer to the start of
  the array
2021-01-10 23:01:08 +00:00
Sanne Wouda 09acd6253d Implement simple macro expansion
- no longer generate CONSTANT lines for #defined constants

- "#define FOO 1" turns "return FOO;" into "return 1;"

- Macros expanding into a macro is not supported:
  #define FOO 1
  #define BAR FOO
  will expand BAR to FOO, not to 1

- Expansion inside #if conditions is not supported.

- Function-like macros are not supported.
2021-01-09 17:39:48 +00:00
Sanne Wouda a8551f2fcd Implement --bootstrap-mode for preprocessor
- // and # lines always appear in the result of read_all_tokens

- in bootstrap mode, // tokens (but not the subsequent lines) and #
  lines are stripped. no preprocessing happens.

- in non-bootstrap mode, // lines are stripped and # lines stay for the
  preprocessing phase

- updates tests to pass --bootstrap-mode when necessary
2021-01-09 17:38:50 +00:00
Sanne Wouda 4550eec19e Extend macro #define support
- now supports #if defined(FOO)
- translation of #define FOO 1 to CONSTANT FOO 1 is still supported
2021-01-08 21:31:43 +00:00
Jeremiah Orians 3c4c09b95e
Added hacky version of #define support 2021-01-06 19:24:16 -05:00
Jeremiah Orians 25fd5e66c9
Another set of segfaults cleared out 2021-01-05 23:22:26 -05:00
Jeremiah Orians bdd4e65580
Catch some basic segfaults 2021-01-05 23:00:58 -05:00
Sanne Wouda 63bb59404d Improve error reporting for unexpected non-newline 2021-01-05 22:56:30 +00:00
Sanne Wouda 49fbe8942f Add error checking for unexpected #endif 2021-01-05 22:56:30 +00:00
Sanne Wouda 89c6513cd8 Add support for conditional inclusion
- support for #if, #elif, #else, #endif, but no macro expansion just
  yet. Any macro is treated as undefined and expands to 0.

for example:
./bin/M2-Planet -E test.c

 #if 1 == FOO
foo
 #else
bar
 #endif

results in

bar
2021-01-05 22:54:30 +00:00
Sanne Wouda cd96f65a23 Add macro directives to token_list
- change the lexer to not remove preprocessor directives
- preprocess() removes any lines starting with a macro directive that it
  doesn't understand (which is currently all of them)
2021-01-05 22:53:39 +00:00
Sanne Wouda 7b8a99db3c Add a preprocessor-only mode
- Very useful for testing and debugging
- Add preprocess() stub and skip compilation in preprocessor mode
2021-01-05 22:53:04 +00:00
Sanne Wouda a18e0c1782 Add newline tokens to parse stream
- needed to determine start and end of macro directives
- the main parser doesn't need them, so strip out the newline tokens
  before parsing to avoid changing it
2021-01-05 22:23:15 +00:00
Jeremiah Orians 921cc86ce6
First generation implemention of typedef 2021-01-02 22:00:02 -05:00
Jeremiah Orians 358b6cfb96
Fix modulus behavior that is wrong.
Thank you janneke
2021-01-01 16:39:27 -05:00
Jeremiah Orians e451abd667
Fix e25c1995aa SCM MES regression 2021-01-01 15:55:34 -05:00
Jeremiah Orians cc1a17a040
Revert "file.c: introduce output buffering for x86"
This reverts commit 5afeb0743e.
2021-01-01 15:28:30 -05:00
Jeremiah Orians c220d14928
Catching some segfaults 2020-12-31 09:53:05 -05:00
Jeremiah Orians e25c1995aa
Make types more proper 2020-12-27 21:51:46 -05:00
Michael Schierl 5afeb0743e file.c: introduce output buffering for x86
Note that this is a backwards incompatible change: Unlike POSIX, exit()
will not flush all open streams, so you are responsible for flushing or
closing all your streams before successful exit.

Also, file.c will now also require calloc.c (and malloc.c).

Updated the test cases accordingly.

Only implemented and tested for x86.
2020-12-21 16:57:17 +01:00
Jeremiah Orians 6fe6f44a29
Make type information localized to the inside of statements 2020-12-19 16:35:33 -05:00
Jeremiah Orians e7a0ecd244
Cleared out non-essential string primitives and added support for --max-string 2020-12-19 09:46:22 -05:00
Jeremiah Orians d9504e3872
Allow M2-Planet to support larger outputs without hitting a segfault 2020-12-19 06:50:11 -05:00
Sanne Wouda 968fdfea65 AArch64 support for unsigned comparison 2020-12-17 00:01:17 +00:00
Jeremiah Orians e5befc4fee
armv7l support for unsigned comparisons 2020-12-15 21:09:26 -05:00
Jeremiah Orians f2cae3d501
AMD64 support for unsigned comparisons 2020-12-15 20:28:04 -05:00
Jeremiah Orians eaf3861954
Fix failing tests on x86 2020-12-15 19:02:32 -05:00
Jeremiah Orians 132e685f97
Fix x86 behavior on unsigned compares 2020-12-15 17:46:45 -05:00