defer statements

This commit is contained in:
gingerBill
2016-08-16 18:53:02 +01:00
parent 5da6b74567
commit 2d49a61563
13 changed files with 338 additions and 454 deletions
+28 -8
View File
@@ -1,16 +1,34 @@
#load "basic.odin"
#load "win32.odin"
constant := 1;
main :: proc() {
print_string("Hellope\n");
defer print_string("World\n");
win32_perf_count_freq: i64 = win32_get_perf_count_freq();
win32_get_perf_count_freq :: proc() -> i64 {
r: i64;
_ = QueryPerformanceFrequency(^r);
return r;
for i := 0; i < 4; i++ {
defer {
print_int(i);
print_rune('\n');
}
if i > 2 {
defer print_string("break\n");
break;
}
if i == 2 {
// return;
}
}
print_string("Never called\n");
}
/*
#load "win32.odin"
win32_perf_count_freq := GetQueryPerformanceFrequency();
time_now :: proc() -> f64 {
if win32_perf_count_freq == 0 {
debug_trap();
@@ -22,7 +40,6 @@ time_now :: proc() -> f64 {
return result;
}
win32_print_last_error :: proc() {
err_code := GetLastError() as int;
if err_code != 0 {
@@ -33,6 +50,7 @@ win32_print_last_error :: proc() {
}
main :: proc() {
/*
wc: WNDCLASSEXA;
instance := GetModuleHandleA(null);
@@ -113,4 +131,6 @@ main :: proc() {
sleep_ms(16);
}
*/
}
*/