Commit Graph

403 Commits

Author SHA1 Message Date
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
2f8f99bd94 Implement -Wpurge= (#1443) 2024-08-05 12:50:48 -04:00
Sylvie
f304e1dd7f Implement state file output for RGBASM (#1435) 2024-08-05 12:41:40 -04:00
Sylvie
9a5b3f0902 Implement multi-value charmaps (#1429) 2024-08-04 23:32:08 +02:00
Rangi42
4e0f794c23 More refactoring and renaming 2024-07-26 20:12:51 -04:00
Sylvie
623c3f662c Allow NUL characters in strings (#1405) 2024-06-18 14:26:18 -04:00
Rangi42
39e9315e8a Use a smaller size for the lexer buffer
Large sizes are more efficient when it's actually buffered,
but most of the time `mmap` is used instead, and the extra size
just slows down allocation of lexer states.
2024-05-17 20:59:42 -04:00
Sylvie
e2633d5b66 Use the standard stream buffer size for the lexer buffer (#1396) 2024-05-17 11:02:36 +02:00
Rangi42
b8387427a6 Use consistent RGBDS_<PROG>_<NAME>_HPP header guard convention 2024-04-14 21:50:05 -04:00
Sylvie
1d39e5ed56 Use std::variant for RPN expression value (#1389) 2024-04-01 16:47:15 +02:00
Rangi42
14b72222b1 Remove the deprecated -H/-h/-L/-l options 2024-03-28 17:26:42 -04:00
Rangi42
106e516962 Split the .peek() method into its next-char and lookahead cases 2024-03-28 15:37:25 -04:00
Rangi42
6f74e4fb9c Remove the suboptimal .canPeek() and .peek() methods 2024-03-28 14:49:36 -04:00
Rangi42
83c0634f15 Refactor peekInternal to be a LexerState method 2024-03-28 13:21:28 -04:00
Rangi42
4172d330b9 Refactor BufferedContent and Expansion to have methods
Use a buffer size that is a power of two for fast modulus
2024-03-28 12:57:23 -04: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
ISSOtm
cae7b5dcf6 Use standard attribute syntax instead of IBM __attribute__
Move format attrs to proper standard location

For some reason, GCC 13 is more lax than earlier versions...
2024-03-27 20:01:12 -04:00
Rangi42
912a1504ec Defer closing of depend file 2024-03-27 11:44:26 -04:00
Rangi42
b6039870e5 Remove now-redundant MmappedContent struct 2024-03-27 11:27:34 -04:00
Rangi42
78801e324c Group pointer and size as a ContentSpan struct 2024-03-27 11:27:34 -04:00
Rangi42
bf0cabb3ea Use std::shared_ptr for lexer capture buffers 2024-03-27 11:27:34 -04:00
Rangi42
32db0a0f18 Rename CaptureBody to Capture, and refactor its methods 2024-03-26 12:29:59 -04:00
Rangi42
a167d23d01 Use content-specific destructors for lexer state
Also rename `LexerState` content structs from `*LexerState` to `*Content`
2024-03-26 12:29:59 -04:00
Rangi42
2b44672873 Rename a few variables 2024-03-25 14:22:38 -04:00
Rangi42
cb59119881 Use automatically-allocated std::string_view for macros 2024-03-25 11:33:17 -04:00
Rangi42
d9e5e57e27 Make CaptureBufs be parser values instead of a single static global 2024-03-23 19:44:54 -04:00
Rangi42
e9e8915725 Refactor to keep lexerState and lexerStateEOL static
Also run `clang-format` on everything
2024-03-23 19:14:46 -04:00
Rangi42
6a5518e0c5 Use RAII to unmap or close the lexer states' files automatically 2024-03-22 14:25:36 -04:00
Rangi42
507439bc25 Refactor macro args to be owned collectively by their fstack contexts 2024-03-22 14:25:36 -04:00
Rangi42
b85c5cde8f Use std::shared_ptr for MacroArgs 2024-03-22 14:25:36 -04:00
ISSOtm
e255af9e10 Do not limit strings to 255 characters 2024-03-22 14:25:36 -04:00
ISSOtm
9f239f6dcc Use std::shared_ptr<std::string> for lexed/parsed strings 2024-03-22 14:25:36 -04:00
ISSOtm
412073774c Refactor string-formatting routines to append to an existing string 2024-03-22 14:25:36 -04:00
ISSOtm
52e8e1f9fc Simplify \@ handling by using std::shared_ptr<std::string>
This has been relocated from macro.cpp to fstack.cpp, since both
MACRO and REPT/FOR nodes have their own unique `\@` values.
2024-03-22 14:25:36 -04:00
Sylvie
04405fb444 Use std::shared_ptr for fstack nodes (#1371) 2024-03-22 13:27:21 -04:00
Sylvie
dd43723e20 Use methods for RPN Expression (#1372) 2024-03-22 04:41:04 -04:00
Sylvie
f792580816 Only restore parent context's \@ value if it had one defined (#1366)
This way, if a child context initializes `\@`, the parent won't
reset it. And if the child context did not initialize `\@`,
then resetting it would be redundant.
2024-03-21 19:53:49 -04:00
Sylvie
0300971a17 Fix some header #includes with clangd LSP (#1370)
Co-authored-by: ISSOtm <eldredhabert0@gmail.com>
2024-03-21 15:13:10 -04:00
Sylvie
fec2266dd8 Use std::string for string-formatted values (#1360)
* Use `std::string` for string-formatted values

* Make `formatString` and `formatNumber` be `const`
2024-03-19 07:43:18 +01:00
Rangi42
40db9d5cef Use std::string for lexer state paths 2024-03-18 14:42:05 -04:00
Rangi42
05d79d87f6 Pass std::string references to RPN functions 2024-03-18 14:42:05 -04:00
Rangi42
e96675be03 Pass std::string references to fstack functions 2024-03-18 14:42:05 -04:00
Rangi42
472d1bde06 Pass std::string references to symbol functions 2024-03-18 14:42:05 -04:00
Rangi42
6cabb8c9af Pass std::string references to output functions 2024-03-18 14:42:05 -04:00
Rangi42
7b11c528ef Pass std::string references to section functions 2024-03-18 14:42:05 -04:00
Rangi42
91164ac1b0 Pass std::string references to charmap functions 2024-03-18 14:42:05 -04:00
Sylvie
eb99fc8681 Use a std::unordered_map for looking up sections by name (#1357) 2024-03-13 19:45:52 -04:00
Rangi42
846a9411b9 Refactor FileStackNode::dump to not need a helper function 2024-03-10 14:14:34 -04:00
Sylvie
820f6b5b3c Consistently format type qualifiers like const on the right (#1347) 2024-03-10 12:21:52 -04:00
Rangi42
569b940b82 No need to manually do the Expression destructor's job 2024-03-09 19:33:53 -05:00