mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
use inkwell's FunctionIterator
This commit is contained in:
parent
b907f01f1f
commit
031866799a
3 changed files with 2 additions and 32 deletions
|
@ -1,6 +1,5 @@
|
||||||
use inkwell::memory_buffer::MemoryBuffer;
|
use inkwell::memory_buffer::MemoryBuffer;
|
||||||
use roc_error_macros::internal_error;
|
use roc_error_macros::internal_error;
|
||||||
pub use roc_gen_llvm::llvm::build::FunctionIterator;
|
|
||||||
use roc_gen_llvm::llvm::build::{module_from_builtins, LlvmBackendMode};
|
use roc_gen_llvm::llvm::build::{module_from_builtins, LlvmBackendMode};
|
||||||
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
|
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
|
||||||
use roc_load::{EntryPoint, ExpectMetadata, LoadedModule, MonomorphizedModule};
|
use roc_load::{EntryPoint, ExpectMetadata, LoadedModule, MonomorphizedModule};
|
||||||
|
@ -256,7 +255,7 @@ fn gen_from_mono_module_llvm<'a>(
|
||||||
debug_assert!(kind_id > 0);
|
debug_assert!(kind_id > 0);
|
||||||
let enum_attr = context.create_enum_attribute(kind_id, 1);
|
let enum_attr = context.create_enum_attribute(kind_id, 1);
|
||||||
|
|
||||||
for function in FunctionIterator::from_module(module) {
|
for function in module.get_functions() {
|
||||||
let name = function.get_name().to_str().unwrap();
|
let name = function.get_name().to_str().unwrap();
|
||||||
|
|
||||||
// mark our zig-defined builtins as internal
|
// mark our zig-defined builtins as internal
|
||||||
|
|
|
@ -91,34 +91,6 @@ macro_rules! debug_info_init {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over all functions in an llvm module
|
|
||||||
pub struct FunctionIterator<'ctx> {
|
|
||||||
next: Option<FunctionValue<'ctx>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'ctx> FunctionIterator<'ctx> {
|
|
||||||
pub fn from_module(module: &inkwell::module::Module<'ctx>) -> Self {
|
|
||||||
Self {
|
|
||||||
next: module.get_first_function(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'ctx> Iterator for FunctionIterator<'ctx> {
|
|
||||||
type Item = FunctionValue<'ctx>;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
match self.next {
|
|
||||||
Some(function) => {
|
|
||||||
self.next = function.get_next_function();
|
|
||||||
|
|
||||||
Some(function)
|
|
||||||
}
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Scope<'a, 'ctx> {
|
pub struct Scope<'a, 'ctx> {
|
||||||
symbols: ImMap<Symbol, (Layout<'a>, BasicValueEnum<'ctx>)>,
|
symbols: ImMap<Symbol, (Layout<'a>, BasicValueEnum<'ctx>)>,
|
||||||
|
|
|
@ -4,7 +4,6 @@ use std::path::PathBuf;
|
||||||
use inkwell::module::Module;
|
use inkwell::module::Module;
|
||||||
use libloading::Library;
|
use libloading::Library;
|
||||||
use roc_build::link::llvm_module_to_dylib;
|
use roc_build::link::llvm_module_to_dylib;
|
||||||
use roc_build::program::FunctionIterator;
|
|
||||||
use roc_collections::all::MutSet;
|
use roc_collections::all::MutSet;
|
||||||
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
|
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
|
||||||
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult};
|
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult};
|
||||||
|
@ -192,7 +191,7 @@ fn create_llvm_module<'a>(
|
||||||
debug_assert!(kind_id > 0);
|
debug_assert!(kind_id > 0);
|
||||||
let attr = context.create_enum_attribute(kind_id, 1);
|
let attr = context.create_enum_attribute(kind_id, 1);
|
||||||
|
|
||||||
for function in FunctionIterator::from_module(module) {
|
for function in module.get_functions() {
|
||||||
let name = function.get_name().to_str().unwrap();
|
let name = function.get_name().to_str().unwrap();
|
||||||
if name.starts_with("roc_builtins") {
|
if name.starts_with("roc_builtins") {
|
||||||
if name.starts_with("roc_builtins.expect") {
|
if name.starts_with("roc_builtins.expect") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue