Isolate import handling code
This commit is contained in:
parent
41cad61e34
commit
9cd64d97a5
@ -21,27 +21,29 @@ impl<'a> ScopeResolver<'a> {
|
||||
match statement.kind {
|
||||
StatementKind::Declaration(ref decl) => self.decl(decl),
|
||||
StatementKind::Expression(ref expr) => self.expr(expr),
|
||||
StatementKind::Import(ImportSpecifier { ref path_components, ref imported_names, .. }) => {
|
||||
match imported_names {
|
||||
ImportedNames::All => unimplemented!(),
|
||||
ImportedNames::LastOfPath => {
|
||||
let name = path_components.last().unwrap(); //TODO handle better
|
||||
let fqsn_prefix = path_components.iter().map(|c| ScopeSegment {
|
||||
name: c.clone(), kind: ScopeSegmentKind::Type
|
||||
}).collect();
|
||||
self.name_scope_stack.insert(name.clone(), fqsn_prefix);
|
||||
()
|
||||
}
|
||||
ImportedNames::List(ref names) => unimplemented!()
|
||||
};
|
||||
//self.name_scope_stack.insert()
|
||||
Ok(())
|
||||
}
|
||||
StatementKind::Import(ref spec) => self.import(spec),
|
||||
}?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn import(&mut self, import_spec: &ImportSpecifier) -> Result<(), String> {
|
||||
let ImportSpecifier { ref path_components, ref imported_names, .. } = &import_spec;
|
||||
match imported_names {
|
||||
ImportedNames::All => unimplemented!(),
|
||||
ImportedNames::LastOfPath => {
|
||||
let name = path_components.last().unwrap(); //TODO handle better
|
||||
let fqsn_prefix = path_components.iter().map(|c| ScopeSegment {
|
||||
name: c.clone(), kind: ScopeSegmentKind::Type
|
||||
}).collect();
|
||||
self.name_scope_stack.insert(name.clone(), fqsn_prefix);
|
||||
()
|
||||
}
|
||||
ImportedNames::List(ref names) => unimplemented!()
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn decl(&mut self, decl: &Declaration) -> Result<(), String> {
|
||||
use Declaration::*;
|
||||
match decl {
|
||||
|
Loading…
Reference in New Issue
Block a user