Skip to content

Commit 3f36b9c

Browse files
committed
Implement export statement resolution.
This commit completes AST resolution. An `imports` and `exports` collection were added to the resolution to keep track of imported and exported items from the composition. The resolution now ensures that import names are unique. Additionally, this updates to the latest dependencies including changes to `wasmparser`'s type information representation. Import and export names are now validated in accordance with the latest component model spec; this will enable specifying import dependencies when performing encodings.
1 parent 205dc16 commit 3f36b9c

49 files changed

Lines changed: 730 additions & 287 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 39 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ wat = ["wac-parser/wat"]
3535

3636
[workspace.dependencies]
3737
wac-parser = { path = "crates/wac-parser", default-features = false }
38-
wit-parser = "0.12.1"
39-
wasmparser = "0.115.0"
40-
wit-component = "0.16.0"
38+
wit-parser = "0.13.0"
39+
wasmparser = "0.116.1"
40+
wit-component = "0.18.0"
4141
anyhow = "1.0.75"
42-
clap = { version = "4.4.6", features = ["derive"] }
42+
clap = { version = "4.4.7", features = ["derive"] }
4343
semver = "1.0.20"
4444
pretty_env_logger = "0.5.0"
4545
log = "0.4.20"
4646
tokio = { version = "1.33.0", default-features = false, features = ["macros", "rt-multi-thread"] }
4747
owo-colors = { version = "3.5.0", features = ["supports-colors"] }
48-
indexmap = { version = "2.0.2", features = ["serde"] }
48+
indexmap = { version = "2.1.0", features = ["serde"] }
4949
id-arena = "2.2.1"
50-
serde = { version = "1.0.189", features = ["derive"] }
51-
serde_json = "1.0.107"
52-
wat = "1.0.77"
50+
serde = { version = "1.0.191", features = ["derive"] }
51+
serde_json = "1.0.108"
52+
wat = "1.0.79"
5353
logos = "0.13.0"
5454
thiserror = "1.0.50"

crates/wac-parser/src/ast/export.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{
22
display, expr::Expr, parse_optional, parse_token, DocComment, Lookahead, Parse, ParseResult,
33
Peek,
44
};
5-
use crate::lexer::{Lexer, Token};
5+
use crate::lexer::{Lexer, Span, Token};
66
use serde::Serialize;
77

88
/// Represents an export statement in the AST.
@@ -11,6 +11,8 @@ use serde::Serialize;
1111
pub struct ExportStatement<'a> {
1212
/// The doc comments for the statement.
1313
pub docs: Vec<DocComment<'a>>,
14+
/// The span of the export keyword.
15+
pub span: Span<'a>,
1416
/// The optional `with` string.
1517
pub with: Option<super::String<'a>>,
1618
/// The expression to export.
@@ -20,11 +22,16 @@ pub struct ExportStatement<'a> {
2022
impl<'a> Parse<'a> for ExportStatement<'a> {
2123
fn parse(lexer: &mut Lexer<'a>) -> ParseResult<'a, Self> {
2224
let docs = Parse::parse(lexer)?;
23-
parse_token(lexer, Token::ExportKeyword)?;
25+
let span = parse_token(lexer, Token::ExportKeyword)?;
2426
let expr = Parse::parse(lexer)?;
2527
let with = parse_optional(lexer, Token::WithKeyword, Parse::parse)?;
2628
parse_token(lexer, Token::Semicolon)?;
27-
Ok(Self { docs, expr, with })
29+
Ok(Self {
30+
docs,
31+
span,
32+
expr,
33+
with,
34+
})
2835
}
2936
}
3037

0 commit comments

Comments
 (0)