-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds the >,>=,<=,<,==,!= operators to the language. It also contains a rewrite of how tests are performed so that instead of using *.mun files, the test are written in Rust which enables testing of individual test cases with a little more ease.
- Loading branch information
1 parent
b6d5864
commit 2f892f5
Showing
86 changed files
with
1,494 additions
and
647 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
79 changes: 79 additions & 0 deletions
79
crates/mun_codegen/src/snapshots/test__equality_operands.snap
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,79 @@ | ||
--- | ||
source: crates/mun_codegen/src/test.rs | ||
expression: "fn equals(a:int, b:int):bool { a == b }\nfn not_equals(a:int, b:int):bool { a != b }\nfn less(a:int, b:int):bool { a < b }\nfn less_equal(a:int, b:int):bool { a <= b }\nfn greater(a:int, b:int):bool { a > b }\nfn greater_equal(a:int, b:int):bool { a >= b }\nfn equalsf(a:float, b:float):bool { a == b }\nfn not_equalsf(a:float, b:float):bool { a != b }\nfn lessf(a:float, b:float):bool { a < b }\nfn less_equalf(a:float, b:float):bool { a <= b }\nfn greaterf(a:float, b:float):bool { a > b }\nfn greater_equalf(a:float, b:float):bool { a >= b }" | ||
--- | ||
; ModuleID = 'main.mun' | ||
source_filename = "main.mun" | ||
|
||
define i1 @equals(i64 %a, i64 %b) { | ||
body: | ||
%eq = icmp eq i64 %a, %b | ||
ret i1 %eq | ||
} | ||
|
||
define i1 @not_equals(i64 %a, i64 %b) { | ||
body: | ||
%neq = icmp ne i64 %a, %b | ||
ret i1 %neq | ||
} | ||
|
||
define i1 @less(i64 %a, i64 %b) { | ||
body: | ||
%less = icmp slt i64 %a, %b | ||
ret i1 %less | ||
} | ||
|
||
define i1 @less_equal(i64 %a, i64 %b) { | ||
body: | ||
%lesseq = icmp sle i64 %a, %b | ||
ret i1 %lesseq | ||
} | ||
|
||
define i1 @greater(i64 %a, i64 %b) { | ||
body: | ||
%greater = icmp sgt i64 %a, %b | ||
ret i1 %greater | ||
} | ||
|
||
define i1 @greater_equal(i64 %a, i64 %b) { | ||
body: | ||
%greatereq = icmp sge i64 %a, %b | ||
ret i1 %greatereq | ||
} | ||
|
||
define i1 @equalsf(double %a, double %b) { | ||
body: | ||
%eq = fcmp oeq double %a, %b | ||
ret i1 %eq | ||
} | ||
|
||
define i1 @not_equalsf(double %a, double %b) { | ||
body: | ||
%neq = fcmp one double %a, %b | ||
ret i1 %neq | ||
} | ||
|
||
define i1 @lessf(double %a, double %b) { | ||
body: | ||
%less = fcmp olt double %a, %b | ||
ret i1 %less | ||
} | ||
|
||
define i1 @less_equalf(double %a, double %b) { | ||
body: | ||
%lesseq = fcmp ole double %a, %b | ||
ret i1 %lesseq | ||
} | ||
|
||
define i1 @greaterf(double %a, double %b) { | ||
body: | ||
%greater = fcmp ogt double %a, %b | ||
ret i1 %greater | ||
} | ||
|
||
define i1 @greater_equalf(double %a, double %b) { | ||
body: | ||
%greatereq = fcmp oge double %a, %b | ||
ret i1 %greatereq | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
...n_codegen/tests/data/ir/0001_function.txt → ...codegen/src/snapshots/test__function.snap
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
--- | ||
source: crates/mun_codegen/src/test.rs | ||
expression: "fn main() {\n}" | ||
--- | ||
; ModuleID = 'main.mun' | ||
source_filename = "main.mun" | ||
|
||
define void @main() { | ||
body: | ||
ret void | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
...tests/data/ir/0003_function_arguments.txt → ...c/snapshots/test__function_arguments.snap
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
--- | ||
source: crates/mun_codegen/src/test.rs | ||
expression: "fn main(a:int):int {\n a\n}" | ||
--- | ||
; ModuleID = 'main.mun' | ||
source_filename = "main.mun" | ||
|
||
define i64 @main(i64 %a) { | ||
body: | ||
ret i64 %a | ||
} | ||
|
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
6 changes: 6 additions & 0 deletions
6
crates/mun_codegen/src/snapshots/test__invalid_binary_ops.snap
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,6 @@ | ||
--- | ||
source: crates/mun_codegen/src/test.rs | ||
expression: "fn main() {\n let a = 3+3.0;\n let b = 3.0+3;\n}" | ||
--- | ||
error 2:13: mismatched type | ||
error 3:15: mismatched type |
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
5 changes: 5 additions & 0 deletions
5
...odegen/tests/data/ir/0002_return_type.txt → ...egen/src/snapshots/test__return_type.snap
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
--- | ||
source: crates/mun_codegen/src/test.rs | ||
expression: "fn main():int {\n 0\n}" | ||
--- | ||
; ModuleID = 'main.mun' | ||
source_filename = "main.mun" | ||
|
||
define i64 @main() { | ||
body: | ||
ret i64 0 | ||
} | ||
|
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
Oops, something went wrong.