Skip to content

Commit fddb6b2

Browse files
committed
Allow unused fields in Instructions
1 parent ddb3152 commit fddb6b2

File tree

7 files changed

+33
-8
lines changed

7 files changed

+33
-8
lines changed

crates/cli-support/src/js/binding.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ fn instruction(
12401240

12411241
Instruction::CachedStringLoad {
12421242
owned,
1243+
optional: _,
12431244
mem,
12441245
free,
12451246
table,

crates/cli-support/src/js/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,6 +3274,7 @@ __wbg_set_wasm(wasm);"
32743274
dtor,
32753275
mutable,
32763276
adapter,
3277+
nargs: _,
32773278
} => {
32783279
assert!(kind == AdapterJsImportKind::Normal);
32793280
assert!(!variadic);

crates/cli-support/src/wit/incoming.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl InstructionBuilder<'_, '_> {
117117
&[AdapterType::Enum(name.clone())],
118118
Instruction::IntToWasm {
119119
input: AdapterType::U32,
120+
output: ValType::I32,
120121
},
121122
&[AdapterType::I32],
122123
);
@@ -472,6 +473,7 @@ impl InstructionBuilder<'_, '_> {
472473
fn number(&mut self, input: AdapterType, output: walrus::ValType) {
473474
let instr = Instruction::IntToWasm {
474475
input: input.clone(),
476+
output,
475477
};
476478
self.instruction(&[input], instr, &[AdapterType::from_wasm(output).unwrap()]);
477479
}

crates/cli-support/src/wit/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ impl<'a> Context<'a> {
197197
// aren't present in the signature but are present in the wasm
198198
// signature.
199199
let mut function = descriptor.function.clone();
200+
let nargs = function.arguments.len();
200201
function.arguments.insert(0, Descriptor::I32);
201202
function.arguments.insert(0, Descriptor::I32);
202203
let adapter = self.table_element_adapter(descriptor.shim_idx, function)?;
@@ -205,6 +206,7 @@ impl<'a> Context<'a> {
205206
AuxImport::Closure {
206207
dtor: descriptor.dtor_idx,
207208
mutable: descriptor.mutable,
209+
nargs,
208210
adapter,
209211
},
210212
);
@@ -1202,7 +1204,7 @@ impl<'a> Context<'a> {
12021204
kind: AdapterJsImportKind,
12031205
) -> Result<AdapterId, Error> {
12041206
let import = self.module.imports.get(import);
1205-
let import_name = import.name.clone();
1207+
let (import_module, import_name) = (import.module.clone(), import.name.clone());
12061208
let import_id = import.id();
12071209
let core_id = match import.kind {
12081210
walrus::ImportKind::Function(f) => f,
@@ -1239,6 +1241,7 @@ impl<'a> Context<'a> {
12391241
ret.input,
12401242
vec![],
12411243
AdapterKind::Import {
1244+
module: import_module,
12421245
name: import_name,
12431246
kind,
12441247
},

crates/cli-support/src/wit/nonstandard.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ pub enum AuxImport {
244244
mutable: bool, // whether or not this was a `FnMut` closure
245245
dtor: u32, // table element index of the destructor function
246246
adapter: AdapterId, // the adapter which translates the types for this closure
247+
#[allow(dead_code)]
248+
nargs: usize,
247249
},
248250

249251
/// This import is expected to be a shim that simply calls the `foo` method

crates/cli-support/src/wit/outgoing.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl InstructionBuilder<'_, '_> {
110110
Descriptor::Ref(d) => self.outgoing_ref(false, d)?,
111111
Descriptor::RefMut(d) => self.outgoing_ref(true, d)?,
112112

113-
Descriptor::CachedString => self.cached_string(false)?,
113+
Descriptor::CachedString => self.cached_string(false, true)?,
114114

115115
Descriptor::String => {
116116
// fetch the ptr/length ...
@@ -193,7 +193,7 @@ impl InstructionBuilder<'_, '_> {
193193
&[AdapterType::NamedExternref(name.clone())],
194194
);
195195
}
196-
Descriptor::CachedString => self.cached_string(false)?,
196+
Descriptor::CachedString => self.cached_string(false, false)?,
197197

198198
Descriptor::String => {
199199
self.instruction(
@@ -316,10 +316,13 @@ impl InstructionBuilder<'_, '_> {
316316
&[AdapterType::Enum(name.clone()).option()],
317317
);
318318
}
319-
Descriptor::StringEnum { name, .. } => {
319+
Descriptor::StringEnum { name, hole, .. } => {
320320
self.instruction(
321321
&[AdapterType::I32],
322-
Instruction::OptionWasmToStringEnum { name: name.clone() },
322+
Instruction::OptionWasmToStringEnum {
323+
name: name.clone(),
324+
hole: *hole,
325+
},
323326
&[AdapterType::StringEnum(name.clone()).option()],
324327
);
325328
}
@@ -335,7 +338,7 @@ impl InstructionBuilder<'_, '_> {
335338
Descriptor::Ref(d) => self.outgoing_option_ref(false, d)?,
336339
Descriptor::RefMut(d) => self.outgoing_option_ref(true, d)?,
337340

338-
Descriptor::CachedString => self.cached_string(true)?,
341+
Descriptor::CachedString => self.cached_string(true, true)?,
339342

340343
Descriptor::String | Descriptor::Vector(_) => {
341344
let kind = arg.vector_kind().ok_or_else(|| {
@@ -525,7 +528,7 @@ impl InstructionBuilder<'_, '_> {
525528
&[AdapterType::NamedExternref(name.clone()).option()],
526529
);
527530
}
528-
Descriptor::CachedString => self.cached_string(true)?,
531+
Descriptor::CachedString => self.cached_string(true, false)?,
529532
Descriptor::String | Descriptor::Slice(_) => {
530533
let kind = arg.vector_kind().ok_or_else(|| {
531534
format_err!(
@@ -553,6 +556,7 @@ impl InstructionBuilder<'_, '_> {
553556

554557
fn outgoing_i32(&mut self, output: AdapterType) {
555558
let instr = Instruction::WasmToInt {
559+
input: walrus::ValType::I32,
556560
output: output.clone(),
557561
};
558562
self.instruction(&[AdapterType::I32], instr, &[output]);
@@ -570,18 +574,20 @@ impl InstructionBuilder<'_, '_> {
570574

571575
fn outgoing_i64(&mut self, output: AdapterType) {
572576
let instr = Instruction::WasmToInt {
577+
input: walrus::ValType::I64,
573578
output: output.clone(),
574579
};
575580
self.instruction(&[AdapterType::I64], instr, &[output]);
576581
}
577582

578-
fn cached_string(&mut self, owned: bool) -> Result<(), Error> {
583+
fn cached_string(&mut self, optional: bool, owned: bool) -> Result<(), Error> {
579584
let mem = self.cx.memory()?;
580585
let free = self.cx.free()?;
581586
self.instruction(
582587
&[AdapterType::I32, AdapterType::I32],
583588
Instruction::CachedStringLoad {
584589
owned,
590+
optional,
585591
mem,
586592
free,
587593
table: None,

crates/cli-support/src/wit/standard.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub enum AdapterKind {
4040
instructions: Vec<InstructionData>,
4141
},
4242
Import {
43+
#[allow(dead_code)]
44+
module: String,
4345
name: String,
4446
kind: AdapterJsImportKind,
4547
},
@@ -138,9 +140,13 @@ pub enum Instruction {
138140
/// Pops a typed integer (`u8`, `s16`, etc.) and pushes a plain Wasm `i32` or `i64` equivalent.
139141
IntToWasm {
140142
input: AdapterType,
143+
#[allow(dead_code)]
144+
output: walrus::ValType,
141145
},
142146
/// Pops a Wasm `i32` or `i64` and pushes a typed integer (`u8`, `s16`, etc.) equivalent.
143147
WasmToInt {
148+
#[allow(dead_code)]
149+
input: walrus::ValType,
144150
output: AdapterType,
145151
},
146152

@@ -163,6 +169,8 @@ pub enum Instruction {
163169

164170
OptionWasmToStringEnum {
165171
name: String,
172+
#[allow(dead_code)]
173+
hole: u32,
166174
},
167175

168176
/// pops a string and pushes the enum variant as an `i32`
@@ -306,6 +314,8 @@ pub enum Instruction {
306314
/// pops ptr/length i32, loads string from cache
307315
CachedStringLoad {
308316
owned: bool,
317+
#[allow(dead_code)]
318+
optional: bool,
309319
mem: walrus::MemoryId,
310320
free: walrus::FunctionId,
311321
/// If we're in reference-types mode, the externref table ID to get the cached string from.

0 commit comments

Comments
 (0)