Commit Graph

47 Commits

Author SHA1 Message Date
Sylvie
c1c5b10082 Deprecate LDH with $00-$FF (#1575) 2024-12-10 21:27:37 -05:00
Sylvie
b877c81c32 Use C++-style casts (#1576) 2024-12-09 21:56:54 -05:00
Sylvie
bc5a71ff88 Update some RGBLINK error messages (#1544) 2024-10-16 01:42:49 +02:00
Rangi42
6bc2446966 Rephrase error messages for consistency 2024-09-10 21:38:50 +02:00
Sylvie
323028d9f2 RGBLINK lists local symbols when encountering an unknown symbol reference (#1496) 2024-09-06 21:31:13 -04:00
ISSOtm
8286d9c462 Check that there is enough room to write a patch when linking
Prevents segfaulting if a patch's offset is too large
2024-08-26 22:58:38 -04:00
Sylvie
57c3d74b9e Use a custom generic tagged union Either instead of std::variant for efficiency (#1476)
* Implement custom generic tagged union `Either`

This should be more efficient than `std::variant`, while still
keeping runtime safety as it `assert`s when `get`ting values.

* Use `Either` for RPN expressions

* Use `Either` for file stack node data

* Use `Either` for `File` buffer

* Use `Either` for `STRFMT` args

* Use `Either` for RGBLINK symbol values

* Support an equivalent of `std::monostate` for `Either`

* Use `Either` for lexer tokens

* Use `Either` for symbol values

* Use `Either` for lexer mmap/buffer state
2024-08-20 21:19:11 +02:00
Sylvie
e93190d491 Implement BITWIDTH and TZCOUNT functions (#1450) 2024-08-07 10:39:30 -04:00
Sylvie
2706f94788 Multiple fixes and enhancements to RPN behavior: (#1448)
- FIX: `Label & const` was not actually doing the `& const` masking
  (fixes #1446)
- ADD: `LOW(Label)` can be constant if `Label` is aligned to 8 or more bits
  (resolves #1444)
- ADD: `!expr` can be constant 0 if `expr` has any non-zero bits
  (resolves #1447)
- `LOW()` and `HIGH()` have their own RPN operator values
  (resolves #1445)

The change to RPN values means that the object file version was incremented.

This also refactors unary operators and functions, combining their
evaluation similarly to binary ones.
2024-08-06 13:54:55 +02:00
Sylvie
3e9d2cab12 Make some error messages more consistent (#1393)
* Update some error messages

* Make non-A destination operand syntactically invalid
2024-04-20 23:13:01 +02:00
Sylvie
a234da42a6 Replace assert with assume for release build optimization (#1390) 2024-04-02 11:09:31 -04:00
ISSOtm
20b7b591d4 Run clang-format
Fix some small style inconsistencies
2024-03-28 01:41:25 +01:00
ISSOtm
e5078aba3b Clean up #includes
Remove unused headers, and avoid relying on transitive inclusions

`include-what-you-use` has been very useful for this!
2024-03-28 01:25:38 +01:00
Rangi42
506911d7d0 Refactor to avoid redundant obj_CheckAssertions function 2024-03-27 16:19:01 -04:00
Sylvie
0af1e512c2 Use std::get_if instead of std::visit (#1367)
`std::visit` is (arguably) cleaner code, but older versions of gcc
and clang (not very old; the ones packaged with Ubuntu 22.04 LTS)
compile them as tables of function pointers, instead of efficient
jump tables.
2024-03-20 22:37:54 -04:00
Sylvie
17444e825a Reduce the header declarations (#1342)
- Since we have style rules to include foo.hpp at the top of its
  corresponding foo.cpp, this takes any headers included by foo.hpp
  as being also guaranteed for foo.cpp.

- Use C-style <foo.h> instead of <cfoo>, since the latter only
  guarantees putting symbols in the `std` namespace, which we are
  not using for C functions (e.g. `printf` not `std::printf`).

- Remove now-unused `__PRETTY_FUNCTION__` reporting
2024-03-09 14:55:39 -05:00
Sylvie
4a7d333891 Use std::unique_ptr for rgblink sections (#1337) 2024-03-09 11:12:01 -05:00
Sylvie
53537cf9af Remove now-unnecessary enum keyword (#1338)
C++ does not need it
2024-03-08 19:40:41 -05:00
Rangi42
aed172071b Replace some macros with static functions or constants 2024-03-07 16:10:05 -05:00
Sylvie
e74073e480 Run clang-format on everything (#1332) 2024-03-04 14:22:49 -05:00
Rangi42
f2c875e71e Avoid using std::get except in holds_alternative-asserting accessors 2024-03-03 23:33:23 -05:00
Sylvie
447c561aaa Use std::variant for symbol values (#1330) 2024-03-03 21:16:36 -05:00
Rangi42
930a5c3e44 Replace RGBLINK non-null pointers with references 2024-03-03 00:57:03 -05:00
Rangi42
52f8ecc347 We do not call malloc/free any more 2024-03-02 08:16:44 -05:00
Rangi42
e14ba664ea Remove redundant (void) parameter declarations 2024-03-01 10:41:47 -05:00
Sylvie
eff8c324c8 Remove now-unnecessary struct keyword (#1320)
C++ acts like structs are `typedef`ed by default

We do have to keep `struct stat`, since there's ambiguity
with the function also called `stat`.
2024-02-29 14:41:58 -05:00
Rangi42
2ff723f943 Use vec.data() instead of &vec[0]
In general `vec.data()` is always safe, whereas `&vec[0]`
may fail when `vec` is empty.
2024-02-29 13:44:08 -05:00
Rangi42
96f354026a Use automatic allocation for section data 2024-02-29 13:44:08 -05:00
Rangi42
002eed405b Use automatic allocation for assertion error messages 2024-02-29 13:44:08 -05:00
Rangi42
ef1c1440a0 Use automatic allocation for symbol names 2024-02-29 13:44:08 -05:00
Rangi42
5a26a48d11 Use automatic allocation for section names 2024-02-29 13:44:08 -05:00
Rangi42
3c0af94c5c Use automatic allocation for patches 2024-02-29 13:44:08 -05:00
Rangi42
48b2e94aa3 Use std::string for symbol/section/node names and assertion messages 2024-02-29 13:44:08 -05:00
Rangi42
52ac98c294 Use std::vector for section data 2024-02-29 13:44:08 -05:00
Rangi42
4cd88ade54 Use automatic allocation for object file symbols 2024-02-29 13:44:08 -05:00
Rangi42
f47ce337bf Use std::vector for reading object file symbols 2024-02-29 13:44:08 -05:00
Rangi42
5075ac8887 Use std::vector for RPN expressions 2024-02-29 13:44:08 -05:00
Rangi42
d792ee4b61 Use std::vector for section patches 2024-02-29 13:44:08 -05:00
Rangi42
a5ea25cde5 Use automatic allocation for RPN stack 2024-02-29 13:44:08 -05:00
Rangi42
26a93a530b Use std::deque for assertions
Also fix a memory leak
2024-02-29 13:44:08 -05:00
Rangi42
f44701c02d Use std::map for rgblink symbols and sections 2024-02-29 13:44:08 -05:00
Sylvie
54d6a22d19 Build with pedantically standard C++ (#1309)
* Remove array designators (not standard C++)

* Build with pedantically standard C++
2024-02-23 16:46:53 -05:00
Sylvie
d71a161bc9 Phrase error messages as "Failed to", not "Could not" or "Couldn't" (#1298) 2024-02-18 14:52:31 +01:00
Rangi
6132b77c1e Add more tests for RGBASM code coverage (#1257)
* Add more tests for RGBASM code coverage

* Use C++ unnamed parameters, not `(void)` casting

* Fix crash in `sect_AlignPC` from #1253
2023-12-01 10:21:43 -05:00
Rangi
a218622d73 Remove checkpatch, since it's tuned for C not C++ (#1250)
Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
2023-11-22 19:26:08 +01:00
Rangi
dde9f2bb79 Rename some RPN constants for consistency (#1230) 2023-11-08 21:30:27 +01:00
Rangi
1e70e703a7 Build everything as C++ (#1176) 2023-11-07 21:45:56 +01:00