-
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.
Typechecker2: Add default toString/hash/eq method stubs onto each `enum` declaration, similar to how it works for `type`s. LLVM2: Add compilation for enums with basic/constant variants, in addition to default implementations of toString/hash/eq.
- Loading branch information
Showing
6 changed files
with
607 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,57 @@ | ||
// TODO: This shouldn't stackoverflow | ||
//println([]) | ||
|
||
val i: Int? = 17 | ||
|
||
if !i { | ||
println("i is None") | ||
enum Color { | ||
Red | ||
Blue | ||
Green | ||
} | ||
|
||
println("done") | ||
val colors = [Color.Red, Color.Green, Color.Blue] | ||
println(colors[3]?.toString()) | ||
println(colors[2]?.toString()) | ||
|
||
//enum Color { | ||
// Red | ||
// Blue | ||
// Green | ||
// | ||
// func hex(self): String { | ||
// if self == Color.Red { | ||
// "0xFF0000" | ||
// } else if self == Color.Green { | ||
// "0x00FF00" | ||
// } else if self == Color.Blue { | ||
// "0x0000FF" | ||
// } else { | ||
// "unreachable" | ||
// } | ||
// } | ||
//} | ||
// | ||
//val r = Color.Red | ||
//val b = Color.Blue | ||
//val g = Color.Green | ||
// | ||
////println(b) | ||
////r.toString() | ||
////b.hash() | ||
// | ||
////r == r | ||
// | ||
////func hex(color: Color): String { | ||
//// if color == Color.Red { | ||
//// "0xFF0000" | ||
//// } else if color == Color.Green { | ||
//// "0x00FF00" | ||
//// } else if color == Color.Blue { | ||
//// "0x0000FF" | ||
//// } else { | ||
//// "unreachable" | ||
//// } | ||
////} | ||
// | ||
////hex(b) | ||
// | ||
//r.hex() | ||
// |
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
Oops, something went wrong.