Basic when statement - Compile time if statement

This is similar to an #if in C but handled during the semantic checking stage.
This commit is contained in:
Ginger Bill
2016-11-29 22:08:48 +00:00
parent 348bcc3f9a
commit b232b9d5ea
12 changed files with 584 additions and 328 deletions

View File

@@ -1,11 +1,27 @@
#import "fmt.odin"
// #import "fmt.odin"
#import "utf8.odin"
when ODIN_OS == "window" {
when ODIN_OS != "window" {
} else {
MAX :: 64
}
#import "fmt.odin"
} else {
}
main :: proc() {
MAX :: 64
when true {
OffsetType :: type int
}
// MAX :: 64
buf: [MAX]rune
backing: [MAX]byte
offset: int
offset: OffsetType
msg := "Hello"
count := utf8.rune_count(msg)
@@ -17,16 +33,17 @@ main :: proc() {
s := msg[offset:]
r, len := utf8.decode_rune(s)
runes[count-i-1] = r
offset += len
offset += len as OffsetType
}
offset = 0
for i := 0; i < count; i++ {
data, len := utf8.encode_rune(runes[i])
copy(backing[offset:], data[:len])
offset += len
offset += len as OffsetType
}
reverse := backing[:offset] as string
fmt.println(reverse) // olleH
}