Hi, can I ask for a bit of help with a problem I have with the parameter name for a function. The problem is that I am generating this code:
internal static void A(string p0)
{
var result = x;
IntPtr interopString = InteropString.FromString(result, out int length);
AInterop.wasmImportA(interopString.ToInt32(), length);
Where what I want is
internal static void A(string p0)
{
var result = p0;
I.e. `p0`, not `x`. The `x` comes from the `GetArg` instruction:
[image.png](/user_uploads/15107/fF4EE_QccOFok-SJwbuXhxPq/image.png)
And my question is where does the `x` come from and what might I have done wrong so that it doesn't match
let sig = self.resolve.wasm_signature(AbiVariant::GuestImport, func);
and `sig.params` ?
Thanks
Param names should be available from func.params
(https://docs.rs/wit-parser/0.11.1/wit_parser/type.Params.html)
sig
is a core wasm func signature; core func params don't have names
So
impl Bindgen for FunctionBindgen<'_, '_> {
type Operand = String;
fn emit(
&mut self,
_resolve: &Resolve,
inst: &Instruction<'_>,
operands: &mut Vec<String>,
results: &mut Vec<String>,
) {
match inst {
Instruction::GetArg { nth } => results.push(self.params[*nth].clone()),
Is correct?
I am not that familiar with bindgen; is nth
referring to the component signature or the core signature?
One component param could be lowered into multiple core params
Right, what I'm after is the core params
Interesting that core params don't have names, I wonder where "x" comes from
Core params don't inherently have names. I see wasmtime bindgen for example just uses argN
Thanks, I'll have a look at the rust to see how it works
Problem between keyboard and chair :-)
Scott Waye has marked this topic as resolved.
Last updated: Dec 23 2024 at 12:05 UTC