AltoLang / Alto

Compiler in the works!
MIT License
3 stars 1 forks source link

More memory efficient `import` statements #56

Closed FilipToth closed 2 years ago

FilipToth commented 3 years ago

Background and Motivation

Currently, we mix all syntax trees into a collection and when an import statement referencing the syntax tree we insert the tree into another collection. That's not very efficient.

Proposed Solution

I propose we search all global statements for imports in the BindGlobalScope method and then see if the file name referenced in the import corresponds to a syntax tree. If it does, we'll add it to the _importedTrees collection and allow it's child methods to be referenced. This will also illegalize import statements outside the global scope.

FilipToth commented 2 years ago

This has now become a duplicate of #69.