mirror of https://github.com/tbklang/tlang.git
Cross-module extern statements #168
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 1 hour 1 minute
Due Date
deavmi
1 hour 1 minute
Dependencies
No dependencies set.
Reference: tlang/tlang#168
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose ✍️
To be able to extern a statement in module
a
, have moduleb
importa
and have that extern statement also accessible tob
viaa.<externName>
.Why?
All
extern
-like statements must become automaticallyprivate
. This will stop them from being accessible outside to other modules which would cause them to get double externed. I mean, is that a problem. We could maybe handle it. But maybe not for now?With regards to the second item in this list I think it actually may not require much work to get right. Look when we generate the externs for module import system we do so by placing
extern <type> <name>
, where<name>
is theEntity
's name regardless of whether itisExternal()
or not.Hence it should just work. The only part we must worry about is that we must NOT symbol map the
Entity
's (Variable
s) which are extern.So basically this:
Okay but wait, this is fine and all but technically if we request a signature for a
variable
then it should also place theextern
in front of it.This is where the problemo lies. Who's resposibility. I say this because the function siganture generator does this and therefore, to stay consistent, so should the
Variable
-based one.So:
And now we shall run into expected problems that should be fixed in the
ModuleExternStmts
thing.Heheh:
Okay, but now that it is fixed we could also then do checks in the
ModExternSttmsd
that yanks out theextern
part if is knows the entity the signature is requested for isextern
.This would then make the following
evar
/efunc
s:into:
The checks are therefore basically like this:
Looks like this solution works. ✅
We allow cross-module extern usage, it automagically works and the
DGen
emitter has now been updated to make it work.This is done ✅