compiler: implement binop string: <, <=, >, >=

Include unit tests.
This commit is contained in:
Marc-Antoine Ruel
2018-11-08 15:06:53 -05:00
parent 76d04990f4
commit b1cf69a523
4 changed files with 74 additions and 10 deletions
+18
View File
@@ -32,6 +32,24 @@ func stringEqual(x, y string) bool {
return true
}
// Return true iff x < y.
//go:nobounds
func stringLess(x, y string) bool {
l := len(x)
if m := len(y); m < l {
l = m
}
for i := 0; i < l; i++ {
if x[i] < y[i] {
return true
}
if x[i] > y[i] {
return false
}
}
return len(x) < len(y)
}
// Add two strings together.
func stringConcat(x, y _string) _string {
if x.length == 0 {