Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIR: Provide utility functions for looking up full identifiers #1980

Open
RyanGlScott opened this issue Nov 13, 2023 · 0 comments
Open

MIR: Provide utility functions for looking up full identifiers #1980

RyanGlScott opened this issue Nov 13, 2023 · 0 comments
Labels
crucible/mir Related to crucible-mir verification enhancement usability An issue that impedes efficient understanding and use

Comments

@RyanGlScott
Copy link
Contributor

Finding the names of MIR identifiers in a MIR JSON file is challenging, and doubly so when the name is autogenerated. For instance, consider this file:

pub fn f<A>(x: A) -> A {
    x
}

pub fn g(x: u32) -> u32 {
    f(x)
}

Let's suppose you want to look up the identifier corresponding to f when the A type parameter is instantiated with u32 (as is the case when g invokes the f function). Currently, there is no good way to do this—you'd have to dig into the MIR JSON file manually to discover that the autogenerated name is something like test::f::_instc5e93708b8ca6e2a. Users shouldn't have to do this!

Instead, we should offer utility functions to make it possible to look up these sorts of names directly from SAW. For instance, we could imagine a command like this:

mir_instantiated_name : String -> [MIRType] -> String

Where the String argument represents a polymorphic function being called (in this case, "test::f) and the [MIRType] list represents the list of types to instantiate the function with (in this case, [mir_u32]). The String that it returns would then be the name of the fully instantiated function identifier (in this case, test::f::_instc5e93708b8ca6e2a). This API closely resembles that of the existing mir_find_adt function, which already performs a similar sort of type-based name lookup.

Other useful commands worth adding would be something that granted users the ability to look up names using things that resemble fully qualified syntax (e.g., <Ty>::foo). In order to support this, we may have to extend mir-json to include more information linking foo back to Ty, especially if foo is located in an impl Ty block (currently, nothing in the mir-json file makes it obvious which impl<N> block specifically corresponds to the impl Ty block).

@RyanGlScott RyanGlScott added enhancement usability An issue that impedes efficient understanding and use crucible/mir Related to crucible-mir verification labels Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crucible/mir Related to crucible-mir verification enhancement usability An issue that impedes efficient understanding and use
Projects
None yet
Development

No branches or pull requests

1 participant