-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LUA+macro] Defining same labels inside differently named modules #120
Comments
Never mind this for now - I forgot that I need to do LUA PASS1 when defining a function, in which case it works. Nevertheless, I believe there's still some similar bug regarding LUA and labels, which is affecting some of my own code. I'll see if I can narrow it down to a reasonable example. Edit: alright, I think I have one. I've edited the OP and reopened it. |
I see... this is technically "by design", although it looks a bit confusing at first sight. Docs in macro chapter:
This is actually higher priority than module/etc, i.e. in macros the "local labels" are like new class of local labels... "macro local labels" ... :) And the regular "local labels" are not accessible from macros (to define one, you can access them in expression to evaluate their values). To get the label you expect (?)
I don't see any particularly meaningful workaround in your case (also it depends a lot what you expect from that line And I don't see any obvious fix (the current design have its own purpose and inner logic, covering different kind of use cases where the same macro is emitted multiple times and where macros are nested). I think I can add module name within the macro-local-labels without any harm to current design (ie. your example would produce Maybe more meaningful "fix" would be to make these macro labels explicitly separate class, i.e. they would be defined with other prefix, not dot... maybe |
Yep - I realized it might've been something similar some time after. Somewhat disappointing. The macro temp labels feature is great, but having them outright replace one kind of regular labels is frankly an awful decision. I hope this changes in the future. This example comes from a loader maker system, and it's how it includes various components of itself. It can build images for several different formats at once, differing mostly by the 'runtime' component of the loader, and/or the ORG to which it is compiled. The reason for using modules is exactly that: to avoid label clashing (the modules are named after the image formats, e.g. ls_loader_tap, ls_loader_scl and so on). I can accomodate for the local label issue in my own code, but the problem is that one of the included files is an unpacker, which is logically not part of the loader source but rather 'third party code', so there can be anything in it, including local labels. I think in my situation it would help even if you just add module names to temp.label names ( |
Yep, I can imagine assembler where it would be defined like that, but it would probably need more time arguing and figuring out how to define it well, but it also sounds like something what would not work very well with current sjasmplus architecture. That parser code is any way good candidate for rewrite (as the mkoloberdin did in sjasmplus/sjasmplus fork), but that's quite a big task, and the instant benefits are tiny (the current 1.17.0 is already solid tool in terms of doing its job, even if the source code is sometimes questionable). But long-term it would be nice to clean the main parser architecture, then things like idea above would be open for discussion, right now I'm not even sure how the include inside macro works, I mean I spent some serious time fixing the original code to at least work as intended, but it still feels to me quite hack-ish in this regard, so it's sort of nice surprise this works so well and the files are included and assembled.
I will take a look on that, but it will be still in form About the loader use case: still too little info to discuss it seriously, but just a dumb question.. maybe avoid macros and use lua or explicit code + includes, so when the unpacker source is included, that's not happening inside macro instancing, but as regular code include... Or if the different modules are not used together, like producing different platform targets, then I would rather build each platform separately, doing multiple assembling steps (using probably some |
I would appreciate that!
Mostly ease of use. I think of it as mainly using macros that just might sometimes use LUA in them if needed. It's possible to write |
note to explore: since 1.18.0 there is exclamation mark to prevent main label to redefine the current main-prefix for following local labels (matching the syntax of current sjasm). Maybe it could be extended to work with local-macro labels to change expansion not to macro-instance prefix, but current main label prefix, as if spawned outside of macro. TODO:
|
So it turned out the original sjasm 0.42 has now extra syntax to create non-macro local label from inside macro, see #84 for details or check the test file listing how the new syntax works macros/local_labels.lst test I still didn't check your original zip and whether this new feature does cover your original issue. I don't remember much about this ticket, if you would be kind enough to learn about this new syntax, and see if it can be used to resolve your original issue, and refresh this issue with new details, I would be very thankful. (please add fresh info here then, if it does apply or not, or let me know if you can't check it at all. Or close the ticket if the new feature covers it completely. Thank you.) |
But you expect me to remember these details after a year. Hah! :) Anyway, the issue can be summed up as follows:
A syntax to create regular local labels is a good thing, but that alone doesn't help here. I can see a couple of options that could help: It's up to you what to do with this information. :) |
uff... it always surprises me the INCLUDE inside macro even works... I will not even take a look how that works and what it does internally... :D Ok, the 1) other mode for include inside macro - my first instinct is just "no", will re-check and think about reasons, but I'm almost sure that's not a good idea.
|
I took a look into this, and the internal code is too complex and convoluted to simply switch off local macro labels into regular local labels. Not going to try to implement it now. |
issue cleanup notes: Keeping this around tagged as v2.x just in case I would consider refactoring the whole parsing system, to think also about this use case and make sure it is implemented better than now. |
Hello,
There's a problem with defining same labels inside differently named modules when using LUA blocks inside macros. See the attached example (compile lua-modules-local-labels.asm).
Particularly, it complains about duplicated local labels, which is also the case in my main code, but in this example there are also errors about labels having different values and so on.
lua-modules-local-labels.zip
The text was updated successfully, but these errors were encountered: