diff options
| -rw-r--r-- | boot/symbol.cc | 18 | ||||
| -rw-r--r-- | include/elna/boot/symbol.h | 13 | ||||
| -rw-r--r-- | 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_table> symbol_bag::exported_symbols() const + { + if (!m_exported) + { + m_exported = std::make_shared<symbol_table>(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_type> 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<symbol_table> exported_symbols() const; + + mutable std::shared_ptr<symbol_table> 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. |
