Commit Graph

2647 Commits

Author SHA1 Message Date
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
Rangi42
04899a21cd Pass std::string references to parser semantic functions instead of .c_str() pointers
This also refactors some semantic functions to be more efficient
2024-03-18 14:42:05 -04:00
Rangi42
8f77518406 Use std::string for most intermediate parsed strings
This is a work in progress: its performance is unacceptably slow,
and it is obviously not a complete refactoring:

- The parser's semantic functions are still written for C-style
  strings, taking `.c_str()` pointers instead of `std::string`
  references (and using their methods, `<algorithm>`s, etc).
- Quoted string literals from the lexer still use our `String`
  struct, which wraps around a fixed-size char array.
- Symbol values, macro arguments, and so forth are still pointers
  to C-style strings with unclear ownership semantics (i.e. we
  still have "leaks as a feature").
2024-03-18 14:42:05 -04:00
Rangi42
b76e196c89 Run clang-format on everything 2024-03-18 14:08:57 -04:00
Rangi42
d06376c170 Use std::unordered_map and std::vector for sections
This allows us to control the order in which sections are iterated,
instead of it depending on the internals of `std::map`. (This order
is arbitrary, but should be deterministic regardless.)
2024-03-16 11:51:47 -04:00
Rangi42
cefc4f4aa3 Use std::unordered_map for symbols 2024-03-16 11:19:19 -04:00
Rangi42
a14de10e28 Use std::unordered_map for charmaps 2024-03-16 11:13:14 -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
Sylvie
eb99fc8681 Use a std::unordered_map for looking up sections by name (#1357) 2024-03-13 19:45:52 -04:00
Sylvie
8ec0d01fc4 Sort .sym files in ascending order, and test for it (#1355) 2024-03-13 18:32:35 -04:00
Sylvie
658286c8e4 Move a SECTION FRAGMENT test to the test/link/section-fragment folder (#1354)
Add a binary comparison for the same-label SECTION UNION test
2024-03-13 15:34:27 -04:00
Sylvie
a1bbb3b3f7 Strip CI binaries built with make (#1345) 2024-03-13 14:42:11 -04:00
Sylvie
67c707739d Allow multiple identical exported numeric constants (#1341)
This still doesn't allow identical exported label constants.
That can be addressed when or if it's requested for a real use case.

Symbols only store one source filename + line number, so this
arbitrarily keeps the last read symbol as the reported one.
2024-03-13 14:06:20 -04:00
Sylvie
68f6ab5c32 Add test cases for SECTION UNION defining multiple identical labels (#1349)
Exported labels should fail to link; non-exported ones should be okay.
2024-03-13 13:34:44 -04:00
Rangi42
188fcfdd64 Add license header to test/CMakeLists.tst like the rest 2024-03-13 11:55:17 -04:00
Sylvie
4f15f07dd4 Refactor link/test.sh to avoid repeating test names (#1353) 2024-03-13 11:43:50 -04:00
Eldred Habert
08066d4692 Fix a reference being used after being invalidated (#1352)
Your classic use-after-free bug.
2024-03-12 22:19:01 -04:00
ISSOtm
42d32c72a6 Use a unique name to upload W32/W64 binaries in CI
This now breaks in CI.
2024-03-13 01:07:28 +01:00
ISSOtm
81ed5fe41e Update Actions to Node 20
There are some warnings in CI about this.
2024-03-13 00:15:43 +01:00
ISSOtm
b9596890c9 Disable a Clang warning
Fixes `make develop` with Clang 17.
The warning only triggers on the auto-generated `yynerrs_` in `src/asm/parser.cpp`,
so it's not very useful to us right now.
2024-03-13 00:04:11 +01:00
Rangi42
846a9411b9 Refactor FileStackNode::dump to not need a helper function 2024-03-10 14:14:34 -04:00
Rangi42
58fdaa8747 Avoid a couple of clang-format quirks 2024-03-10 12:31:03 -04:00
Sylvie
820f6b5b3c Consistently format type qualifiers like const on the right (#1347) 2024-03-10 12:21:52 -04:00
Rangi42
d982d47c56 Use move semantics for more parsed values 2024-03-09 20:05:09 -05:00
Rangi42
569b940b82 No need to manually do the Expression destructor's job 2024-03-09 19:33:53 -05:00
Rangi42
ba104baf3e Refactor mapFile for Windows 2024-03-09 19:22:06 -05:00
Rangi42
cce7f51235 Remove RPN symbol name length limit 2024-03-09 17:56:30 -05: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
3323cb56fe Make enum patterns more explicit (#1343) 2024-03-09 14:55:17 -05:00
Sylvie
5681be1fd8 Use automatic allocation and std::move for RPN bytes (#1336) 2024-03-09 11:12:34 -05:00
Sylvie
4a7d333891 Use std::unique_ptr for rgblink sections (#1337) 2024-03-09 11:12:01 -05:00
SnDream
9890cf25b4 Fix -O being always ignored (#1339)
The file isn't opened at this point, it's the file name that should be inspected.
2024-03-09 14:11:56 +01:00
Rangi42
9f5bf5e285 Remove an unnecessary .close() call that the destructor handles 2024-03-08 22:29:37 -05:00
Rangi42
0bfade4435 Fix enum: REG_SP == REG_AF == 3 2024-03-08 20:00:29 -05:00
Rangi42
40704b5055 Remove unused yyerror declaration
Also reformat some `enum`s
2024-03-08 19:47:57 -05:00
Sylvie
53537cf9af Remove now-unnecessary enum keyword (#1338)
C++ does not need it
2024-03-08 19:40:41 -05:00
Rangi42
1b97297d63 Fix a typo bug in sdas_obj.cpp
This was introduced in commit 447c561, PR #1330
2024-03-08 18:30:30 -05:00
Rangi42
75cc12bb3d Use std::optional for fstack paths 2024-03-07 21:41:02 -05:00
Rangi42
563d699394 Avoid an extra operation if !labelScope (thanks, ISSOtm) 2024-03-07 17:33:33 -05:00
Rangi42
e701faa1bc Print summaries at the end of test.sh scripts 2024-03-07 16:45:53 -05:00
Rangi42
aed172071b Replace some macros with static functions or constants 2024-03-07 16:10:05 -05:00
Rangi42
90356ee669 Remove unused #define 2024-03-07 15:07:16 -05:00
Rangi42
0a4a01c5e5 Ignore callgrind output files 2024-03-07 14:56:32 -05:00
Rangi42
0f52cd0bab Use std::reverse for binary digits 2024-03-07 14:48:23 -05:00
Rangi42
2fd95381a6 Get rid of some fixed-size char buffers 2024-03-07 14:36:30 -05:00