Skip to content

Commit

Permalink
docs: add missing function documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Mar 21, 2020
1 parent c4b2c8e commit e68435e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/mun_codegen/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ pub trait Intrinsic: Sync {
}

intrinsics! {
/// Allocates memory for the specified type.
/// Allocates memory for the specified `type` in the allocator referred to by `alloc_handle`.
pub fn new(type: *const TypeInfo, alloc_handle: *mut ffi::c_void) -> *const *mut ffi::c_void;
/// Allocates memory for and clones the specified type located at `src` into it.
/// Allocates memory for and clones the specified type located at `src` into it. Memory is
/// allocated in the allocator referred to by `alloc_handle`.
pub fn clone(src: *const ffi::c_void, alloc_handle: *mut ffi::c_void) -> *const *mut ffi::c_void;
}
2 changes: 2 additions & 0 deletions crates/mun_codegen/src/ir/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ impl<'a, 'b, D: IrDatabase> BodyIrGenerator<'a, 'b, D> {

/// Given an expression and the type of the expression, optionally dereference the value.
fn opt_deref_value(&mut self, ty: hir::Ty, value: BasicValueEnum) -> BasicValueEnum {
/// Derefs a heap-allocated value. As we introduce a layer of introduction for hot
/// reloading, we need to first load the pointer that points to the memory block.
fn deref_heap_value(builder: &Builder, value: BasicValueEnum) -> BasicValueEnum {
let mem_ptr = builder
.build_load(value.into_pointer_value(), "mem_ptr")
Expand Down
6 changes: 6 additions & 0 deletions crates/mun_codegen/src/ir/type_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use inkwell::{
use std::collections::{BTreeSet, HashMap};
use std::{mem, sync::Arc};

/// A type table in IR is a list of pointers to unique type information that are used to generate
/// function and struct information.
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct TypeTable {
type_info_to_index: HashMap<TypeInfo, usize>,
Expand All @@ -22,6 +24,9 @@ pub struct TypeTable {
}

impl TypeTable {
/// Generates a `TypeInfo` lookup through the `TypeTable`, equivalent to something along the
/// lines of: `type_table[i]`, where `i` is the index of the type and `type_table` is an array
/// of `TypeInfo` pointers.
pub fn gen_type_info_lookup(
&self,
builder: &inkwell::builder::Builder,
Expand All @@ -44,6 +49,7 @@ impl TypeTable {
.into_pointer_value()
}

/// Retrieves the pointer to a `TypeInfo`, if it exists in the `TypeTable`.
pub fn get(&self, type_info: &TypeInfo) -> Option<PointerValue> {
self.type_info_to_index
.get(type_info)
Expand Down

0 comments on commit e68435e

Please sign in to comment.