aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.19k stars 3.66k forks source link

[Feature Request][move-compiler-v2] extend `GlobalEnv::display` to print all IR constructs (including V1) in move-model #15340

Open brmataptos opened 5 days ago

brmataptos commented 5 days ago

🚀 Feature Request

I just wrote this:

     exp.display(env),
     env.display(param),
     ast_debug::display_verbose(old_exp),

and we also have things like:

                let name = format!(
                    "{}::{}",
                    module.get_name().name().display(module.symbol_pool()),
                    fun.name.display(module.symbol_pool())
                );
....
            self.symbol_pool.string(spec_var_name)
...
    fn dump_field(&self, tctx: &TypeDisplayContext, fld: &FieldEnv) -> String {
        format!(
            "{}: {}",
            fld.get_name().display(tctx.env.symbol_pool()),
            fld.get_type().display(tctx)
        )
    }

and think this is pretty crazy. We should have a more standard way to get a Display and/or String object for all IR constructs. Probably we could continue to generalize/implement trait EnvDisplay and use env.display(x) for everything (and replace all existing uses so it's the obvious way to do it).