-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adjust grammar * Extend elvis operator * Add test
- Loading branch information
1 parent
d4b0554
commit 0b4d63f
Showing
9 changed files
with
105 additions
and
7 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
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
3 changes: 3 additions & 0 deletions
3
test/test-files/generator/ternary/success-shortened-ternary/cout.out
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,3 @@ | ||
F1 called. | ||
F2 called. | ||
Result: 1 |
49 changes: 49 additions & 0 deletions
49
test/test-files/generator/ternary/success-shortened-ternary/ir-code.ll
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,49 @@ | ||
; ModuleID = 'source.spice' | ||
source_filename = "source.spice" | ||
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-w64-windows-gnu" | ||
|
||
@0 = private unnamed_addr constant [12 x i8] c"F1 called.\0A\00", align 1 | ||
@1 = private unnamed_addr constant [12 x i8] c"F2 called.\0A\00", align 1 | ||
@2 = private unnamed_addr constant [11 x i8] c"Result: %d\00", align 1 | ||
|
||
define internal i1 @_f__void__f1() { | ||
entry.l1: | ||
%result = alloca i1, align 1 | ||
%0 = call i32 (ptr, ...) @printf(ptr @0) | ||
%1 = alloca i1, align 1 | ||
store i1 false, ptr %1, align 1 | ||
%2 = load i1, ptr %1, align 1 | ||
ret i1 %2 | ||
} | ||
|
||
declare i32 @printf(ptr, ...) | ||
|
||
define internal i1 @_f__void__f2() { | ||
entry.l6: | ||
%result = alloca i1, align 1 | ||
%0 = call i32 (ptr, ...) @printf(ptr @1) | ||
%1 = alloca i1, align 1 | ||
store i1 true, ptr %1, align 1 | ||
%2 = load i1, ptr %1, align 1 | ||
ret i1 %2 | ||
} | ||
|
||
define i32 @main() { | ||
entry.l11: | ||
%result = alloca i32, align 4 | ||
store i32 0, ptr %result, align 4 | ||
%0 = call i1 @_f__void__f1() | ||
%1 = alloca i1, align 1 | ||
store i1 %0, ptr %1, align 1 | ||
%2 = call i1 @_f__void__f2() | ||
%3 = alloca i1, align 1 | ||
store i1 %2, ptr %3, align 1 | ||
%4 = load i1, ptr %1, align 1 | ||
%5 = select i1 %4, ptr %1, ptr %3 | ||
%6 = load i1, ptr %5, align 1 | ||
%7 = zext i1 %6 to i32 | ||
%8 = call i32 (ptr, ...) @printf(ptr @2, i32 %7) | ||
%9 = load i32, ptr %result, align 4 | ||
ret i32 %9 | ||
} |
13 changes: 13 additions & 0 deletions
13
test/test-files/generator/ternary/success-shortened-ternary/source.spice
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,13 @@ | ||
f<bool> f1() { | ||
printf("F1 called.\n"); | ||
return false; | ||
} | ||
|
||
f<bool> f2() { | ||
printf("F2 called.\n"); | ||
return true; | ||
} | ||
|
||
f<int> main() { | ||
printf("Result: %d", f1() ?: f2()); | ||
} |