subdir is a pain. Ideally, we'd deal with it entirely at the AST level, because you'd have subdir('foo'). No variables, no keywords, just a basic "here is a subdir". We don't. we have two annoying cases that make handling it at the AST level really, really, really hard:
x = 'foo'
if host_machine.system() == 'windows'
x = 'bar'
endif
subdir(x)
This cannot be handled at the AST level, because we can't know what X is until we get to the MIR passes that check host machine and lower away dead variables.
Second, we need to handle the subdir('foo', if_found : bar). This can be handled at the AST level.
So, I have two choices. Do as much of the lowering in the AST as possible, but then do some of it at the MIR level. Or, I move it all to the MIR level and deal with that annoyance.
subdir
is a pain. Ideally, we'd deal with it entirely at the AST level, because you'd havesubdir('foo')
. No variables, no keywords, just a basic "here is a subdir". We don't. we have two annoying cases that make handling it at the AST level really, really, really hard:This cannot be handled at the AST level, because we can't know what X is until we get to the MIR passes that check host machine and lower away dead variables.
Second, we need to handle the
subdir('foo', if_found : bar)
. This can be handled at the AST level.So, I have two choices. Do as much of the lowering in the AST as possible, but then do some of it at the MIR level. Or, I move it all to the MIR level and deal with that annoyance.