fmease / lushui

The reference compiler of the Lushui programming language
Apache License 2.0
7 stars 0 forks source link

Do not lower use-path-trees to simple use-declarations #93

Open fmease opened 3 years ago

fmease commented 3 years ago

Instead, keep the notion of use-path-trees in the lowered AST. This prevents the name resolver from having to resolve the common path prefixes over and over again as it can simply store the resolved relative root.

Consider (not everything shown):

use alpha.beta.gamma.(delta epsilon zeta eta)

which is a very common pattern (in Rust at least).

Today, this looks like the following for the name resolver:

use alpha.beta.gamma.delta
use alpha.beta.gamma.epsilon
use alpha.beta.gamma.zeta
use alpha.beta.gamma.eta

It has to resolve alpha.beta.gamma 4 times (!) having to