Skip to content

Compiler: move c2_trace functions to libs/c2/c2_trace.c2 #314

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chqrlie
Copy link
Contributor

@chqrlie chqrlie commented Jun 30, 2025

  • add c2_trace.c2 source module in libs/c2 (will later incorporate all
    libs/c2 files in an internal embedded library
  • fix stack overflow on recursive inline functions
  • generate call tracing tables in c2_trace_tables.c for fast builds

Fix external array definitions:

  • accept array definitions without length in interface files
  • reject elemsof on arrays of unknown length
  • fix external array definitions in C generator
  • fix test/interface/incremental_array.c2t: fix external array definition
  • fix test/interface/public_by_array_expr.c2t: fix external array definition
  • fix test/interface/muti_dimensional_array.c2t: Row and Columns definitions
    were reversed, 2D external array definition in C was incorrect

@bvdberg
Copy link
Member

bvdberg commented Jul 1, 2025

This patch seems to combine 2 things:

  • arrays in c2i files
  • c2trace refactoring

There is a couple of things i think should change:

  • c2trace is now part of libc, with has nothing to do with it
  • tracing is now everywhere, in the parser, analyser and generator (it used to be only generator)
  • it adds more exceptions (if-statements) for tracing

Overall I think we need some other mechanism to write 'internal' code. Writing this is a c2 file is much better,
than writing it in (raw-)strings. This code should be compiled in IMO, since I dont want the c2c binary to need
internal stuff after compilation. I'll give this some thought..

@chqrlie chqrlie force-pushed the c2trace branch 2 times, most recently from 8bc6b64 to ab9fc0b Compare July 2, 2025 09:42
@chqrlie chqrlie changed the title Compiler: move c2_trace functions to libc/c2trace.c2i Compiler: move c2_trace functions to libs/c2/c2_trace.c2 Jul 2, 2025
@chqrlie
Copy link
Contributor Author

chqrlie commented Jul 2, 2025

I simplified the port: the source module libs/c2/c2_trace.c2 is added to the target if tracing is enabled and the tables are generated in another module c2_trace_tables for which an interface file is added to the c2 library.

I had to fix the C generator for extern tables as these do not really decay to pointers. (further simplifications pending). I split this into a separate PR to be merged first and separately.

I shall add a way to incorporate the c2 library files in the c2c compiler once the assert and string switch code is moved to c2.

@chqrlie chqrlie force-pushed the c2trace branch 6 times, most recently from 4e5d613 to 367ad67 Compare July 6, 2025 08:38
* add c2_trace.c2 source module in libs/c2 (will later incorporate all
  libs/c2 files in an internal embedded library
* generate call tracing tables in **c2_trace_tables.c** for fast builds
@chqrlie
Copy link
Contributor Author

chqrlie commented Jul 6, 2025

I just rebased this PR on the latest master. It should be ready to merge now!

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

Successfully merging this pull request may close these issues.

2 participants