aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/demo.odin34
-rw-r--r--examples/runtime.odin9
2 files changed, 31 insertions, 12 deletions
diff --git a/examples/demo.odin b/examples/demo.odin
index a0441921c..492974e3c 100644
--- a/examples/demo.odin
+++ b/examples/demo.odin
@@ -3,6 +3,26 @@
#load "game.odin"
main :: proc() {
+
+
+ match x := "1"; x {
+ case "1":
+ print_string("1!\n")
+ case "2":
+ print_string("2!\n")
+ if true {
+ break
+ }
+ case "3", "4":
+ print_string("3 or 4!\n")
+ fallthrough
+ default:
+ print_string("default!\n")
+ }
+
+ nl()
+
+/*
Vec3 :: type struct { x, y, z: f32 }
Entity :: type struct {
using pos: Vec3
@@ -19,11 +39,11 @@ main :: proc() {
}
f := Frog{};
- f.name = "ribbit";
- f.jump_height = 1337;
+ f.name = "ribbit"
+ f.jump_height = 1337
- e := ^f.entity;
- parent := e down_cast ^Frog;
+ e := ^f.entity
+ parent := e down_cast ^Frog
print_name :: proc(using e: Entity, v: Vec3) {
print_string(name); nl()
@@ -35,10 +55,8 @@ main :: proc() {
print_name(f, Vec3{1, 2, 3})
print_name(parent, Vec3{3, 2, 1})
-
-
+*/
}
-
-nl :: proc() #inline { print_nl() }
+nl :: proc() { print_nl() }
diff --git a/examples/runtime.odin b/examples/runtime.odin
index e203aaca1..6663819d4 100644
--- a/examples/runtime.odin
+++ b/examples/runtime.odin
@@ -365,13 +365,14 @@ __default_allocator_proc :: proc(allocator_data: rawptr, mode: AllocationMode,
size, alignment: int,
old_memory: rawptr, old_size: int, flags: u64) -> rawptr {
using AllocationMode
- if mode == ALLOC {
+ match mode {
+ case ALLOC:
return heap_alloc(size)
- } else if mode == RESIZE {
+ case RESIZE:
return default_resize_align(old_memory, old_size, size, alignment)
- } else if mode == DEALLOC {
+ case DEALLOC:
heap_free(old_memory)
- } else if mode == DEALLOC_ALL {
+ case DEALLOC_ALL:
// NOTE(bill): Does nothing
}