Skip to content
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

Change when tcc build fail, fallback to previous working copy of program instead of blocking #24

Open
Ok23 opened this issue Sep 9, 2021 · 2 comments

Comments

@Ok23
Copy link

Ok23 commented Sep 9, 2021

That behavior allows to edit self code for example through Dear ImGui.

@anael-seghezzi
Copy link
Owner

It's not the same, but you can call a new instance of tcc inside your program like this:
https://github.com/anael-seghezzi/CToy/blob/master/ressources/src/sample/libtcc_hello.c
Meaning you can edit additional code through Dear ImGui.

The behavior you seek is not an easy improvement to do, and could have side effects with symbols and memory.
We would need to store two copies of ctoy__tcc and ctoy__src_path.
Releasing the previous program only after the new one compiles would fragment memory.
And I'm not sure if we can declare two copies of symbols sharing the same names.

@noncom
Copy link

noncom commented Jan 29, 2023

This would be cool! Currently I can think of the following ways to approach this:

  • Maybe it would be possible to create such a shadow copy with all the symbol names changed. For example, the parsing phase could be adding some suffix like "_shadow" to each and every name in the program.
  • It could be spawned in a totally separate process? The separation and cleanup would be much simpler then?
  • A copy could be started as a separate program, probably without the render, and communicated with through network/http.

In cases 1 and 2 the copy would be used only for compilation test and entirely discarded right after that, without even ever running it. If no errors were found -- the real compilation of the same source would then occur.

In general this is much like presentation compilers in IDEs work -- and they serve the exact same purpose -- they are separate "simplified" compilation processes that are used for early detection and presentation of compilation errors, without any claim for anything else.

That, of course, would introduce some complexity which might be not what CToy is about.. but it's tooling, and good tooling is important too.

I'm not as proficient in coding in C, low-level stuff and this toolset though, so these are just wishful guesses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants