Skip to content

Commit

Permalink
[move-compiler] Add sui specific information to TypingProgramInfo (#1…
Browse files Browse the repository at this point in the history
…9287)

## Description 

- Added a map of all UID holders
- Added a map of all transferred objects

## Test plan 

- Not yet used

---

## 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:
- [ ] REST API:
  • Loading branch information
tnowacki authored Sep 11, 2024
1 parent 74d6d56 commit 601ff73
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

use std::{collections::BTreeMap, fmt::Display, sync::Arc};

use move_ir_types::location::Loc;
use move_symbol_pool::Symbol;

use self::known_attributes::AttributePosition;
use crate::{
expansion::ast::{AbilitySet, Attributes, ModuleIdent, TargetKind, Visibility},
naming::ast::{
Expand All @@ -15,11 +13,12 @@ use crate::{
parser::ast::{ConstantName, DatatypeName, Field, FunctionName, VariantName},
shared::unique_map::UniqueMap,
shared::*,
sui_mode::info::SuiInfo,
typing::ast::{self as T},
FullyCompiledProgram,
};

use self::known_attributes::AttributePosition;
use move_ir_types::location::Loc;
use move_symbol_pool::Symbol;

#[derive(Debug, Clone)]
pub struct FunctionInfo {
Expand Down Expand Up @@ -52,6 +51,14 @@ pub struct ModuleInfo {
pub constants: UniqueMap<ConstantName, ConstantInfo>,
}

#[derive(Debug, Clone)]
pub struct ProgramInfo<const AFTER_TYPING: bool> {
pub modules: UniqueMap<ModuleIdent, ModuleInfo>,
pub sui_flavor_info: Option<SuiInfo>,
}
pub type NamingProgramInfo = ProgramInfo<false>;
pub type TypingProgramInfo = ProgramInfo<true>;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DatatypeKind {
Struct,
Expand All @@ -66,13 +73,6 @@ pub enum NamedMemberKind {
Constant,
}

#[derive(Debug, Clone)]
pub struct ProgramInfo<const AFTER_TYPING: bool> {
pub modules: UniqueMap<ModuleIdent, ModuleInfo>,
}
pub type NamingProgramInfo = ProgramInfo<false>;
pub type TypingProgramInfo = ProgramInfo<true>;

macro_rules! program_info {
($pre_compiled_lib:ident, $prog:ident, $pass:ident, $module_use_funs:ident) => {{
let all_modules = $prog.modules.key_cloned_iter();
Expand Down Expand Up @@ -118,12 +118,16 @@ macro_rules! program_info {
}
}
}
ProgramInfo { modules }
ProgramInfo {
modules,
sui_flavor_info: None,
}
}};
}

impl TypingProgramInfo {
pub fn new(
env: &CompilationEnv,
pre_compiled_lib: Option<Arc<FullyCompiledProgram>>,
modules: &UniqueMap<ModuleIdent, T::ModuleDefinition>,
mut module_use_funs: BTreeMap<ModuleIdent, ResolvedUseFuns>,
Expand All @@ -133,7 +137,18 @@ impl TypingProgramInfo {
}
let mut module_use_funs = Some(&mut module_use_funs);
let prog = Prog { modules };
program_info!(pre_compiled_lib, prog, typing, module_use_funs)
let pcl = pre_compiled_lib.clone();
let mut info = program_info!(pcl, prog, typing, module_use_funs);
// TODO we should really have an idea of root package flavor here
// but this feels roughly equivalent
if env
.package_configs()
.any(|(_, config)| config.flavor == Flavor::Sui)
{
let sui_flavor_info = SuiInfo::new(pre_compiled_lib, modules, &info);
info.sui_flavor_info = Some(sui_flavor_info);
};
info
}
}

Expand Down
Loading

0 comments on commit 601ff73

Please sign in to comment.