This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move function linking to its own pass (#150)
* Specify that function is from trait * Move linking to its own pass * Fix llvm version in worlkflow
- Loading branch information
1 parent
e2b0344
commit 88c0ef1
Showing
5 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use derive_visitor::VisitorMut; | ||
use log::debug; | ||
|
||
use crate::hir::{Call, Generic, Type}; | ||
|
||
use super::Context; | ||
|
||
#[derive(VisitorMut)] | ||
#[visitor(Call(exit))] | ||
pub struct TraitFunctionsLinker<'ctx, C: Context> { | ||
context: &'ctx mut C, | ||
} | ||
|
||
impl<'ctx, C: Context> TraitFunctionsLinker<'ctx, C> { | ||
pub fn new(context: &'ctx mut C) -> Self { | ||
Self { context } | ||
} | ||
|
||
fn exit_call(&mut self, call: &mut Call) { | ||
let f = call.function.read().unwrap(); | ||
// FIXME: definition may be overrided | ||
if f.is_generic() || !f.is_from_trait() || f.is_definition() { | ||
return; | ||
} | ||
|
||
debug!(target: "linking-trait-fn-from", "{f}"); | ||
// Unknown type here is ok, because we don't have selfs any more | ||
let real_impl = self | ||
.context | ||
.find_implementation(&f, &Type::Unknown) | ||
.unwrap(); | ||
drop(f); | ||
|
||
call.function = real_impl; | ||
debug!(target: "linking-trait-fn-to", "{}", call.function); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,6 @@ pub use unnamed::*; | |
|
||
mod replace_self; | ||
pub use replace_self::*; | ||
|
||
mod link_impls; | ||
pub use link_impls::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters