Added support for unions as a step towards lowering ADTs in the next pass to be written.

This commit is contained in:
Nathan Braswell
2016-06-15 22:26:03 -07:00
parent d44293a48b
commit 4de7dd1210
8 changed files with 55 additions and 13 deletions

View File

@@ -4,6 +4,9 @@ import mem
import serialize
import io
fun to_string(in: bool): string
if (in) return string("true")
else return string("false")
fun to_string(in: uchar): string
return to_string_num(in)
fun to_string(in: short): string
@@ -168,6 +171,7 @@ obj string (Object, Serializable) {
}
fun operator+(integer: int): string return *this + to_string(integer);
fun operator+(b: bool): string return *this + to_string(b);
fun operator+(str: *char): string {
var newStr.construct(str):string
@@ -181,6 +185,7 @@ obj string (Object, Serializable) {
}
fun operator+=(integer: int) *this += to_string(integer);
fun operator+=(b: bool) *this += to_string(b);
fun operator+=(character: char): void {
data += character