Commit Graph

55 Commits

Author SHA1 Message Date
Rangi42
912a1504ec Defer closing of depend file 2024-03-27 11:44:26 -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
Sylvie
a68bebf4a2 Use a Defer struct to close files and restore lexer state with RAII (#1379) 2024-03-27 10:42:53 -04:00
Rangi42
cb59119881 Use automatically-allocated std::string_view for macros 2024-03-25 11:33:17 -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
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
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
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
554778da5b Built-in symbols are "<builtin>", not "<command-line>" (#1362) 2024-03-19 16:01:45 -04:00
Rangi42
40db9d5cef Use std::string for lexer state paths 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
b76e196c89 Run clang-format on everything 2024-03-18 14:08:57 -04:00
ISSOtm
e4a3509845 Fix build failure with GCC 13
It complains about *those* calls returning a dangling reference...
Unfortunately, GCC does not provide more information about what the
reference *is*. (It only mentions the temporary being destroyed at
the end of this *huge* expression.)

I am normally not one to just commit a thing that gets rid of a
warning if I can't explain why, but this eludes me.
Stubbing out the calls to only return a captured variable still
complains, which led me to test that the error wasn't stemming
from the `Visitor` itself... which it seems to?
But I don't see why a reference to the *visitor* should be kept...

Anyway, here is the obligatory part where I state my yearning for Rust :)
2024-03-15 21:40:11 +01: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
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
Rangi42
75cc12bb3d Use std::optional for fstack paths 2024-03-07 21:41:02 -05:00
Rangi42
2fd95381a6 Get rid of some fixed-size char buffers 2024-03-07 14:36:30 -05:00
Rangi42
097b7c3baf Use std::string for symbol names 2024-03-07 12:40:33 -05:00
Rangi42
bd88787cb3 Use FileStackNode constructor to avoid std::monostate possibility 2024-03-05 14:22:29 -05:00
Sylvie
e74073e480 Run clang-format on everything (#1332) 2024-03-04 14:22:49 -05:00
Sylvie
b004648a13 Use std::variant for symbol values (#1331) 2024-03-04 08:55:33 -05:00
Rangi42
277ea9be28 Replace RGBASM non-null pointers with references 2024-03-03 00:57:03 -05:00
Sylvie
a71e4086a2 Use std::string_view for macro bodies (#1326)
This removes the last use of `strdup`

This required making a lot of related pointers be `const`.
That in turn conflicted with the need to `munmap()` a pointer
eventually, which was similar to the need to eventually `free()`
an `Expansion`'s contents, so I used the same solution of a
`union`. That lets us normally use the `const` pointer for
`const` correctness, and the non-`const` one for the not-really-
mutating destruction cases.
2024-03-02 13:21:28 -05:00
Rangi42
2069a95e0f Use std::string for macro args 2024-03-02 05:23:15 -05:00
Sylvie
1ac3c0262f Refactor structs to use methods instead of functions (#1322) 2024-03-01 13:11:45 -05:00
Rangi42
e14ba664ea Remove redundant (void) parameter declarations 2024-03-01 10:41:47 -05:00
Sylvie
043db49676 Replace NULL with nullptr (#1321) 2024-02-29 15:06:33 -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
d1fa5ccd4d Rename lexer_DeleteState to lexer_CleanupState 2024-02-29 13:44:08 -05:00
Rangi42
d6681d3580 struct Section's src can be const 2024-02-29 13:44:08 -05:00
Rangi42
c3eb532439 Use copy constructor for file stack node 2024-02-29 13:44:08 -05:00
Rangi42
0bed84174b Use std::string for FOR loop variables 2024-02-29 13:44:08 -05:00
Rangi42
31836967fa Use automatic allocation for lexer states
Lexer states are now owned by fstack contexts
2024-02-29 13:44:08 -05:00
Rangi42
cf42d035f2 Use std::variant for file stack nodes 2024-02-29 13:44:08 -05:00
Rangi42
4b2294292a Use std::string for target file name 2024-02-29 13:44:08 -05:00
Rangi42
0e19f6c0ae Use automatic allocation for fstack nodes' iters/names 2024-02-29 13:44:08 -05:00
Rangi42
e98d1efee3 Use std::vector for include paths 2024-02-29 13:44:08 -05:00
Rangi42
e4764e37b1 Use std::stack for fstack contexts 2024-02-29 13:44:08 -05:00
Rangi42
1afc8554c0 Use std::deque for file stack nodes 2024-02-29 13:44:08 -05:00
Sylvie
b66212e6d6 Fix fstack traces for macro nodes (#1318)
Since the lexer rewrite, MACRO nodes' fstack traces have not
included their parent REPT nodes' names.
2024-02-24 20:23:25 -05:00
Sylvie
c0d534f5ad No more flexible array members (not standard C++) (#1307)
* Replace FAMs with `std::vector`s (or one `std::string`) in four `struct`s

* Anonymous types declared in an anonymous union are also non-standard
  Only Clang complains about this (-Wnested-anon-types)
2024-02-22 16:22:37 -05:00
Sylvie
6d29d2a67e Simplify fstk_FindFile usage (#1310)
* Simplify `fstk_FindFile` usage

* Use `std::string` for `fstk_FindFile`
2024-02-22 13:14:38 +01:00