From 73495e0d0d483769ae2937868840854c15515eb2 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 12 Jul 2026 17:50:32 +0200 Subject: Fix exporting non-public symbols --- boot/symbol.cc | 18 +++++++++++++++++- include/elna/boot/symbol.h | 13 +++++++++++-- source/cstdio.elna | 14 +++++++------- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/boot/symbol.cc b/boot/symbol.cc index 9052b23..d7ceacb 100644 --- a/boot/symbol.cc +++ b/boot/symbol.cc @@ -457,7 +457,23 @@ namespace elna::boot void symbol_bag::add_import(const symbol_bag& bag) { - this->imports.push_front(bag.symbols); + this->imports.push_front(bag.exported_symbols()); + } + + std::shared_ptr symbol_bag::exported_symbols() const + { + if (!m_exported) + { + m_exported = std::make_shared(symbols->scope()); + for (const auto& [name, info] : *symbols) + { + if (info->exported) + { + m_exported->enter(name, info); + } + } + } + return m_exported; } type inner_aliased_type(std::shared_ptr alias) diff --git a/include/elna/boot/symbol.h b/include/elna/boot/symbol.h index d29587d..e13e842 100644 --- a/include/elna/boot/symbol.h +++ b/include/elna/boot/symbol.h @@ -205,12 +205,12 @@ namespace elna::boot return this->entries.end(); } - const_iterator cbegin() const + const_iterator begin() const { return this->entries.cbegin(); } - const_iterator cend() const + const_iterator end() const { return this->entries.cend(); } @@ -448,6 +448,15 @@ namespace elna::boot * \param bag Symbol bag of another module. */ void add_import(const symbol_bag& bag); + + private: + /** + * Returns a reduced symbol table with exported symbols, computed lazily + * and cached. + */ + std::shared_ptr exported_symbols() const; + + mutable std::shared_ptr m_exported; }; /** diff --git a/source/cstdio.elna b/source/cstdio.elna index 346d931..15c467e 100644 --- a/source/cstdio.elna +++ b/source/cstdio.elna @@ -34,25 +34,25 @@ extern proc fwrite*(ptr: Pointer; size: Word; nitems: Word; stream: ^FILE): Word extern -proc fputc(c: Int; stream: ^FILE): Word +proc fputc*(c: Int; stream: ^FILE): Word extern -proc perror(s: ^Char) +proc perror*(s: ^Char) extern -proc puts(s: ^Char): Int +proc puts*(s: ^Char): Int extern -proc putchar(c: Int): Int +proc putchar*(c: Int): Int extern -proc sprintf(str: Pointer; format: ^Char; number: Word): Int +proc sprintf*(str: Pointer; format: ^Char; number: Word): Int extern -proc fprintf(stream: Pointer; format: ^Char; number: Word): Int +proc fprintf*(stream: Pointer; format: ^Char; number: Word): Int extern -proc fdopen(fildes: Int; mode: ^Char): Pointer +proc fdopen*(fildes: Int; mode: ^Char): Pointer extern end. -- cgit v1.2.3