internal modules
parent
920ac3f92e
commit
979917144f
|
@ -139,6 +139,10 @@ pub fn(graph &ModDepGraph) last_node() {
|
|||
return graph.nodes[graph.nodes.len-1]
|
||||
}
|
||||
|
||||
pub fn(graph &ModDepGraph) last_cycle() string {
|
||||
return graph.nodes[graph.nodes.len-1].last_cycle
|
||||
}
|
||||
|
||||
pub fn(graph &ModDepGraph) display() {
|
||||
for i:=0; i<graph.nodes.len; i++ {
|
||||
node := graph.nodes[i]
|
||||
|
|
|
@ -713,7 +713,19 @@ fn (fit mut FileImportTable) register_alias(alias string, mod string) {
|
|||
if alias in fit.imports {
|
||||
panic('cannot import $mod as $alias: import name $alias already in use in "${fit.file_path}".')
|
||||
return
|
||||
}
|
||||
}
|
||||
if mod.contains('.internal.') {
|
||||
mod_parts := mod.split('.')
|
||||
mut internal_mod_parts := []string
|
||||
for part in mod_parts {
|
||||
if part == 'internal' { break }
|
||||
internal_mod_parts << part
|
||||
}
|
||||
internal_parent := internal_mod_parts.join('.')
|
||||
if !fit.module_name.starts_with(internal_parent) {
|
||||
panic('module $mod can only be imported internally by libs.')
|
||||
}
|
||||
}
|
||||
fit.imports[alias] = mod
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue