Add comments to group code together

This commit is contained in:
Brian Carroll 2021-12-18 00:23:31 +00:00
parent 71bb756d20
commit 55f5956175

View file

@ -77,6 +77,12 @@ impl<'a> CodeGenHelp<'a> {
} }
} }
// ============================================================================
//
// CALL GENERATED PROCS
//
// ============================================================================
/// Expand a `Refcounting` node to a `Let` node that calls a specialized helper proc. /// Expand a `Refcounting` node to a `Let` node that calls a specialized helper proc.
/// The helper procs themselves are to be generated later with `generate_procs` /// The helper procs themselves are to be generated later with `generate_procs`
pub fn expand_refcount_stmt( pub fn expand_refcount_stmt(
@ -218,6 +224,13 @@ impl<'a> CodeGenHelp<'a> {
(expr, new_procs_info) (expr, new_procs_info)
} }
// ============================================================================
//
// TRAVERSE LAYOUT & CREATE PROC NAMES
//
// ============================================================================
/// Find the Symbol of the procedure for this layout and operation /// Find the Symbol of the procedure for this layout and operation
/// If any new helper procs are needed for this layout or its children, /// If any new helper procs are needed for this layout or its children,
/// return their details in a vector. /// return their details in a vector.
@ -340,6 +353,12 @@ impl<'a> CodeGenHelp<'a> {
Symbol::new(self.home, ident_id) Symbol::new(self.home, ident_id)
} }
// ============================================================================
//
// GENERATE PROCS
//
// ============================================================================
/// Generate refcounting helper procs, each specialized to a particular Layout. /// Generate refcounting helper procs, each specialized to a particular Layout.
/// For example `List (Result { a: Str, b: Int } Str)` would get its own helper /// For example `List (Result { a: Str, b: Int } Str)` would get its own helper
/// to update the refcounts on the List, the Result and the strings. /// to update the refcounts on the List, the Result and the strings.
@ -399,13 +418,9 @@ impl<'a> CodeGenHelp<'a> {
eq_todo() eq_todo()
} }
Layout::Struct(_) => eq_todo(), Layout::Struct(_) => eq_todo(),
Layout::Union(union_layout) => match union_layout { Layout::Union(union_layout) => {
UnionLayout::NonRecursive(_) => eq_todo(), self.eq_tag_union(ident_ids, proc_symbol, union_layout)
UnionLayout::Recursive(_) => eq_todo(), }
UnionLayout::NonNullableUnwrapped(_) => eq_todo(),
UnionLayout::NullableWrapped { .. } => eq_todo(),
UnionLayout::NullableUnwrapped { .. } => eq_todo(),
},
Layout::LambdaSet(_) => unreachable!("`==` is not defined on functions"), Layout::LambdaSet(_) => unreachable!("`==` is not defined on functions"),
Layout::RecursivePointer => eq_todo(), Layout::RecursivePointer => eq_todo(),
} }
@ -433,6 +448,12 @@ impl<'a> CodeGenHelp<'a> {
} }
} }
// ============================================================================
//
// GENERATE REFCOUNTING
//
// ============================================================================
/// Generate a procedure to modify the reference count of a Str /// Generate a procedure to modify the reference count of a Str
fn gen_modify_str( fn gen_modify_str(
&mut self, &mut self,
@ -565,6 +586,22 @@ impl<'a> CodeGenHelp<'a> {
host_exposed_layouts: HostExposedLayouts::NotHostExposed, host_exposed_layouts: HostExposedLayouts::NotHostExposed,
} }
} }
// ============================================================================
//
// GENERATE EQUALS
//
// ============================================================================
fn eq_tag_union(
&mut self,
ident_ids: &mut IdentIds,
proc_name: Symbol,
union_layout: UnionLayout<'a>,
) -> Proc<'a> {
//
todo!("return something")
}
} }
/// Helper to derive a debug function name from a layout /// Helper to derive a debug function name from a layout