/// A inline alias for component exported items. /// /// Handles both `core export` and `export` aliases #[derive(Debug)] pubstruct InlineExportAlias<'a, const CORE: bool> { /// The instance to alias the export from. pub instance: Index<'a>, /// The name of the export to alias. pub name: &'a str,
}
impl<'a, const CORE: bool> Parse<'a> for InlineExportAlias<'a, CORE> { fn parse(parser: Parser<'a>) -> Result<Self> {
parser.parse::<kw::alias>()?; if CORE {
parser.parse::<kw::core>()?;
}
parser.parse::<kw::export>()?; let instance = parser.parse()?; let name = parser.parse()?;
Ok(Self { instance, name })
}
}
/// An alias to a component item. #[derive(Debug)] pubstruct Alias<'a> { /// Where this `alias` was defined. pub span: Span, /// An identifier that this alias is resolved with (optionally) for name /// resolution. pub id: Option<Id<'a>>, /// An optional name for this alias stored in the custom `name` section. pub name: Option<NameAnnotation<'a>>, /// The target of this alias. pub target: AliasTarget<'a>,
}
impl<'a> Alias<'a> { /// Parses only an outer type alias. pubfn parse_outer_core_type_alias(parser: Parser<'a>) -> Result<Self> { let span = parser.parse::<kw::alias>()?.0;
parser.parse::<kw::outer>()?; let outer = parser.parse()?; let index = parser.parse()?;
let (kind, id, name) = parser.parens(|parser| { letmut kind: ComponentOuterAliasKind = parser.parse()?; match kind {
ComponentOuterAliasKind::CoreType => { return Err(parser.error("expected type for outer alias"))
}
ComponentOuterAliasKind::Type => {
kind = ComponentOuterAliasKind::CoreType;
}
_ => return Err(parser.error("expected core type or type for outer alias")),
}
impl<'a> Parse<'a> for Alias<'a> { fn parse(parser: Parser<'a>) -> Result<Self> { let span = parser.parse::<kw::alias>()?.0;
letmut l = parser.lookahead1();
let (target, id, name) = if l.peek::<kw::outer>()? {
parser.parse::<kw::outer>()?; let outer = parser.parse()?; let index = parser.parse()?; let (kind, id, name) =
parser.parens(|parser| Ok((parser.parse()?, parser.parse()?, parser.parse()?)))?;
(AliasTarget::Outer { outer, index, kind }, id, name)
} elseif l.peek::<kw::export>()? {
parser.parse::<kw::export>()?; let instance = parser.parse()?; let export_name = parser.parse()?; let (kind, id, name) =
parser.parens(|parser| Ok((parser.parse()?, parser.parse()?, parser.parse()?)))?;
/// Represents the kind of instance export alias. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pubenum ComponentExportAliasKind { /// The alias is to a core module export.
CoreModule, /// The alias is to a function export.
Func, /// The alias is to a value export.
Value, /// The alias is to a type export. Type, /// The alias is to a component export.
Component, /// The alias is to an instance export.
Instance,
}
/// Represents the kind of outer alias. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pubenum ComponentOuterAliasKind { /// The alias is to an outer core module.
CoreModule, /// The alias is to an outer core type.
CoreType, /// The alias is to an outer type. Type, /// The alias is to an outer component.
Component,
}
/// The target of a component alias. #[derive(Debug)] pubenum AliasTarget<'a> { /// The alias is to an export of a component instance.
Export { /// The component instance exporting the item.
instance: Index<'a>, /// The name of the exported item to alias.
name: &'a str, /// The export kind of the alias.
kind: ComponentExportAliasKind,
}, /// The alias is to an export of a module instance.
CoreExport { /// The module instance exporting the item.
instance: Index<'a>, /// The name of the exported item to alias.
name: &'a str, /// The export kind of the alias.
kind: ExportKind,
}, /// The alias is to an item from an outer component.
Outer { /// The number of enclosing components to skip.
outer: Index<'a>, /// The index of the item being aliased.
index: Index<'a>, /// The outer alias kind.
kind: ComponentOuterAliasKind,
},
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.