MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / do_import_stmt

Method do_import_stmt

compiler/src/modules/parser/imports.rs:19–31  ·  view source on GitHub ↗

`import name [as alias]`: resolves and binds module as HeapObj::Module under alias. */

(&mut self)

Source from the content-addressed store, hash-verified

17
18 /* `import name [as alias]`: resolves and binds module as HeapObj::Module under alias. */
19 pub(super) fn do_import_stmt(&mut self) {
20 self.advance(); // 'import'
21 loop {
22 let (spec, span) = self.read_module_spec();
23 let alias = if self.eat_if(TokenType::As) {
24 self.advance_text()
25 } else {
26 spec.split('.').next().unwrap_or(&spec).to_string()
27 };
28 self.resolve_and_bind_all(&spec, span, &alias);
29 if !self.eat_if(TokenType::Comma) { break; }
30 }
31 }
32
33 /* `from <spec> import names|*`: spec is URL, path, or bare name; `*` binds all exports. Names may be parenthesized for multi-line lists, trailing comma allowed. */
34 pub(super) fn do_from_stmt(&mut self) {

Callers 1

import_stmtMethod · 0.80

Calls 6

advanceMethod · 0.80
read_module_specMethod · 0.80
eat_ifMethod · 0.80
advance_textMethod · 0.80
nextMethod · 0.80
resolve_and_bind_allMethod · 0.80

Tested by

no test coverage detected