Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Opt<'a> {
imports: LinkInfo,
exports: LinkInfo,
main: LinkInfo,
need_debug: bool,
}
#[derive(Default)]
struct LinkInfo {
Expand All @@ -37,6 +38,7 @@ impl<'a> Opt<'a> {
imports: LinkInfo::default(),
exports: LinkInfo::default(),
main: LinkInfo::default(),
need_debug: false,
}
}
fn generate_main_wit(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) {
Expand Down Expand Up @@ -66,6 +68,7 @@ impl<'a> Opt<'a> {
let name = resolve.name_world_key(name);
// Don't virtualize util imports
if name.starts_with("proxy:util/") {
self.need_debug = true;
self.main.imports.insert(name.clone(), LinkType::Debug);
out.push_str(&format!("import {name};\n"));
continue;
Expand Down Expand Up @@ -162,7 +165,9 @@ impl<'a> Opt<'a> {
self.load_exports(exports_wasm)?;
let mut out = Source::default();
out.push_str("package component:composed;\n");
out.push_str("let debug = new import:debug { ... };\n");
if self.need_debug {
out.push_str("let debug = new import:debug { ... };\n");
}
if !self.args.use_host_recorder {
out.push_str("let recorder = new import:recorder { ... };\n");
}
Expand Down Expand Up @@ -362,7 +367,10 @@ impl<'a> Opt<'a> {
WorldItem::Interface { .. } => {
let name = resolve.name_world_key(name);
let link_type = match name.as_str() {
"proxy:util/debug" => LinkType::Debug,
"proxy:util/debug" => {
self.need_debug = true;
LinkType::Debug
}
"proxy:util/dialog" => LinkType::Host,
name if name.starts_with("proxy:recorder/") => LinkType::Recorder,
_ => LinkType::Host,
Expand All @@ -382,7 +390,10 @@ impl<'a> Opt<'a> {
WorldItem::Interface { .. } => {
let name = resolve.name_world_key(name);
let link_type = match name.as_str() {
"proxy:util/debug" => LinkType::Debug,
"proxy:util/debug" => {
self.need_debug = true;
LinkType::Debug
}
"proxy:conversion/conversion" => LinkType::Imports,
"proxy:util/dialog" => LinkType::Host,
name if name.starts_with("proxy:recorder/") => LinkType::Recorder,
Expand Down
8 changes: 7 additions & 1 deletion src/traits/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,14 @@ impl Trait for DialogTrait {
}
impl Dialog for MockedResource {
fn read_value(_dep: u32) -> Self {
let handle = HANDLE_ID.with(|id| {
let mut id = id.borrow_mut();
let current_id = *id;
*id += 1;
current_id
});
Self {
handle: 42,
handle,
name: "mocked-resource".to_string(),
}
}
Expand Down