sui
sui copied to clipboard
[move] Add save hooks for extracting compiler information
Description
- Most of the usages of the stepped compiler are to simply clone out portions of the AST
- Particularly for the move-model and move-model-2
- I added generalized hooks that let you save any step of compilation, including ProgramInfo, which might be helpful for the IDE
Test plan
- Internal change
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.
- [ ] Protocol:
- [ ] Nodes (Validators and Full nodes):
- [ ] Indexer:
- [ ] JSON-RPC:
- [ ] GraphQL:
- [ ] CLI:
- [ ] Rust SDK:
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
multisig-toolkit | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 8, 2024 11:35pm |
sui-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 8, 2024 11:35pm |
sui-kiosk | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 8, 2024 11:35pm |
sui-typescript-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 8, 2024 11:35pm |
Can we simplify this implementation quite a bit?
pub struct SavedInfo {
parser: Option<P::Program>,
expansion: Option<E::Program>,
naming: Option<N::Program>,
typing: Option<T::Program>,
typing_info: Option<Arc<program_info::TypingProgramInfo>>,
hlir: Option<H::Program>,
cfgir: Option<G::Program>,
}
#[derive(Ord, PartialOrd)]
pub enum SavedInfoFlag {
Parser,
Expansion,
Naming,
Typing,
TypingInfo,
HLIR,
CFGIR,
}
pub type SavedInfoSettings = BTreeSet<SavedInfoFlag>;
...
pub struct CompilationEnv {
...,
saved_info: Rc<RefCell<SavedInfo>>,
save_info_flags: SavedInfoSettings,
}
...
impl CompilationEnv {
...
pub fn save_parser_ast(&self, ast: &P::Program) {
if self.save_info_flags.contains(SavedInfoFlag::Parser) {
self.saved_info.borrow_mut().parser = Some(ast.clone());
}
}
...
pub fn set_saved_flag(&mut self, flag: SavedInfoFlag) {
self.saved_info_flags.insert(flag);
}
}
I appreciate it isn't quite the same: the callee doesn't hold the hook, so you'll have to set the flags, call, and grab the result out. I think since this requires passing the compilation env around, though, the friction is pretty low?
Can we simplify this implementation quite a bit?
I like it. Will do