internal modules

pull/1322/head^2
joe-conigliaro 2019-07-27 02:02:58 +10:00 committed by Alexander Medvednikov
parent 920ac3f92e
commit 979917144f
2 changed files with 17 additions and 1 deletions

View File

@ -139,6 +139,10 @@ pub fn(graph &ModDepGraph) last_node() {
return graph.nodes[graph.nodes.len-1] 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() { pub fn(graph &ModDepGraph) display() {
for i:=0; i<graph.nodes.len; i++ { for i:=0; i<graph.nodes.len; i++ {
node := graph.nodes[i] node := graph.nodes[i]

View File

@ -714,6 +714,18 @@ fn (fit mut FileImportTable) register_alias(alias string, mod string) {
panic('cannot import $mod as $alias: import name $alias already in use in "${fit.file_path}".') panic('cannot import $mod as $alias: import name $alias already in use in "${fit.file_path}".')
return 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 fit.imports[alias] = mod
} }