aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-01-03 20:07:46 +0000
committerGinger Bill <bill@gingerbill.org>2017-01-03 20:07:46 +0000
commitcff1b3dff6d169675309d3f7a8433ed55b9a2007 (patch)
treead144e56efead6456064261b086bdc3befaada50 /code
parent883dd0642c377840e3baaca341ea147e53c2d2d5 (diff)
v0.0.5
Fix enumerations to so they work as integers in indices; Add llir_opt.c and llir_print.c
Diffstat (limited to 'code')
-rw-r--r--code/demo.odin75
1 files changed, 51 insertions, 24 deletions
diff --git a/code/demo.odin b/code/demo.odin
index a7bf7aa88..3680c8957 100644
--- a/code/demo.odin
+++ b/code/demo.odin
@@ -1,33 +1,60 @@
-#import "atomic.odin";
#import "fmt.odin";
-#import "hash.odin";
-#import "math.odin";
-#import "mem.odin";
-#import "opengl.odin";
-#import "os.odin";
-#import "sync.odin";
-#import "utf8.odin";
-#import win32 "sys/windows.odin";
-Thing :: enum f64 {
- _, // Ignore first value
- A = 1<<(10*iota),
- B,
- C,
- D,
-}
+
main :: proc() {
- msg := "Hellope";
- list := []int{1, 4, 7, 3, 7, 2, 1};
+ {
+ Byte_Size :: enum f64 {
+ _, // Ignore first value
+ KB = 1<<(10*iota),
+ MB,
+ GB,
+ TB,
+ PB,
+ }
+
+ using Byte_Size;
+ fmt.println(KB, MB, GB, TB, PB);
+ }
+ {
+ x := if 1 < 2 {
+ y := 123;
+ give y-2;
+ } else {
+ give 0;
+ };
+
+ x += {
+ x := 2;
+ give x;
+ };
- for value : msg {
- fmt.println(value);
+ fmt.println("x =", x);
}
- for value : list {
- fmt.println(value);
+ {
+ list := []int{1, 4, 7, 3, 7, 2, 1};
+ for value : list {
+ fmt.println(value);
+ }
+ for val, idx : 12 ..< 17 {
+ fmt.println(val, idx);
+ }
+ msg := "Hellope";
+ for value : msg {
+ fmt.println(value);
+ }
}
- for val, idx : 12 ..< 17 {
- fmt.println(val, idx);
+ {
+ i := 0;
+ while i < 2 {
+ i += 1;
+ }
+
+ // Idiom to emulate C-style for loops
+ while x := 0; x < 2 {
+ defer x += 1;
+ // Body of code
+ // ++ and -- have been removed
+ }
}
}