Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Fix trait with ref test
Browse files Browse the repository at this point in the history
  • Loading branch information
gavrilikhin-d committed May 12, 2024
1 parent 74fdd0e commit 0d56e26
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 28 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
* [x] Destructors for parameters
* [x] No tmps for literals inside of constructors
* [x] Fix recursive trait (AsString with prints)
* [x] Fix references in traits test
---
### Current task
* [ ] Benchmark for linear algebra
* [ ] Printable trait should take references
---
* [ ] Benchmark for linear algebra
* [ ] Sum of series benchmark
* [ ] Find test that is taking infinite time
* [ ] Use traits to check for `clone` and `destructoy` functions
* [ ] Forbid recursion without `@recursive` annotation
* [ ] Generate clone for types with clonable members
Expand Down
19 changes: 11 additions & 8 deletions src/hir/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ impl Display for ModuleData {
for statement in &self.statements {
writeln!(f, "{:#}", statement)?;
}
writeln!(f, "\n==MONOMORPHIZED==\n")?;
for fun in self
.monomorphized_functions
.iter()
.filter(|f| !f.read().unwrap().is_generic())
{
writeln!(f, "{fun}")?;

if !self.monomorphized_functions.is_empty() {
writeln!(f, "\n==MONOMORPHIZED==\n")?;
for fun in self
.monomorphized_functions
.iter()
.filter(|f| !f.read().unwrap().is_generic())
{
writeln!(f, "{fun}")?;
}
}

Ok(())
Expand Down Expand Up @@ -149,7 +152,7 @@ impl ModuleData {
/// Iterate over all functions with `n` name parts
pub fn functions_with_n_name_parts(&self, n: usize) -> impl Iterator<Item = &Function> + '_ {
self.iter_functions()
.filter(move |f| f.read().unwrap().name_parts().len() == n)
.filter(move |f| f.read().is_ok_and(|f| f.name_parts().len() == n))
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__common_functions.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ fn foo -> None:
return ($tmp@10:None)

foo

==MONOMORPHIZED==
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__consume_greater.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ type Point<U>:
x: U

Point<Integer> { x: 1 }

==MONOMORPHIZED==
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__deps.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ expression: hir
---
use helper.*
say hello

==MONOMORPHIZED==
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__destructor.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ destroy (x:Destructible)
(x:Destructible) = Destructible { }
println "done"
destroy (x:Destructible)

==MONOMORPHIZED==
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__escaped_id.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ let mut if: Integer = 1
destroy (if:Integer)
(if:Integer) = 2
destroy (if:Integer)

==MONOMORPHIZED==
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__multifile.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ expression: hir
---
use greet.greet <:String>
greet "World"

==MONOMORPHIZED==
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__ppl.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ use memory.*
use threads.*
use math.*
use printable.*

==MONOMORPHIZED==
2 changes: 0 additions & 2 deletions src/tests/snapshots/ppl__tests__reference_to_none.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ fn foo <$arg0: Reference<None>> -> None:

let x: None = none
foo (&x:Reference<None>)

==MONOMORPHIZED==
7 changes: 6 additions & 1 deletion src/tests/snapshots/ppl__tests__trait_with_ref.hir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ source: src/tests/mod.rs
expression: hir
---
trait Foo:
fn foo <$arg0: Reference<Integer>> -> None

fn foo <$arg0: Reference<Integer>> -> None:
let $tmp@51: None = println "foo integer"
return ($tmp@51:None)




fn foo <$arg0: Reference<Integer>> -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/tests/snapshots/ppl__tests__trait_with_ref.ir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define void @"bar <:Reference<Foo>>"(ptr %0) !dbg !19 {
%x = alloca ptr, align 8
store ptr %0, ptr %x, align 8
call void @"foo <:Reference<Integer>>"(ptr %x), !dbg !20
br label %return, !dbg !20
br label %return, !dbg !21

return: ; preds = %1
ret void
Expand Down Expand Up @@ -103,3 +103,4 @@ declare void @destroy_integer(ptr)
!18 = !DILocation(line: 7, column: 8, scope: !17)
!19 = distinct !DISubprogram(name: "bar <:Reference<Foo>>", linkageName: "bar <:Reference<Foo>>", scope: !9, file: !2, line: 5, type: !4, spFlags: DISPFlagDefinition, unit: !1)
!20 = !DILocation(line: 5, column: 24, scope: !19)
!21 = !DILocation(line: 5, column: 20, scope: !19)

0 comments on commit 0d56e26

Please sign in to comment.