Skip to content

Commit

Permalink
Fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
VonTum committed Nov 1, 2024
1 parent f617833 commit 0c02b0f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/dev_aid/lsp/hover_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub fn hover(info: LocationInfo, linker: &Linker, file_data: &FileData) -> Vec<M
));

let show_interfaces = submodule.is_multi_domain().then_some(InterfaceToDomainMap {
local_domain_map: &submod.local_interface_domains.get().unwrap(),
local_domain_map: &submod.local_interface_domains,
domains: &md.domains,
});
hover.sus_code(submodule.make_all_ports_info_string(
Expand Down
14 changes: 12 additions & 2 deletions src/flattening/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,15 @@ impl<'l, 'errs : 'l> FlatteningContext<'l, 'errs> {
}
let name = &self.globals.file_data.file_text[name_span];

let md = &self.globals[module_ref.id];
let local_interface_domains = md
.domain_names
.map(|_| DomainType::DomainVariable(self.type_alloc.domain_variable_alloc.alloc()));

let submod_id = self.instructions.alloc(Instruction::SubModule(SubModuleInstance{
name : Some((name.to_owned(), name_span)),
module_ref,
local_interface_domains : OnceCell::new(),
local_interface_domains,
documentation
}));

Expand Down Expand Up @@ -817,11 +822,16 @@ impl<'l, 'errs : 'l> FlatteningContext<'l, 'errs> {
PartialWireReference::GlobalModuleName(module_ref) => {
let documentation = cursor.extract_gathered_comments();
let interface_span = module_ref.span;
let md = &self.globals[module_ref.id];
let local_interface_domains = md
.domain_names
.map(|_| DomainType::DomainVariable(self.type_alloc.domain_variable_alloc.alloc()));

let submodule_decl =
self.instructions.alloc(Instruction::SubModule(SubModuleInstance {
name: None,
module_ref,
local_interface_domains: OnceCell::new(),
local_interface_domains,
documentation,
}));
Some(ModuleInterfaceReference {
Expand Down
2 changes: 1 addition & 1 deletion src/flattening/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ pub struct SubModuleInstance {
/// Maps each of the module's local domains to the domain that it is used in.
///
/// These are *always* [DomainType::Physical] (of course, start out as [DomainType::DomainVariable] before typing)
pub local_interface_domains: OnceCell<FlatAlloc<DomainType, DomainIDMarker>>,
pub local_interface_domains: FlatAlloc<DomainType, DomainIDMarker>,
pub documentation: Documentation,
}

Expand Down
10 changes: 2 additions & 8 deletions src/flattening/typechecking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'l, 'errs> TypeCheckingContext<'l, 'errs> {
let submodule_module = &self.globals[submodule_inst.module_ref.id];
let decl = submodule_module.get_port_decl(port);
let port_interface = submodule_module.ports[port].domain;
let port_local_domain = submodule_inst.local_interface_domains.get().unwrap()[port_interface];
let port_local_domain = submodule_inst.local_interface_domains[port_interface];
let typ = AbstractType::Unknown(self.type_checker.alloc_typ_variable());
self.type_checker.unify_with_written_type_substitute_templates_must_succeed(&decl.typ_expr, &typ, &submodule_inst.module_ref.template_arg_types);
FullType {
Expand Down Expand Up @@ -378,12 +378,6 @@ impl<'l, 'errs> TypeCheckingContext<'l, 'errs> {
match &self.working_on.instructions[instr_id] {
Instruction::SubModule(sm) => {
self.typecheck_template_global(&sm.module_ref);
let md = &self.globals[sm.module_ref.id];
let local_interface_domains = md
.domain_names
.map(|_| DomainType::DomainVariable(self.type_checker.alloc_domain_variable()));

sm.local_interface_domains.set(local_interface_domains).unwrap();
}
Instruction::Declaration(decl) => {
if let Some(latency_spec) = decl.latency_specifier {
Expand Down Expand Up @@ -557,7 +551,7 @@ pub fn apply_types(
Instruction::Write(Write { to_type, to_span, .. }) => type_checker.finalize_type(types, to_type, *to_span, errors),
// TODO Submodule domains may not be crossed either?
Instruction::SubModule(sm) => {
for (_domain_id_in_submodule, domain_assigned_to_it_here) in sm.local_interface_domains.get_mut().unwrap() {
for (_domain_id_in_submodule, domain_assigned_to_it_here) in &mut sm.local_interface_domains {
type_checker.finalize_domain_type(domain_assigned_to_it_here);
}
for (_template_id, template_type) in &mut sm.module_ref.template_arg_types {
Expand Down
4 changes: 2 additions & 2 deletions src/instantiation/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> {
} else {
RealWireDataSource::ReadOnly
};
let domain = submodule_instruction.local_interface_domains.get().unwrap()[port_data.domain];
let domain = submodule_instruction.local_interface_domains[port_data.domain];
let new_wire = self.wires.alloc(RealWire {
source,
original_instruction: submod_instance.original_instruction,
Expand Down Expand Up @@ -689,7 +689,7 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> {
let submod_interface_domain =
submod_md.interfaces[fc.interface_reference.submodule_interface].domain;
let domain =
original_submod_instr.local_interface_domains.get().unwrap()[submod_interface_domain];
original_submod_instr.local_interface_domains[submod_interface_domain];

add_to_small_set(
&mut self.submodules[submod_id].interface_call_sites
Expand Down

0 comments on commit 0c02b0f

Please sign in to comment.