diff --git a/ccodegen.cpp b/ccodegen.cpp index 5a4c4f9..b13a407 100644 --- a/ccodegen.cpp +++ b/ccodegen.cpp @@ -548,7 +548,8 @@ gen_ast(Ast *ast){ } CASE(VAR_UNPACK, Var_Unpack){ - For(node->vars) {gen_ast(it);} + For(node->vars) + gen_ast(it); Scratch scratch; gen_simple_decl(node->resolved_type); @@ -559,9 +560,8 @@ gen_ast(Ast *ast){ gen(";"); int i = 0; - For(node->vars) { - gen("%Q = %Q.m%d;", it->name, var_name, i); - } + For(node->vars) + gen("%Q = %Q.m%d;", it->name, var_name, i++); BREAK(); } @@ -717,7 +717,6 @@ end_compilation(){ #if 1 gen(R"==( #include -#include #include typedef int8_t S8; typedef int16_t S16; diff --git a/programs/main.kl b/programs/main.kl index 74d1e87..c5644c3 100644 --- a/programs/main.kl +++ b/programs/main.kl @@ -3,6 +3,7 @@ #load "user32.kl" #load "os.kl" +question_mark16 :: 0x003f String16 :: struct;; str: *U16; len: S64 String32 :: struct;; str: *U32; len: S64 UTF32_Result :: struct @@ -13,7 +14,6 @@ UTF16_Result :: struct out_str: [2]U16 len : S64 error : S64 -question_mark16 :: 0x003f utf8_to_utf32 :: (c: *U8, max_advance: S64): UTF32_Result @@ -77,7 +77,7 @@ allocate :: (size: U64): *void process_heap = GetProcessHeap() return HeapAlloc(process_heap, 0, size) -string_to_string16 :: (in: String): String16 +string_to_string16 :: (in: String): *U16, S64 in_str := &in[0] // @Note(Krzosa): Should be more then enough space alloc_size := (length_of(in)*2)+1 @@ -98,12 +98,12 @@ string_to_string16 :: (in: String): String16 break result.str[result.len] = 0 - return result + return result.str, result.len test_unicode :: () string := " 豈 更 車 賈 滑 串 句 龜 龜 契 金 喇 奈 懶 癩 羅 蘿 螺 裸 邏 樂 洛 烙 珞 落 酪 駱 亂 卵 欄 爛 蘭 鸞 嵐 濫 藍 襤 拉 臘 蠟 廊 朗 浪 狼 郎 來 冷 勞 擄 櫓 爐 盧 老 蘆 虜 路 露 魯 鷺 碌 祿 綠 菉 錄 鹿 論 壟 弄 籠 聾 牢 磊 賂 雷 壘 屢 樓 淚 漏 累 縷 陋 勒 肋 凜 凌 稜 綾 菱 陵 讀 拏 樂 諾 丹 寧 怒 率 異 北 磻 便 復 不 泌 數 索 參 塞 省 葉 說 殺 辰 沈 拾 若 掠 略 亮 兩 凉 梁 糧 良 諒 量 勵 ..." - string_result := string_to_string16(string) - print(string_result) + string_result, string_result_len := string_to_string16(string) + // print(string_result) result := utf8_to_utf32(&"A"[0], 1) assert(result.out_str == 'A, "Invalid decode") // ' @@ -153,27 +153,20 @@ window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRE return 0 else;; return DefWindowProcW(hwnd, msg, wparam, lparam) -multiple_return_values :: (i: int): int, int - return i, i*2 - -slice :: (i: []int) - return - WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nShowCmd: int): int - a, b := multiple_return_values(10) - window_name := string_to_string16("Have a wonderful day! 豈 更 車 賈 滑 串 句 龜 ") + window_name, window_name_len := string_to_string16("Have a wonderful day! 豈 更 車 賈 滑 串 句 龜 ") w := WNDCLASSW{ lpfnWndProc = window_procedure, hInstance = hInstance, - lpszClassName = window_name.str, + lpszClassName = window_name, } assert(RegisterClassW(&w) != 0) window := CreateWindowExW( dwExStyle = 0, hWndParent = 0, hMenu = 0, lpParam = 0, X = CW_USEDEFAULT, Y = CW_USEDEFAULT, nWidth = 1280, nHeight = 720, - lpClassName = window_name.str, - lpWindowName = window_name.str, + lpClassName = window_name, + lpWindowName = window_name, dwStyle = WS_OVERLAPPEDWINDOW, hInstance = hInstance )