diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-18 19:24:45 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-18 19:24:45 +0100 |
| commit | 59fb7b020a5e0bd2d23daab0f74e9cfa23420afc (patch) | |
| tree | 435bd10ec767d4bdf56bfc3d232c0c9debea18d8 /code/demo.odin | |
| parent | 65f079ebc474f9decc7afb222630c04b4da32690 (diff) | |
Merge `raw_union` into `struct` as a memory layout tag `#raw_union`
Diffstat (limited to 'code/demo.odin')
| -rw-r--r-- | code/demo.odin | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/code/demo.odin b/code/demo.odin index 9ecf20aef..903278399 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -130,18 +130,16 @@ get_hash :: proc(s: string) -> u32 { -Vector :: struct(N: int, T: type) { - using _: raw_union { - using e: [N]T; - when 0 < N && N <= 4 { - using v: struct { - when N >= 1 do x: T; - when N >= 2 do y: T; - when N >= 3 do z: T; - when N >= 4 do w: T; - }; - -} }; +Vector :: struct(N: int, T: type) #raw_union { + using e: [N]T; + when 0 < N && N <= 4 { + using v: struct { + when N >= 1 do x: T; + when N >= 2 do y: T; + when N >= 3 do z: T; + when N >= 4 do w: T; + }; + } } Vector3 :: Vector(3, f32); @@ -161,17 +159,17 @@ foo3 :: proc(a: type/Vector(3, $T)) { fmt.println("foo3", a{}); } main :: proc() { - Foo :: struct { - a := 123; - b := true; - } - v1 := Foo{}; - fmt.println(v1); + // Foo :: struct { + // a := 123; + // b := true; + // } + // v1 := Foo{}; + // fmt.println(v1); - foo1(Vector(3, f32)); - foo1(Vector3); - foo3(Vector(3, f32)); - foo3(Vector3); + // foo1(Vector(3, f32)); + // foo1(Vector3); + // foo3(Vector(3, f32)); + // foo3(Vector3); a, b: Vector3; @@ -184,17 +182,18 @@ main :: proc() { b.z = 5; v := add(a, b); - fmt.println(v.v); + fmt.println(size_of(Vector3)); + fmt.println(v.e, v.v); - table: Table(string, int); + // table: Table(string, int); - for i in 0..36 do put(&table, "Hellope", i); - for i in 0..42 do put(&table, "World!", i); + // for i in 0..36 do put(&table, "Hellope", i); + // for i in 0..42 do put(&table, "World!", i); - found, _ := find(&table, "Hellope"); - fmt.printf("found is %v\n", found); + // found, _ := find(&table, "Hellope"); + // fmt.printf("found is %v\n", found); - found, _ = find(&table, "World!"); - fmt.printf("found is %v\n", found); + // found, _ = find(&table, "World!"); + // fmt.printf("found is %v\n", found); } |