pub struct Import {
pub path: PathBuf,
pub alias: String,
pub span: Range<usize>,
}Expand description
An import declaration referencing an external implementation file.
§import Declaration (.fi)
Imports an external C or Pancake source file and binds it to a local alias.
import "path/to/file.c" as alias;
import "path/to/file.h" as alias;
import "path/to/file.pnk" as alias;Only .c, .h, and .pnk extensions are accepted: the languages fic
has a reader for, so every call resolves to a function it has read.
The alias is used to call functions from the imported file at runtime.
A .h import is the separate-driver form: the generated translation
unit #includes the header (declarations only) and the paired sibling
.c (e.g. eth.h → eth.c) is compiled and linked alongside it. A
.c import is the legacy inlined form: the driver source is textually
#included into the generated unit (single translation unit).
import "eth.h" as eth; // separate driver: include eth.h, link eth.c
import "eth.c" as eth; // inlined driver: #include <eth.c>
import "uart.pnk" as uart; // Pancake translation unitThe alias is the name a program uses at call sites (eth.send(..)):
it names the file only while the program’s calls are resolved.
Language reference: Imports, Foreign Functions.
The parser records the path as written and decides nothing about the
file: what it is follows from its extension
(ForeignKind::of), which the front
end checks as it binds the program, and the file it names is the
loaded-modules store’s to say
(ForeignModules::module).
Fields§
§path: PathBufThe imported file, as written (relative to the project directory).
alias: StringThe alias call sites use: alias.fn(..).
span: Range<usize>Byte span of the whole import ... ; declaration.