Stream: general

Topic: ✔ witx-bindgen locals question


view this post on Zulip Scott Waye (Nov 06 2021 at 14:03):

I'm working on getting a c# lib.rs for witx-bindgen. Just started really and have a question about how to use the self.locals . In lowering I create a local that I need to "free" after the call, in the lifting. I guess I want to use self.locals.insert("pinnedArray"); to create the local but how do I get a reference to that in Instruction::ListCanonLift ?

view this post on Zulip Scott Waye (Nov 06 2021 at 14:09):

I should add that I'm starting with the C implementation, so locals is locals: Ns, in its struct FunctionBindgen<'a> . I'm new to Rust in general, so not sure what I should be looking for. I mean some of this code is specific to the C implementation, but the general idea of wanting to use a local in the lowering and lifting I would think is universal.

view this post on Zulip Scott Waye (Nov 06 2021 at 16:06):

I've just put stuff on self I guess thats ok if there is a new self for every function?

view this post on Zulip Alex Crichton (Nov 08 2021 at 15:43):

@Scott Waye I don't think there's much too strict about this, the locals idea was just me trying to make it easier to generate temporary names for variables for languages like C where everything needs to be unique. That's not necessarily required of all generators and it largely depends otherwise on the shape of the code that you're generating and the lanugage that you're generating for (I don't know enough about C# to say anything myself)

view this post on Zulip Notification Bot (Nov 08 2021 at 15:45):

Scott Waye has marked this topic as resolved.


Last updated: Dec 23 2024 at 12:05 UTC