Browse Source

Semicolons are required; `when` condition for certain file scope declarations; #import syntax change

Ginger Bill 8 years ago
parent
commit
4bb45700a5
29 changed files with 3431 additions and 3275 deletions
  1. 2 30
      code/demo.odin
  2. 94 94
      code/game.odin
  3. 74 74
      code/http_test.odin
  4. 1 1
      code/old_demos/demo001.odin
  5. 3 3
      code/old_demos/demo002.odin
  6. 1 1
      code/old_demos/old_runtime.odin
  7. 138 140
      code/punity.odin
  8. 1 1
      code/test.odin
  9. 150 172
      core/_preload.odin
  10. 80 81
      core/_soft_numbers.odin
  11. 278 276
      core/fmt.odin
  12. 96 96
      core/hash.odin
  13. 214 217
      core/math.odin
  14. 127 127
      core/mem.odin
  15. 114 116
      core/opengl.odin
  16. 1365 1365
      core/opengl_constants.odin
  17. 2 3
      core/os.odin
  18. 173 0
      core/os_windows.odin
  19. 95 95
      core/utf8.odin
  20. 123 125
      core/win32.odin
  21. 52 73
      src/checker/checker.c
  22. 23 26
      src/checker/decl.c
  23. 2 0
      src/checker/expr.c
  24. 29 22
      src/checker/stmt.c
  25. 3 4
      src/main.c
  26. 120 117
      src/parser.c
  27. 20 13
      src/ssa.c
  28. 49 1
      src/ssa_print.c
  29. 2 2
      src/tokenizer.c

+ 2 - 30
code/demo.odin

@@ -1,34 +1,6 @@
-#import "fmt.odin"
-#import "utf8.odin"
+#import "fmt.odin";
 
 main :: proc() {
-	MAX :: 64
-	buf:     [MAX]rune
-	backing: [MAX]byte
-	offset:  int
-
-	msg := "Hello"
-
-	count := utf8.rune_count(msg)
-	assert(count <= MAX)
-	runes := buf[:count]
-
-	offset = 0
-	for i := 0; i < count; i++ {
-		s := msg[offset:]
-		r, len := utf8.decode_rune(s)
-		runes[count-i-1] = r
-		offset += len
-	}
-
-	offset = 0
-	for i := 0; i < count; i++ {
-		data, len := utf8.encode_rune(runes[i])
-		copy(backing[offset:], data[:len])
-		offset += len
-	}
-
-	reverse := backing[:offset] as string
-	fmt.println(reverse) // olleH
+	fmt.println("Hellope");
 }
 

+ 94 - 94
code/game.odin

@@ -1,60 +1,60 @@
-#import "win32.odin"
-#import "fmt.odin"
-#import "math.odin"
-#import "os.odin"
-#import "opengl.odin" as gl
+#import "win32.odin" when ODIN_OS == "windows";
+#import "fmt.odin";
+#import "math.odin";
+#import "os.odin";
+#import gl "opengl.odin";
 
-TWO_HEARTS :: '💕'
+TWO_HEARTS :: '💕';
 
-win32_perf_count_freq := win32.GetQueryPerformanceFrequency()
+win32_perf_count_freq := win32.GetQueryPerformanceFrequency();
 time_now :: proc() -> f64 {
-	assert(win32_perf_count_freq != 0)
+	assert(win32_perf_count_freq != 0);
 
-	counter: i64
-	win32.QueryPerformanceCounter(^counter)
-	result := counter as f64 / win32_perf_count_freq as f64
-	return result
+	counter: i64;
+	win32.QueryPerformanceCounter(^counter);
+	result := counter as f64 / win32_perf_count_freq as f64;
+	return result;
 }
 win32_print_last_error :: proc() {
-	err_code := win32.GetLastError() as int
+	err_code := win32.GetLastError() as int;
 	if err_code != 0 {
-		fmt.println("GetLastError: %", err_code)
+		fmt.println("GetLastError: %", err_code);
 	}
 }
 
 // Yuk!
 to_c_string :: proc(s: string) -> []u8 {
-	c_str := new_slice(u8, s.count+1)
-	copy(c_str, s as []byte)
-	c_str[s.count] = 0
-	return c_str
+	c_str := new_slice(u8, s.count+1);
+	copy(c_str, s as []byte);
+	c_str[s.count] = 0;
+	return c_str;
 }
 
 
 Window :: struct {
-	width, height:      int
-	wc:                 win32.WNDCLASSEXA
-	dc:                 win32.HDC
-	hwnd:               win32.HWND
-	opengl_context, rc: win32.HGLRC
-	c_title:            []u8
+	width, height:      int;
+	wc:                 win32.WNDCLASSEXA;
+	dc:                 win32.HDC;
+	hwnd:               win32.HWND;
+	opengl_context, rc: win32.HGLRC;
+	c_title:            []u8;
 }
 
 make_window :: proc(title: string, msg, height: int, window_proc: win32.WNDPROC) -> (Window, bool) {
-	using win32
+	using win32;
 
-	w: Window
-	w.width, w.height = msg, height
+	w: Window;
+	w.width, w.height = msg, height;
 
-	class_name := "Win32-Odin-Window\x00"
-	c_class_name := class_name.data
+	class_name := "Win32-Odin-Window\x00";
+	c_class_name := class_name.data;
 	if title[title.count-1] != 0 {
-		w.c_title = to_c_string(title)
+		w.c_title = to_c_string(title);
 	} else {
-		w.c_title = title as []u8
+		w.c_title = title as []u8;
 	}
 
-	instance := GetModuleHandleA(nil)
+	instance := GetModuleHandleA(nil);
 
 	w.wc = WNDCLASSEXA{
 		size       = size_of(WNDCLASSEXA) as u32,
@@ -65,8 +65,8 @@ make_window :: proc(title: string, msg, height: int, window_proc: win32.WNDPROC)
 	};
 
 	if RegisterClassExA(^w.wc) == 0 {
-		win32_print_last_error()
-		return w, false
+		win32_print_last_error();
+		return w, false;
 	}
 
 	w.hwnd = CreateWindowExA(0,
@@ -74,14 +74,14 @@ make_window :: proc(title: string, msg, height: int, window_proc: win32.WNDPROC)
 	                         WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
 	                         CW_USEDEFAULT, CW_USEDEFAULT,
 	                         w.width as i32, w.height as i32,
-	                         nil, nil, instance, nil)
+	                         nil, nil, instance, nil);
 
 	if w.hwnd == nil {
-		win32_print_last_error()
-		return w, false
+		win32_print_last_error();
+		return w, false;
 	}
 
-	w.dc = GetDC(w.hwnd)
+	w.dc = GetDC(w.hwnd);
 
 	{
 		pfd := PIXELFORMATDESCRIPTOR{
@@ -94,122 +94,122 @@ make_window :: proc(title: string, msg, height: int, window_proc: win32.WNDPROC)
 			depth_bits   = 24,
 			stencil_bits = 8,
 			layer_type   = PFD_MAIN_PLANE,
-		}
+		};
 
-		SetPixelFormat(w.dc, ChoosePixelFormat(w.dc, ^pfd), nil)
-		w.opengl_context = wglCreateContext(w.dc)
-		wglMakeCurrent(w.dc, w.opengl_context)
+		SetPixelFormat(w.dc, ChoosePixelFormat(w.dc, ^pfd), nil);
+		w.opengl_context = wglCreateContext(w.dc);
+		wglMakeCurrent(w.dc, w.opengl_context);
 
 		attribs := [8]i32{
 			WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
 			WGL_CONTEXT_MINOR_VERSION_ARB, 1,
 			WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
 			0, // NOTE(bill): tells the proc that this is the end of attribs
-		}
+		};
 
-		wglCreateContextAttribsARB := wglGetProcAddress(("wglCreateContextAttribsARB\x00" as string).data) as wglCreateContextAttribsARBType
-		w.rc = wglCreateContextAttribsARB(w.dc, 0, ^attribs[0])
-		wglMakeCurrent(w.dc, w.rc)
-		SwapBuffers(w.dc)
+		wglCreateContextAttribsARB := wglGetProcAddress(("wglCreateContextAttribsARB\x00" as string).data) as wglCreateContextAttribsARBType;
+		w.rc = wglCreateContextAttribsARB(w.dc, 0, ^attribs[0]);
+		wglMakeCurrent(w.dc, w.rc);
+		SwapBuffers(w.dc);
 	}
 
-	return w, true
+	return w, true;
 }
 
 destroy_window :: proc(w: ^Window) {
-	free(w.c_title.data)
+	free(w.c_title.data);
 }
 
 display_window :: proc(w: ^Window) {
-	win32.SwapBuffers(w.dc)
+	win32.SwapBuffers(w.dc);
 }
 
 
 run :: proc() {
-	using win32
-	using math
+	using win32;
+	using math;
 
 	win32_proc :: proc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT #no_inline {
 		if msg == WM_DESTROY || msg == WM_CLOSE || msg == WM_QUIT {
-			os.exit(0)
-			return 0
+			os.exit(0);
+			return 0;
 		}
-		return DefWindowProcA(hwnd, msg, wparam, lparam)
+		return DefWindowProcA(hwnd, msg, wparam, lparam);
 	}
 
-	window, window_success := make_window("Odin Language Demo", 854, 480, win32_proc)
+	window, window_success := make_window("Odin Language Demo", 854, 480, win32_proc);
 	if !window_success {
-		return
+		return;
 	}
-	defer destroy_window(^window)
+	defer destroy_window(^window);
 
-	gl.init()
+	gl.init();
 
 
-	prev_time := time_now()
-	running := true
+	prev_time := time_now();
+	running := true;
 
-	pos := Vec2{100, 100}
+	pos := Vec2{100, 100};
 
 	for running {
-		curr_time := time_now()
-		dt := (curr_time - prev_time) as f32
-		prev_time = curr_time
+		curr_time := time_now();
+		dt := (curr_time - prev_time) as f32;
+		prev_time = curr_time;
 
-		msg: MSG
+		msg: MSG;
 		for PeekMessageA(^msg, nil, 0, 0, PM_REMOVE) > 0 {
 			if msg.message == WM_QUIT {
-				running = false
+				running = false;
 			}
-			TranslateMessage(^msg)
-			DispatchMessageA(^msg)
+			TranslateMessage(^msg);
+			DispatchMessageA(^msg);
 		}
 
 		if is_key_down(Key_Code.ESCAPE) {
-			running = false
+			running = false;
 		}
 
 		{
-			SPEED :: 500
-			v: Vec2
+			SPEED :: 500;
+			v: Vec2;
 
-			if is_key_down(Key_Code.RIGHT) { v[0] += 1 }
-			if is_key_down(Key_Code.LEFT)  { v[0] -= 1 }
-			if is_key_down(Key_Code.UP)    { v[1] += 1 }
-			if is_key_down(Key_Code.DOWN)  { v[1] -= 1 }
+			if is_key_down(Key_Code.RIGHT) { v[0] += 1; }
+			if is_key_down(Key_Code.LEFT)  { v[0] -= 1; }
+			if is_key_down(Key_Code.UP)    { v[1] += 1; }
+			if is_key_down(Key_Code.DOWN)  { v[1] -= 1; }
 
-			v = vec2_norm0(v)
+			v = vec2_norm0(v);
 
-			pos += v * Vec2{SPEED * dt}
+			pos += v * Vec2{SPEED * dt};
 		}
 
 
-		gl.ClearColor(0.5, 0.7, 1.0, 1.0)
-		gl.Clear(gl.COLOR_BUFFER_BIT)
+		gl.ClearColor(0.5, 0.7, 1.0, 1.0);
+		gl.Clear(gl.COLOR_BUFFER_BIT);
 
-		gl.LoadIdentity()
+		gl.LoadIdentity();
 		gl.Ortho(0, window.width as f64,
-		         0, window.height as f64, 0, 1)
+		         0, window.height as f64, 0, 1);
 
 		draw_rect :: proc(x, y, w, h: f32) {
-			gl.Begin(gl.TRIANGLES)
-			defer gl.End()
+			gl.Begin(gl.TRIANGLES);
+			defer gl.End();
 
-			gl.Color3f(1, 0, 0); gl.Vertex3f(x,   y,   0)
-			gl.Color3f(0, 1, 0); gl.Vertex3f(x+w, y,   0)
-			gl.Color3f(0, 0, 1); gl.Vertex3f(x+w, y+h, 0)
+			gl.Color3f(1, 0, 0); gl.Vertex3f(x,   y,   0);
+			gl.Color3f(0, 1, 0); gl.Vertex3f(x+w, y,   0);
+			gl.Color3f(0, 0, 1); gl.Vertex3f(x+w, y+h, 0);
 
-			gl.Color3f(0, 0, 1); gl.Vertex3f(x+w, y+h, 0)
-			gl.Color3f(1, 1, 0); gl.Vertex3f(x,   y+h, 0)
-			gl.Color3f(1, 0, 0); gl.Vertex3f(x,   y,   0)
+			gl.Color3f(0, 0, 1); gl.Vertex3f(x+w, y+h, 0);
+			gl.Color3f(1, 1, 0); gl.Vertex3f(x,   y+h, 0);
+			gl.Color3f(1, 0, 0); gl.Vertex3f(x,   y,   0);
 		}
 
-		draw_rect(pos.x, pos.y, 50, 50)
+		draw_rect(pos.x, pos.y, 50, 50);
 
-		display_window(^window)
-		ms_to_sleep := (16 - 1000*dt) as i32
+		display_window(^window);
+		ms_to_sleep := (16 - 1000*dt) as i32;
 		if ms_to_sleep > 0 {
-			win32.Sleep(ms_to_sleep)
+			win32.Sleep(ms_to_sleep);
 		}
 	}
 }

+ 74 - 74
code/http_test.odin

@@ -1,10 +1,10 @@
-#import "fmt.odin" as fmt
+#import "fmt.odin";
 
-#foreign_system_library "Ws2_32"
+#foreign_system_library "Ws2_32" when ODIN_OS == "windows";
 
 
-SOCKET :: type uint
-INVALID_SOCKET :: ~(0 as SOCKET)
+SOCKET :: type uint;
+INVALID_SOCKET :: ~(0 as SOCKET);
 
 AF :: enum i32 {
 	UNSPEC    = 0,       // unspecified
@@ -37,45 +37,45 @@ AF :: enum i32 {
 	MAX       = 26,
 }
 
-SOCK_STREAM  :: 1
-SOCKET_ERROR :: -1
-IPPROTO_TCP  :: 6
-AI_PASSIVE   :: 0x0020
-SOMAXCONN    :: 128
+SOCK_STREAM  :: 1;
+SOCKET_ERROR :: -1;
+IPPROTO_TCP  :: 6;
+AI_PASSIVE   :: 0x0020;
+SOMAXCONN    :: 128;
 
-SD_RECEIVE :: 0
-SD_SEND    :: 1
-SD_BOTH    :: 2
+SD_RECEIVE :: 0;
+SD_SEND    :: 1;
+SD_BOTH    :: 2;
 
-WSADESCRIPTION_LEN :: 256
-WSASYS_STATUS_LEN  :: 128
+WSADESCRIPTION_LEN :: 256;
+WSASYS_STATUS_LEN  :: 128;
 WSADATA :: struct #ordered {
-	version:       i16
-	high_version:  i16
+	version:       i16;
+	high_version:  i16;
 
 
 // NOTE(bill): This is x64 ordering
-	max_sockets:   u16
-	max_udp_dg:    u16
-	vendor_info:   ^byte
-	description:   [WSADESCRIPTION_LEN+1]byte
-	system_status: [WSASYS_STATUS_LEN+1]byte
+	max_sockets:   u16;
+	max_udp_dg:    u16;
+	vendor_info:   ^byte;
+	description:   [WSADESCRIPTION_LEN+1]byte;
+	system_status: [WSASYS_STATUS_LEN+1]byte;
 }
 
 addrinfo :: struct #ordered {
-	flags:     i32
-	family:    i32
-	socktype:  i32
-	protocol:  i32
-	addrlen:   uint
-	canonname: ^u8
-	addr:      ^sockaddr
-	next:      ^addrinfo
+	flags:     i32;
+	family:    i32;
+	socktype:  i32;
+	protocol:  i32;
+	addrlen:   uint;
+	canonname: ^u8;
+	addr:      ^sockaddr;
+	next:      ^addrinfo;
 }
 
 sockaddr :: struct #ordered {
-	family: u16
-	data:   [14]byte
+	family: u16;
+	data:   [14]byte;
 }
 
 
@@ -94,52 +94,52 @@ shutdown        :: proc(s: SOCKET, how: i32) -> i32
 WSAGetLastError :: proc() -> i32                                                                   #foreign #dll_import
 
 to_c_string :: proc(s: string) -> ^byte {
-	c_str := new_slice(byte, s.count+1)
-	assert(c_str.data != null)
-	copy(c_str, s as []byte)
-	c_str[s.count] = 0
-	return c_str.data
+	c_str := new_slice(byte, s.count+1);
+	assert(c_str.data != nil);
+	copy(c_str, s as []byte);
+	c_str[s.count] = 0;
+	return c_str.data;
 }
 
 run :: proc() {
-	wsa: WSADATA
-	res:  ^addrinfo = null
-	hints: addrinfo
-	s, client: SOCKET
+	wsa: WSADATA;
+	res:  ^addrinfo = nil;
+	hints: addrinfo;
+	s, client: SOCKET;
 
 	if WSAStartup(2 | (2 << 8), ^wsa) != 0 {
-		fmt.println("WSAStartup failed: ", WSAGetLastError())
-		return
+		fmt.println("WSAStartup failed: ", WSAGetLastError());
+		return;
 	}
-	defer WSACleanup()
+	defer WSACleanup();
 
-	hints.family   = AF.INET as i32
-	hints.socktype = SOCK_STREAM
-	hints.protocol = IPPROTO_TCP
-	hints.flags    = AI_PASSIVE
+	hints.family   = AF.INET as i32;
+	hints.socktype = SOCK_STREAM;
+	hints.protocol = IPPROTO_TCP;
+	hints.flags    = AI_PASSIVE;
 
-	if getaddrinfo(null, to_c_string("8080"), ^hints, ^res) != 0 {
-		fmt.println("getaddrinfo failed: ", WSAGetLastError())
-		return
+	if getaddrinfo(nil, to_c_string("8080"), ^hints, ^res) != 0 {
+		fmt.println("getaddrinfo failed: ", WSAGetLastError());
+		return;
 	}
-	defer freeaddrinfo(res)
+	defer freeaddrinfo(res);
 
-	s = socket(res.family, res.socktype, res.protocol)
+	s = socket(res.family, res.socktype, res.protocol);
 	if s == INVALID_SOCKET {
-		fmt.println("socket failed: ", WSAGetLastError())
-		return
+		fmt.println("socket failed: ", WSAGetLastError());
+		return;
 	}
-	defer closesocket(s)
+	defer closesocket(s);
 
-	bind(s, res.addr, res.addrlen as i32)
-	listen(s, SOMAXCONN)
+	bind(s, res.addr, res.addrlen as i32);
+	listen(s, SOMAXCONN);
 
-	client = accept(s, null, null)
+	client = accept(s, nil, 0);
 	if client == INVALID_SOCKET {
-		fmt.println("socket failed: ", WSAGetLastError())
-		return
+		fmt.println("socket failed: ", WSAGetLastError());
+		return;
 	}
-	defer closesocket(client)
+	defer closesocket(client);
 
 	html :=
 `HTTP/1.1 200 OK
@@ -154,27 +154,27 @@ Content-type: text/html
 	<h1 style="color: orange;">Odin Server Demo</h1>
 </body>
 </html>
-`
+`;
 
-	buf: [1024]byte
+	buf: [1024]byte;
 	for {
-		bytes := recv(client, ^buf[0], buf.count as i32, 0)
+		bytes := recv(client, ^buf[0], buf.count as i32, 0);
 		if bytes > 0 {
-			// fmt.println(buf[:bytes] as string)
-			bytes_sent := send(client, html.data, (html.count-1) as i32, 0)
+			// fmt.println(buf[:bytes] as string);
+			bytes_sent := send(client, html.data, (html.count-1) as i32, 0);
 			if bytes_sent == SOCKET_ERROR {
-				fmt.println("send failed: ", WSAGetLastError())
-				return
+				fmt.println("send failed: ", WSAGetLastError());
+				return;
 			}
-			break
+			break;
 		} else if bytes == 0 {
-			fmt.println("Connection closing...")
-			break
+			fmt.println("Connection closing...");
+			break;
 		} else {
-			fmt.println("recv failed: ", WSAGetLastError())
-			return
+			fmt.println("recv failed: ", WSAGetLastError());
+			return;
 		}
 	}
 
-	shutdown(client, SD_SEND)
+	shutdown(client, SD_SEND);
 }

+ 1 - 1
code/old_demos/demo001.odin

@@ -301,7 +301,7 @@ namespaces_and_files :: proc() {
 		#import "file.odin" as _
 
 		// Exporting import
-		#load "file.odin"
+		#include "file.odin"
 	*/
 
 	// Talk about scope rules and diagram

+ 3 - 3
code/old_demos/demo002.odin

@@ -1,7 +1,7 @@
 // Demo 002
-#load "basic.odin"
-#load "math.odin"
-// #load "game.odin"
+#include "basic.odin"
+#include "math.odin"
+// #include "game.odin"
 
 #thread_local tls_int: int
 

+ 1 - 1
code/old_demos/old_runtime.odin

@@ -1,4 +1,4 @@
-#load "win32.odin"
+#include "win32.odin"
 
 assume :: proc(cond: bool) #foreign "llvm.assume"
 

+ 138 - 140
code/punity.odin

@@ -1,34 +1,34 @@
-#import "win32.odin"
-#import "fmt.odin"
-#import "os.odin"
+#import "win32.odin";
+#import "fmt.odin";
+#import "os.odin";
 
-CANVAS_WIDTH  :: 128
-CANVAS_HEIGHT :: 128
-CANVAS_SCALE  :: 3
-FRAME_TIME    :: 1.0/30.0
-WINDOW_TITLE  : string : "Punity\x00"
+CANVAS_WIDTH  :: 128;
+CANVAS_HEIGHT :: 128;
+CANVAS_SCALE  :: 3;
+FRAME_TIME    :: 1.0/30.0;
+WINDOW_TITLE  :: "Punity\x00";
 
-_ := compile_assert(CANVAS_WIDTH % 16 == 0)
+_ := compile_assert(CANVAS_WIDTH % 16 == 0);
 
-WINDOW_WIDTH  :: CANVAS_WIDTH  * CANVAS_SCALE
-WINDOW_HEIGHT :: CANVAS_HEIGHT * CANVAS_SCALE
+WINDOW_WIDTH  :: CANVAS_WIDTH  * CANVAS_SCALE;
+WINDOW_HEIGHT :: CANVAS_HEIGHT * CANVAS_SCALE;
 
 
-STACK_CAPACITY   :: 1<<20
-STORAGE_CAPACITY :: 1<<20
+STACK_CAPACITY   :: 1<<20;
+STORAGE_CAPACITY :: 1<<20;
 
-DRAW_LIST_RESERVE :: 128
+DRAW_LIST_RESERVE :: 128;
 
-MAX_KEYS :: 256
+MAX_KEYS :: 256;
 
 Core :: struct {
-	stack:   ^Bank
-	storage: ^Bank
+	stack:   ^Bank;
+	storage: ^Bank;
 
-	running:       bool
-	key_modifiers: u32
-	key_states:    [MAX_KEYS]byte
-	key_deltas:    [MAX_KEYS]byte
+	running:       bool;
+	key_modifiers: u32;
+	key_states:    [MAX_KEYS]byte;
+	key_deltas:    [MAX_KEYS]byte;
 
 	perf_frame,
 	perf_frame_inner,
@@ -36,70 +36,70 @@ Core :: struct {
 	perf_audio,
 	perf_blit,
 	perf_blit_cvt,
-	perf_blit_gdi: Perf_Span
+	perf_blit_gdi: Perf_Span;
 
-	frame: i64
+	frame: i64;
 
-	canvas: Canvas
-	draw_list: ^Draw_List
+	canvas:    Canvas;
+	draw_list: ^Draw_List;
 }
 
 Perf_Span :: struct {
-	stamp: f64
-	delta: f32
+	stamp: f64;
+	delta: f32;
 }
 
 Bank :: struct {
-	memory: []byte
-	cursor: int
+	memory: []byte;
+	cursor: int;
 }
 
 Bank_State :: struct {
-	state: Bank
-	bank: ^Bank
+	state: Bank;
+	bank: ^Bank;
 }
 
 
 Color :: raw_union {
-	using channels: struct{ a, b, g, r: byte }
-	rgba: u32
+	using channels: struct{ a, b, g, r: byte; };
+	rgba: u32;
 }
 
 Palette :: struct {
-	colors: [256]Color
-	colors_count: byte
+	colors: [256]Color;
+	colors_count: byte;
 }
 
 
 Rect :: raw_union {
 	using minmax: struct {
-		min_x, min_y, max_x, max_y: int
-	}
+		min_x, min_y, max_x, max_y: int;
+	};
 	using pos: struct {
-		left, top, right, bottom: int
-	}
-	e: [4]int
+		left, top, right, bottom: int;
+	};
+	e: [4]int;
 }
 
 Bitmap :: struct {
-	pixels: []byte
-	width:  int
-	height: int
+	pixels: []byte;
+	width:  int;
+	height: int;
 }
 
 Font :: struct {
-	using bitmap: Bitmap
-	char_width:   int
-	char_height:  int
+	using bitmap: Bitmap;
+	char_width:   int;
+	char_height:  int;
 }
 
 Canvas :: struct {
-	using bitmap: ^Bitmap
-	palette:      Palette
-	translate_x:  int
-	translate_y:  int
-	clip:         Rect
-	font:         ^Font
+	using bitmap: ^Bitmap;
+	palette:      Palette;
+	translate_x:  int;
+	translate_y:  int;
+	clip:         Rect;
+	font:         ^Font;
 }
 
 DrawFlag :: enum {
@@ -114,7 +114,7 @@ Draw_List :: struct {
 	Item :: struct {
 
 	}
-	items: []Item
+	items: []Item;
 }
 
 Key :: enum {
@@ -272,37 +272,36 @@ Key :: enum {
 
 
 key_down :: proc(k: Key) -> bool {
-	return _core.key_states[k] != 0
+	return _core.key_states[k] != 0;
 }
 
 key_pressed :: proc(k: Key) -> bool {
-	return (_core.key_deltas[k] != 0) && key_down(k)
+	return (_core.key_deltas[k] != 0) && key_down(k);
 }
 
 
 
 
-win32_perf_count_freq := win32.GetQueryPerformanceFrequency()
+win32_perf_count_freq := win32.GetQueryPerformanceFrequency();
 time_now :: proc() -> f64 {
-	assert(win32_perf_count_freq != 0)
+	assert(win32_perf_count_freq != 0);
 
-	counter: i64
-	win32.QueryPerformanceCounter(^counter)
-	result := counter as f64 / win32_perf_count_freq as f64
-	return result
+	counter: i64;
+	win32.QueryPerformanceCounter(^counter);
+	result := counter as f64 / win32_perf_count_freq as f64;
+	return result;
 }
 
-_core: Core
+_core: Core;
 
 run :: proc(user_init, user_step: proc(c: ^Core)) {
-	using win32
-
+	using win32;
 
-	_core.running = true
+	_core.running = true;
 
 	win32_proc :: proc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT #no_inline #stdcall {
 		win32_app_key_mods :: proc() -> u32 {
-			mods: u32 = 0
+			mods: u32 = 0;
 
 			if is_key_down(Key_Code.SHIFT) {
 				mods |= Key.MOD_SHIFT as u32;
@@ -317,33 +316,33 @@ run :: proc(user_init, user_step: proc(c: ^Core)) {
 				mods |= Key.MOD_SUPER as u32;
 			}
 
-			return mods
+			return mods;
 		}
 
 		match msg {
 		case WM_KEYDOWN:
-			_core.key_modifiers = win32_app_key_mods()
+			_core.key_modifiers = win32_app_key_mods();
 			if wparam < MAX_KEYS {
-				_core.key_states[wparam] = 1
-				_core.key_deltas[wparam] = 1
+				_core.key_states[wparam] = 1;
+				_core.key_deltas[wparam] = 1;
 			}
-			return 0
+			return 0;
 
 		case WM_KEYUP:
-			_core.key_modifiers = win32_app_key_mods()
+			_core.key_modifiers = win32_app_key_mods();
 			if wparam < MAX_KEYS {
-				_core.key_states[wparam] = 0
-				_core.key_deltas[wparam] = 1
+				_core.key_states[wparam] = 0;
+				_core.key_deltas[wparam] = 1;
 			}
-			return 0
+			return 0;
 
 		case WM_CLOSE:
-			PostQuitMessage(0)
-			_core.running = false
-			return 0
+			PostQuitMessage(0);
+			_core.running = false;
+			return 0;
 		}
 
-		return DefWindowProcA(hwnd, msg, wparam, lparam)
+		return DefWindowProcA(hwnd, msg, wparam, lparam);
 	}
 
 
@@ -351,30 +350,30 @@ run :: proc(user_init, user_step: proc(c: ^Core)) {
 		class_name = ("Punity\x00" as string).data, // C-style string
 		size       = size_of(WNDCLASSEXA) as u32,
 		style      = CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
-		instance   = GetModuleHandleA(null) as HINSTANCE,
+		instance   = GetModuleHandleA(nil) as HINSTANCE,
 		wnd_proc   = win32_proc,
 		// wnd_proc   = DefWindowProcA,
 		background = GetStockObject(BLACK_BRUSH) as HBRUSH,
-	}
+	};
 
 	if RegisterClassExA(^window_class) == 0 {
-		fmt.fprintln(os.stderr, "RegisterClassExA failed")
-		return
+		fmt.fprintln(os.stderr, "RegisterClassExA failed");
+		return;
 	}
 
-	screen_width  := GetSystemMetrics(SM_CXSCREEN)
-	screen_height := GetSystemMetrics(SM_CYSCREEN)
+	screen_width  := GetSystemMetrics(SM_CXSCREEN);
+	screen_height := GetSystemMetrics(SM_CYSCREEN);
 
-	rc: RECT
-	rc.left   = (screen_width - WINDOW_WIDTH)   / 2
-	rc.top    = (screen_height - WINDOW_HEIGHT) / 2
-	rc.right  = rc.left + WINDOW_WIDTH
-	rc.bottom = rc.top + WINDOW_HEIGHT
+	rc: RECT;
+	rc.left   = (screen_width - WINDOW_WIDTH)   / 2;
+	rc.top    = (screen_height - WINDOW_HEIGHT) / 2;
+	rc.right  = rc.left + WINDOW_WIDTH;
+	rc.bottom = rc.top + WINDOW_HEIGHT;
 
-	style: u32 = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
-	assert(AdjustWindowRect(^rc, style, 0) != 0)
+	style: u32 = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
+	assert(AdjustWindowRect(^rc, style, 0) != 0);
 
-	wt := WINDOW_TITLE
+	wt := WINDOW_TITLE;
 
 	win32_window := CreateWindowExA(0,
 	                                window_class.class_name,
@@ -382,83 +381,82 @@ run :: proc(user_init, user_step: proc(c: ^Core)) {
 	                                style,
 	                                rc.left, rc.top,
 	                                rc.right-rc.left, rc.bottom-rc.top,
-	                                null, null, window_class.instance,
-	                                null);
+	                                nil, nil, window_class.instance,
+	                                nil);
 
-	if win32_window == null {
-		fmt.fprintln(os.stderr, "CreateWindowExA failed")
-		return
+	if win32_window == nil {
+		fmt.fprintln(os.stderr, "CreateWindowExA failed");
+		return;
 	}
 
 
 	window_bmi: BITMAPINFO;
-	window_bmi.size        = size_of(BITMAPINFO.HEADER) as u32
-	window_bmi.width       = CANVAS_WIDTH
-	window_bmi.height      = CANVAS_HEIGHT
-	window_bmi.planes      = 1
-	window_bmi.bit_count   = 32
-	window_bmi.compression = BI_RGB
+	window_bmi.size        = size_of(BITMAPINFO.HEADER) as u32;
+	window_bmi.width       = CANVAS_WIDTH;
+	window_bmi.height      = CANVAS_HEIGHT;
+	window_bmi.planes      = 1;
+	window_bmi.bit_count   = 32;
+	window_bmi.compression = BI_RGB;
 
 
-	user_init(^_core)
+	user_init(^_core);
 
 
-	ShowWindow(win32_window, SW_SHOW)
+	ShowWindow(win32_window, SW_SHOW);
 
 	window_buffer := new_slice(u32, CANVAS_WIDTH * CANVAS_HEIGHT);
-	assert(window_buffer.data != null)
-	defer free(window_buffer.data)
+	assert(window_buffer.data != nil);
+	defer free(window_buffer.data);
 
 	for i := 0; i < window_buffer.count; i++ {
-		window_buffer[i] = 0xff00ff
+		window_buffer[i] = 0xff00ff;
 	}
 
 
-	prev_time, curr_time,dt: f64
-	prev_time = time_now()
-	curr_time = time_now()
-	total_time : f64 = 0
+	prev_time, curr_time,dt: f64;
+	prev_time = time_now();
+	curr_time = time_now();
+	total_time : f64 = 0;
 	offset_x := 0;
 	offset_y := 0;
 
-	message: MSG
+	message: MSG;
 	for _core.running {
-		curr_time = time_now()
-		dt = curr_time - prev_time
-		prev_time = curr_time
-		total_time += dt
+		curr_time = time_now();
+		dt = curr_time - prev_time;
+		prev_time = curr_time;
+		total_time += dt;
 
-		offset_x += 1
-		offset_y += 2
+		offset_x += 1;
+		offset_y += 2;
 
 		{
-			data: [128]byte
-			buf := data[:0]
-			fmt.bprintf(^buf, "Punity: % ms\x00", dt*1000)
-			win32.SetWindowTextA(win32_window, buf.data)
+			data: [128]byte;
+			buf := data[:0];
+			fmt.bprintf(^buf, "Punity: % ms\x00", dt*1000);
+			win32.SetWindowTextA(win32_window, buf.data);
 		}
 
 
 		for y := 0; y < CANVAS_HEIGHT; y++ {
 			for x := 0; x < CANVAS_WIDTH; x++ {
-				g := (x % 32) * 8
-				b := (y % 32) * 8
-				window_buffer[x + y*CANVAS_WIDTH] = (g << 8 | b) as u32
+				g := (x % 32) * 8;
+				b := (y % 32) * 8;
+				window_buffer[x + y*CANVAS_WIDTH] = (g << 8 | b) as u32;
 			}
 		}
 
-		memory_zero(^_core.key_deltas[0], size_of_val(_core.key_deltas[0]))
-
+		_core.key_deltas = nil;
 
-		for PeekMessageA(^message, null, 0, 0, PM_REMOVE) != 0 {
+		for PeekMessageA(^message, nil, 0, 0, PM_REMOVE) != 0 {
 			if message.message == WM_QUIT {
-				_core.running = false
+				_core.running = false;
 			}
-			TranslateMessage(^message)
-			DispatchMessageA(^message)
+			TranslateMessage(^message);
+			DispatchMessageA(^message);
 		}
 
-		user_step(^_core)
+		user_step(^_core);
 
 		dc := GetDC(win32_window);
 		StretchDIBits(dc,
@@ -467,18 +465,18 @@ run :: proc(user_init, user_step: proc(c: ^Core)) {
 		              window_buffer.data,
 		              ^window_bmi,
 		              DIB_RGB_COLORS,
-		              SRCCOPY)
-		ReleaseDC(win32_window, dc)
+		              SRCCOPY);
+		ReleaseDC(win32_window, dc);
 
 
 		{
-			delta := time_now() - prev_time
-			ms := ((FRAME_TIME - delta) * 1000) as i32
+			delta := time_now() - prev_time;
+			ms := ((FRAME_TIME - delta) * 1000) as i32;
 			if ms > 0 {
-				win32.Sleep(ms)
+				win32.Sleep(ms);
 			}
 		}
 
-		_core.frame++
+		_core.frame++;
 	}
 }

+ 1 - 1
code/test.odin

@@ -28,7 +28,7 @@ thing :: proc() {
 */
 
 /*
-#load "fmt.odin"
+#include "fmt.odin"
 
 thing :: proc() {
 	println("Hello5!")

+ 150 - 172
core/_preload.odin

@@ -1,109 +1,86 @@
-#shared_global_scope
+#shared_global_scope;
 
-#import "os.odin"
-#import "fmt.odin"
-#import "mem.odin"
-
-/*
-Optimization_Level :: enum {
-	DEBUG,
-	RELEASE,
-}
-
-Bounds_Check_Mode :: enum {
-	ON,
-	OFF,
-}
-
-Build_Options :: struct {
-	optimization_level: Optimization_Level
-
-	bounds_check: Bounds_Check_Mode
-
-	output_name: string
-	output_path: string
-}
-
-build_options: Build_Options
-*/
+#import "os.odin";
+#import "fmt.odin";
+#import "mem.odin";
 
 // IMPORTANT NOTE(bill): Do not change the order of any of this data
 // The compiler relies upon this _exact_ order
 Type_Info :: union {
 	Member :: struct #ordered {
-		name:      string     // can be empty if tuple
-		type_info: ^Type_Info
-		offset:    int        // offsets are not used in tuples
+		name:      string;     // can be empty if tuple
+		type_info: ^Type_Info;
+		offset:    int;        // offsets are not used in tuples
 	}
 	Record :: struct #ordered {
-		fields:  []Member
-		size:    int // in bytes
-		align:   int // in bytes
-		packed:  bool
-		ordered: bool
+		fields:  []Member;
+		size:    int; // in bytes
+		align:   int; // in bytes
+		packed:  bool;
+		ordered: bool;
 	}
 
 	Named: struct #ordered {
-		name: string
-		base: ^Type_Info // This will _not_ be a Type_Info.Named
-	}
+		name: string;
+		base: ^Type_Info; // This will _not_ be a Type_Info.Named
+	};
 	Integer: struct #ordered {
-		size:   int // in bytes
-		signed: bool
-	}
+		size:   int; // in bytes
+		signed: bool;
+	};
 	Float: struct #ordered {
-		size: int // in bytes
-	}
-	Any:     struct #ordered {}
-	String:  struct #ordered {}
-	Boolean: struct #ordered {}
+		size: int; // in bytes
+	};
+	Any:     struct #ordered {};
+	String:  struct #ordered {};
+	Boolean: struct #ordered {};
 	Pointer: struct #ordered {
-		elem: ^Type_Info // nil -> rawptr
-	}
+		elem: ^Type_Info; // nil -> rawptr
+	};
 	Maybe: struct #ordered {
-		elem: ^Type_Info
-	}
+		elem: ^Type_Info;
+	};
 	Procedure: struct #ordered {
-		params:   ^Type_Info // Type_Info.Tuple
-		results:  ^Type_Info // Type_Info.Tuple
-		variadic: bool
-	}
+		params:   ^Type_Info; // Type_Info.Tuple
+		results:  ^Type_Info; // Type_Info.Tuple
+		variadic: bool;
+	};
 	Array: struct #ordered {
-		elem:      ^Type_Info
-		elem_size: int
-		count:     int
-	}
+		elem:      ^Type_Info;
+		elem_size: int;
+		count:     int;
+	};
 	Slice: struct #ordered {
-		elem:      ^Type_Info
-		elem_size: int
-	}
+		elem:      ^Type_Info;
+		elem_size: int;
+	};
 	Vector: struct #ordered {
-		elem:      ^Type_Info
-		elem_size: int
-		count:     int
-		align:     int
-	}
-	Tuple:     Record
-	Struct:    Record
-	Union:     Record
-	Raw_Union: Record
+		elem:      ^Type_Info;
+		elem_size: int;
+		count:     int;
+		align:     int;
+	};
+	Tuple:     Record;
+	Struct:    Record;
+	Union:     Record;
+	Raw_Union: Record;
 	Enum: struct #ordered {
-		base:   ^Type_Info
-		values: []i64
-		names:  []string
-	}
+		base:   ^Type_Info;
+		values: []i64;
+		names:  []string;
+	};
 }
 
 type_info_base :: proc(info: ^Type_Info) -> ^Type_Info {
 	if info == nil {
-		return nil
+		return nil;
 	}
-	base := info
+	base := info;
 	match type i : base {
 	case Type_Info.Named:
-		base = i.base
+		base = i.base;
 	}
-	return base
+	return base;
 }
 
 
@@ -144,145 +121,146 @@ Allocator :: struct #ordered {
 
 
 	procedure: Proc;
-	data:      rawptr
+	data:      rawptr;
 }
 
 
 Context :: struct #ordered {
-	thread_id: int
+	thread_id: int;
 
-	allocator: Allocator
+	allocator: Allocator;
 
-	user_data:  rawptr
-	user_index: int
+	user_data:  rawptr;
+	user_index: int;
 }
 
-#thread_local __context: Context
+#thread_local __context: Context;
 
 
-DEFAULT_ALIGNMENT :: align_of([vector 4]f32)
+DEFAULT_ALIGNMENT :: align_of([vector 4]f32);
 
 
 __check_context :: proc() {
-	c := ^__context
+	c := ^__context;
 
 	if c.allocator.procedure == nil {
-		c.allocator = default_allocator()
+		c.allocator = default_allocator();
 	}
 	if c.thread_id == 0 {
-		c.thread_id = os.current_thread_id()
+		c.thread_id = os.current_thread_id();
 	}
 }
 
-alloc :: proc(size: int) -> rawptr #inline { return alloc_align(size, DEFAULT_ALIGNMENT) }
+alloc :: proc(size: int) -> rawptr #inline { return alloc_align(size, DEFAULT_ALIGNMENT); }
 
 alloc_align :: proc(size, alignment: int) -> rawptr #inline {
-	__check_context()
-	a := context.allocator
-	return a.procedure(a.data, Allocator.Mode.ALLOC, size, alignment, nil, 0, 0)
+	__check_context();
+	a := context.allocator;
+	return a.procedure(a.data, Allocator.Mode.ALLOC, size, alignment, nil, 0, 0);
 }
 
 free :: proc(ptr: rawptr) #inline {
-	__check_context()
-	a := context.allocator
+	__check_context();
+	a := context.allocator;
 	if ptr != nil {
-		a.procedure(a.data, Allocator.Mode.FREE, 0, 0, ptr, 0, 0)
+		a.procedure(a.data, Allocator.Mode.FREE, 0, 0, ptr, 0, 0);
 	}
 }
 free_all :: proc() #inline {
-	__check_context()
-	a := context.allocator
-	a.procedure(a.data, Allocator.Mode.FREE_ALL, 0, 0, nil, 0, 0)
+	__check_context();
+	a := context.allocator;
+	a.procedure(a.data, Allocator.Mode.FREE_ALL, 0, 0, nil, 0, 0);
 }
 
 
-resize       :: proc(ptr: rawptr, old_size, new_size: int) -> rawptr #inline { return resize_align(ptr, old_size, new_size, DEFAULT_ALIGNMENT) }
+resize       :: proc(ptr: rawptr, old_size, new_size: int) -> rawptr #inline { return resize_align(ptr, old_size, new_size, DEFAULT_ALIGNMENT); }
 resize_align :: proc(ptr: rawptr, old_size, new_size, alignment: int) -> rawptr #inline {
-	__check_context()
-	a := context.allocator
-	return a.procedure(a.data, Allocator.Mode.RESIZE, new_size, alignment, ptr, old_size, 0)
+	__check_context();
+	a := context.allocator;
+	return a.procedure(a.data, Allocator.Mode.RESIZE, new_size, alignment, ptr, old_size, 0);
 }
 
 
 
 default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment: int) -> rawptr {
 	if old_memory == nil {
-		return alloc_align(new_size, alignment)
+		return alloc_align(new_size, alignment);
 	}
 
 	if new_size == 0 {
-		free(old_memory)
-		return nil
+		free(old_memory);
+		return nil;
 	}
 
 	if new_size == old_size {
-		return old_memory
+		return old_memory;
 	}
 
-	new_memory := alloc_align(new_size, alignment)
+	new_memory := alloc_align(new_size, alignment);
 	if new_memory == nil {
-		return nil
+		return nil;
 	}
 
-	mem.copy(new_memory, old_memory, min(old_size, new_size));
-	free(old_memory)
-	return new_memory
+	mem.copy(new_memory, old_memory, min(old_size, new_size));;
+	free(old_memory);
+	return new_memory;
 }
 
 
 default_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator.Mode,
                                size, alignment: int,
                                old_memory: rawptr, old_size: int, flags: u64) -> rawptr {
-	using Allocator.Mode
-/*
-	match mode {
-	case ALLOC:
-		total_size := size + alignment + size_of(mem.AllocationHeader)
-		ptr := os.heap_alloc(total_size)
-		header := ptr as ^mem.AllocationHeader
-		ptr = mem.align_forward(header+1, alignment)
-		mem.allocation_header_fill(header, ptr, size)
-		return mem.zero(ptr, size)
-
-	case FREE:
-		os.heap_free(mem.allocation_header(old_memory))
-		return nil
-
-	case FREE_ALL:
-		// NOTE(bill): Does nothing
-
-	case RESIZE:
-		total_size := size + alignment + size_of(mem.AllocationHeader)
-		ptr := os.heap_resize(mem.allocation_header(old_memory), total_size)
-		header := ptr as ^mem.AllocationHeader
-		ptr = mem.align_forward(header+1, alignment)
-		mem.allocation_header_fill(header, ptr, size)
-		return mem.zero(ptr, size)
-	}
-*/
-	match mode {
-	case ALLOC:
-		return os.heap_alloc(size)
+	using Allocator.Mode;
+	when false {
+		match mode {
+		case ALLOC:
+			total_size := size + alignment + size_of(mem.AllocationHeader);
+			ptr := os.heap_alloc(total_size);
+			header := ptr as ^mem.AllocationHeader;
+			ptr = mem.align_forward(header+1, alignment);
+			mem.allocation_header_fill(header, ptr, size);
+			return mem.zero(ptr, size);
+
+		case FREE:
+			os.heap_free(mem.allocation_header(old_memory));
+			return nil;
+
+		case FREE_ALL:
+			// NOTE(bill): Does nothing
+
+		case RESIZE:
+			total_size := size + alignment + size_of(mem.AllocationHeader);
+			ptr := os.heap_resize(mem.allocation_header(old_memory), total_size);
+			header := ptr as ^mem.AllocationHeader;
+			ptr = mem.align_forward(header+1, alignment);
+			mem.allocation_header_fill(header, ptr, size);
+			return mem.zero(ptr, size);
+		}
+	} else {
+		match mode {
+		case ALLOC:
+			return os.heap_alloc(size);
 
-	case FREE:
-		os.heap_free(old_memory)
-		return nil
+		case FREE:
+			os.heap_free(old_memory);
+			return nil;
 
-	case FREE_ALL:
-		// NOTE(bill): Does nothing
+		case FREE_ALL:
+			// NOTE(bill): Does nothing
 
-	case RESIZE:
-		return os.heap_resize(old_memory, size)
+		case RESIZE:
+			return os.heap_resize(old_memory, size);
+		}
 	}
 
-	return nil
+	return nil;
 }
 
 default_allocator :: proc() -> Allocator {
 	return Allocator{
 		procedure = default_allocator_proc,
 		data = nil,
-	}
+	};
 }
 
 
@@ -297,58 +275,58 @@ default_allocator :: proc() -> Allocator {
 
 __string_eq :: proc(a, b: string) -> bool {
 	if a.count != b.count {
-		return false
+		return false;
 	}
 	if a.data == b.data {
-		return true
+		return true;
 	}
-	return mem.compare(a.data, b.data, a.count) == 0
+	return mem.compare(a.data, b.data, a.count) == 0;
 }
 
 __string_cmp :: proc(a, b : string) -> int {
-	return mem.compare(a.data, b.data, min(a.count, b.count))
+	return mem.compare(a.data, b.data, min(a.count, b.count));
 }
 
-__string_ne :: proc(a, b: string) -> bool #inline { return !__string_eq(a, b) }
-__string_lt :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) < 0 }
-__string_gt :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) > 0 }
-__string_le :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) <= 0 }
-__string_ge :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) >= 0 }
+__string_ne :: proc(a, b: string) -> bool #inline { return !__string_eq(a, b); }
+__string_lt :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) < 0; }
+__string_gt :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) > 0; }
+__string_le :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) <= 0; }
+__string_ge :: proc(a, b: string) -> bool #inline { return __string_cmp(a, b) >= 0; }
 
 
 __assert :: proc(file: string, line, column: int, msg: string) #inline {
 	fmt.fprintf(os.stderr, "%(%:%) Runtime assertion: %\n",
-	            file, line, column, msg)
-	__debug_trap()
+	            file, line, column, msg);
+	__debug_trap();
 }
 
 __bounds_check_error :: proc(file: string, line, column: int,
                              index, count: int) {
 	if 0 <= index && index < count {
-		return
+		return;
 	}
 	fmt.fprintf(os.stderr, "%(%:%) Index % is out of bounds range [0, %)\n",
-	            file, line, column, index, count)
-	__debug_trap()
+	            file, line, column, index, count);
+	__debug_trap();
 }
 
 __slice_expr_error :: proc(file: string, line, column: int,
                            low, high, max: int) {
 	if 0 <= low && low <= high && high <= max {
-		return
+		return;
 	}
 	fmt.fprintf(os.stderr, "%(%:%) Invalid slice indices: [%:%:%]\n",
-	            file, line, column, low, high, max)
-	__debug_trap()
+	            file, line, column, low, high, max);
+	__debug_trap();
 }
 __substring_expr_error :: proc(file: string, line, column: int,
                                low, high: int) {
 	if 0 <= low && low <= high {
-		return
+		return;
 	}
 	fmt.fprintf(os.stderr, "%(%:%) Invalid substring indices: [%:%:%]\n",
-	            file, line, column, low, high)
-	__debug_trap()
+	            file, line, column, low, high);
+	__debug_trap();
 }
 
 __enum_to_string :: proc(info: ^Type_Info, value: i64) -> string {
@@ -357,11 +335,11 @@ __enum_to_string :: proc(info: ^Type_Info, value: i64) -> string {
 		// TODO(bill): Search faster than linearly
 		for i := 0; i < ti.values.count; i++ {
 			if ti.values[i] == value {
-				return ti.names[i]
+				return ti.names[i];
 			}
 		}
 	}
-	return ""
+	return "";
 }
 
 

+ 80 - 81
core/_soft_numbers.odin

@@ -1,157 +1,156 @@
-#shared_global_scope
-
-#import "fmt.odin"
+#shared_global_scope;
 
+#import "fmt.odin";
 
 __u128_mod :: proc(a, b: u128) -> u128 #link_name "__umodti3" {
-	_, r := __u128_quo_mod(a, b)
-	return r
+	_, r := __u128_quo_mod(a, b);
+	return r;
 }
 
 __u128_quo :: proc(a, b: u128) -> u128 #link_name "__udivti3" {
-	n, _ := __u128_quo_mod(a, b)
-	return n
+	n, _ := __u128_quo_mod(a, b);
+	return n;
 }
 
 __i128_mod :: proc(a, b: i128) -> i128 #link_name "__modti3" {
-	_, r := __i128_quo_mod(a, b)
-	return r
+	_, r := __i128_quo_mod(a, b);
+	return r;
 }
 
 __i128_quo :: proc(a, b: i128) -> i128 #link_name "__divti3" {
-	n, _ := __i128_quo_mod(a, b)
-	return n
+	n, _ := __i128_quo_mod(a, b);
+	return n;
 }
 
 __i128_quo_mod :: proc(a, b: i128) -> (i128, i128) #link_name "__divmodti4" {
-	s := b >> 127
-	b = (b ~ s) - s
-	s = a >> 127
-	a = (a ~ s) - s
+	s := b >> 127;
+	b = (b ~ s) - s;
+	s = a >> 127;
+	a = (a ~ s) - s;
 
-	n, r := __u128_quo_mod(a as u128, b as u128)
-	return (n as i128 ~ s) - s, (r as i128 ~ s) - s
+	n, r := __u128_quo_mod(a as u128, b as u128);
+	return (n as i128 ~ s) - s, (r as i128 ~ s) - s;
 }
 
 
 __u128_quo_mod :: proc(a, b: u128) -> (u128, u128) #link_name "__udivmodti4" {
 	clz :: proc(x: u64) -> u64 {
 		clz_u64 :: proc(x: u64, is_zero_undef: bool) -> u64 #foreign "llvm.ctlz.i64"
-		return clz_u64(x, false)
+		return clz_u64(x, false);
 	}
 	ctz :: proc(x: u64) -> u64 {
 		ctz_u64 :: proc(x: u64, is_zero_undef: bool) -> u64 #foreign "llvm.cttz.i64"
-		return ctz_u64(x, false)
+		return ctz_u64(x, false);
 	}
 
 
 	u128_lo_hi :: raw_union {
-		all: u128
-		using _lohi: struct {lo, hi: u64}
+		all: u128;
+		using _lohi: struct {lo, hi: u64;};
 	}
 
-	n, d, q, r: u128_lo_hi
-	sr: u64
+	n, d, q, r: u128_lo_hi;
+	sr: u64;
 
-	n.all = a
-	d.all = b
+	n.all = a;
+	d.all = b;
 
 	if n.hi == 0 {
 		if d.hi == 0 {
-			return (n.lo / d.lo) as u128, (n.lo % d.lo) as u128
+			return (n.lo / d.lo) as u128, (n.lo % d.lo) as u128;
 		}
-		return 0, n.lo as u128
+		return 0, n.lo as u128;
 	}
 	if d.lo == 0 {
 		if d.hi == 0 {
-			return (n.hi / d.lo) as u128, (n.hi % d.lo) as u128
+			return (n.hi / d.lo) as u128, (n.hi % d.lo) as u128;
 		}
 		if n.lo == 0 {
-			r.hi = n.hi % d.hi
-			r.lo = 0
-			return (n.hi / d.hi) as u128, r.all
+			r.hi = n.hi % d.hi;
+			r.lo = 0;
+			return (n.hi / d.hi) as u128, r.all;
 		}
 		if (d.hi & (d.hi-1)) == 0 {
-			r.lo = n.lo
-			r.hi = n.hi & (d.hi-1)
-			return (n.hi >> ctz(d.hi)) as u128, r.all
+			r.lo = n.lo;
+			r.hi = n.hi & (d.hi-1);
+			return (n.hi >> ctz(d.hi)) as u128, r.all;
 		}
 
-		sr = clz(d.hi) - clz(n.hi)
+		sr = clz(d.hi) - clz(n.hi);
 		if sr > 64 - 2 {
-			return 0, n.all
+			return 0, n.all;
 		}
-		sr++
-		q.lo = 0
-		q.hi = n.lo << (64-sr)
-		r.hi = n.hi >> sr
-		r.lo = (n.hi << (64-sr)) | (n.lo >> sr)
+		sr++;
+		q.lo = 0;
+		q.hi = n.lo << (64-sr);
+		r.hi = n.hi >> sr;
+		r.lo = (n.hi << (64-sr)) | (n.lo >> sr);
 	} else {
 		if d.hi == 0 {
 			if (d.lo & (d.lo - 1)) == 0 {
-				rem := (n.lo % (d.lo - 1)) as u128
+				rem := (n.lo % (d.lo - 1)) as u128;
 				if d.lo == 1 {
-					return n.all, rem
+					return n.all, rem;
 				}
-				sr = ctz(d.lo)
-				q.hi = n.hi >> sr
+				sr = ctz(d.lo);
+				q.hi = n.hi >> sr;
 				q.lo = (n.hi << (64-sr)) | (n.lo >> sr);
-				return q.all, rem
+				return q.all, rem;
 			}
 
-			sr = 1 + 64 + clz(d.lo) - clz(n.hi)
+			sr = 1 + 64 + clz(d.lo) - clz(n.hi);
 
-			q.all = n.all << (128-sr)
-			r.all = n.all >> sr
+			q.all = n.all << (128-sr);
+			r.all = n.all >> sr;
 			if sr == 64 {
-				q.lo = 0
-				q.hi = n.lo
-				r.hi = 0
-				r.lo = n.hi
+				q.lo = 0;
+				q.hi = n.lo;
+				r.hi = 0;
+				r.lo = n.hi;
 			} else if sr < 64 {
-				q.lo = 0
-				q.hi = n.lo << (64-sr)
-				r.hi = n.hi >> sr
-				r.lo = (n.hi << (64-sr)) | (n.lo >> sr)
+				q.lo = 0;
+				q.hi = n.lo << (64-sr);
+				r.hi = n.hi >> sr;
+				r.lo = (n.hi << (64-sr)) | (n.lo >> sr);
 			} else {
-				q.lo = n.lo << (128-sr)
-				q.hi = (n.hi << (128-sr)) | (n.lo >> (sr-64))
-				r.hi = 0
-				r.lo = n.hi >> (sr-64)
+				q.lo = n.lo << (128-sr);
+				q.hi = (n.hi << (128-sr)) | (n.lo >> (sr-64));
+				r.hi = 0;
+				r.lo = n.hi >> (sr-64);
 			}
 		} else {
-			sr = clz(d.hi) - clz(n.hi)
+			sr = clz(d.hi) - clz(n.hi);
 			if sr > 64-1 {
-				return 0, n.all
+				return 0, n.all;
 			}
-			sr++
-			q.lo = 0
-			q.hi = n.lo << (64-sr)
-			r.all = n.all >> sr
+			sr++;
+			q.lo = 0;
+			q.hi = n.lo << (64-sr);
+			r.all = n.all >> sr;
 			if sr < 64 {
-				r.hi = n.hi >> sr
-				r.lo = (n.hi << (64-sr)) | (n.lo >> sr)
+				r.hi = n.hi >> sr;
+				r.lo = (n.hi << (64-sr)) | (n.lo >> sr);
 			} else {
-				r.hi = 0
-				r.lo = n.hi
+				r.hi = 0;
+				r.lo = n.hi;
 			}
 		}
 	}
 
-	carry: u64
+	carry: u64;
 	for ; sr > 0; sr-- {
-		r.hi = (r.hi << 1) | (r.lo >> (64-1))
-		r.lo = (r.lo << 1) | (r.hi >> (64-1))
-		q.hi = (q.hi << 1) | (q.lo >> (64-1))
-		q.lo = (q.lo << 1) | carry
+		r.hi = (r.hi << 1) | (r.lo >> (64-1));
+		r.lo = (r.lo << 1) | (r.hi >> (64-1));
+		q.hi = (q.hi << 1) | (q.lo >> (64-1));
+		q.lo = (q.lo << 1) | carry;
 
-		carry = 0
+		carry = 0;
 		if r.all >= d.all {
-			r.all -= d.all
-			carry = 1
+			r.all -= d.all;
+			carry = 1;
 		}
 	}
 
-	q.all = (q.all << 1) | (carry as u128)
-	return q.all, r.all
+	q.all = (q.all << 1) | (carry as u128);
+	return q.all, r.all;
 }

+ 278 - 276
core/fmt.odin

@@ -1,591 +1,593 @@
-#import "os.odin"
-#import "mem.odin"
-#import "utf8.odin"
+#import "os.odin";
+#import "mem.odin";
+#import "utf8.odin";
 
-PRINT_BUF_SIZE :: 1<<12
+PRINT_BUF_SIZE :: 1<<12;
 
 fprint :: proc(f: ^os.File, args: ..any) -> int {
-	data: [PRINT_BUF_SIZE]byte
-	buf := data[:0]
-	bprint(^buf, ..args)
-	os.write(f, buf)
-	return buf.count
+	data: [PRINT_BUF_SIZE]byte;
+	buf := data[:0];
+	bprint(^buf, ..args);
+	os.write(f, buf);
+	return buf.count;
 }
 
 fprintln :: proc(f: ^os.File, args: ..any) -> int {
-	data: [PRINT_BUF_SIZE]byte
-	buf := data[:0]
-	bprintln(^buf, ..args)
-	os.write(f, buf)
-	return buf.count
+	data: [PRINT_BUF_SIZE]byte;
+	buf := data[:0];
+	bprintln(^buf, ..args);
+	os.write(f, buf);
+	return buf.count;
 }
 fprintf :: proc(f: ^os.File, fmt: string, args: ..any) -> int {
-	data: [PRINT_BUF_SIZE]byte
-	buf := data[:0]
-	bprintf(^buf, fmt, ..args)
-	os.write(f, buf)
-	return buf.count
+	data: [PRINT_BUF_SIZE]byte;
+	buf := data[:0];
+	bprintf(^buf, fmt, ..args);
+	os.write(f, buf);
+	return buf.count;
 }
 
 
 print :: proc(args: ..any) -> int {
-	return fprint(os.stdout, ..args)
+	return fprint(os.stdout, ..args);
 }
 println :: proc(args: ..any) -> int {
-	return fprintln(os.stdout, ..args)
+	return fprintln(os.stdout, ..args);
 }
 printf :: proc(fmt: string, args: ..any) -> int {
-	return fprintf(os.stdout, fmt, ..args)
+	return fprintf(os.stdout, fmt, ..args);
 }
 
 
 
 fprint_type :: proc(f: ^os.File, info: ^Type_Info) {
-	data: [PRINT_BUF_SIZE]byte
-	buf := data[:0]
-	print_type_to_buffer(^buf, info)
-	os.write(f, buf)
+	data: [PRINT_BUF_SIZE]byte;
+	buf := data[:0];
+	print_type_to_buffer(^buf, info);
+	os.write(f, buf);
 }
 
 
 
 print_byte_buffer :: proc(buf: ^[]byte, b: []byte) {
 	if buf.count < buf.capacity {
-		n := min(buf.capacity-buf.count, b.count)
+		n := min(buf.capacity-buf.count, b.count);
 		if n > 0 {
-			mem.copy(buf.data + buf.count, ^b[0], n)
-			buf.count += n
+			mem.copy(buf.data + buf.count, b.data, n);
+			buf.count += n;
 		}
 	}
 }
 
 print_string_to_buffer :: proc(buf: ^[]byte, s: string) {
-	print_byte_buffer(buf, s as []byte)
+	print_byte_buffer(buf, s as []byte);
 }
 
 
 byte_reverse :: proc(b: []byte) {
-	n := b.count
+	n := b.count;
 	for i := 0; i < n/2; i++ {
-		b[i], b[n-1-i] = b[n-1-i], b[i]
+		b[i], b[n-1-i] = b[n-1-i], b[i];
 	}
 }
 
 print_rune_to_buffer :: proc(buf: ^[]byte, r: rune) {
-	b, n := utf8.encode_rune(r)
-	print_string_to_buffer(buf, b[:n] as string)
+	b, n := utf8.encode_rune(r);
+	print_string_to_buffer(buf, b[:n] as string);
 }
 
-print_space_to_buffer :: proc(buf: ^[]byte) { print_rune_to_buffer(buf, ' ') }
-print_nl_to_buffer    :: proc(buf: ^[]byte) { print_rune_to_buffer(buf, '\n') }
+print_space_to_buffer :: proc(buf: ^[]byte) { print_rune_to_buffer(buf, ' '); }
+print_nl_to_buffer    :: proc(buf: ^[]byte) { print_rune_to_buffer(buf, '\n'); }
 
-__NUM_TO_CHAR_TABLE := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@$"
+__NUM_TO_CHAR_TABLE := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@$";
 
 print_bool_to_buffer :: proc(buffer: ^[]byte, b : bool) {
-	if b { print_string_to_buffer(buffer, "true") }
-	else { print_string_to_buffer(buffer, "false") }
+	if b { print_string_to_buffer(buffer, "true"); }
+	else { print_string_to_buffer(buffer, "false"); }
 }
 
 print_pointer_to_buffer :: proc(buffer: ^[]byte, p: rawptr) #inline {
-	print_string_to_buffer(buffer, "0x")
-	print_u64_to_buffer(buffer, p as uint as u64)
+	print_string_to_buffer(buffer, "0x");
+	print_u64_to_buffer(buffer, p as uint as u64);
 }
 
-print_f16_to_buffer  :: proc(buffer: ^[]byte, f: f32)  #inline { print__f64(buffer, f as f64, 4) }
-print_f32_to_buffer  :: proc(buffer: ^[]byte, f: f32)  #inline { print__f64(buffer, f as f64, 7) }
-print_f64_to_buffer  :: proc(buffer: ^[]byte, f: f64)  #inline { print__f64(buffer, f as f64, 16) }
+print_f16_to_buffer  :: proc(buffer: ^[]byte, f: f32)  #inline { print__f64(buffer, f as f64, 4); }
+print_f32_to_buffer  :: proc(buffer: ^[]byte, f: f32)  #inline { print__f64(buffer, f as f64, 7); }
+print_f64_to_buffer  :: proc(buffer: ^[]byte, f: f64)  #inline { print__f64(buffer, f as f64, 16); }
 print_u64_to_buffer :: proc(buffer: ^[]byte, value: u64) {
-	i := value
-	buf: [20]byte
-	len := 0
+	i := value;
+	buf: [20]byte;
+	len := 0;
 	if i == 0 {
-		buf[len] = '0'
-		len++
+		buf[len] = '0';
+		len++;
 	}
 	for i > 0 {
-		buf[len] = __NUM_TO_CHAR_TABLE[i % 10]
-		len++
-		i /= 10
+		buf[len] = __NUM_TO_CHAR_TABLE[i % 10];
+		len++;
+		i /= 10;
 	}
-	byte_reverse(buf[:len])
-	print_string_to_buffer(buffer, buf[:len] as string)
+	byte_reverse(buf[:len]);
+	print_string_to_buffer(buffer, buf[:len] as string);
 }
 print_i64_to_buffer :: proc(buffer: ^[]byte, value: i64) {
-	i := value
-	neg := i < 0
+	i := value;
+	neg := i < 0;
 	if neg {
-		i = -i
-		print_rune_to_buffer(buffer, '-')
+		i = -i;
+		print_rune_to_buffer(buffer, '-');
 	}
-	print_u64_to_buffer(buffer, i as u64)
+	print_u64_to_buffer(buffer, i as u64);
 }
 
 print_u128_to_buffer :: proc(buffer: ^[]byte, value: u128) {
-	a := value transmute [2]u64
+	a := value transmute [2]u64;
 	if a[1] != 0 {
-		print_u64_to_buffer(buffer, a[1])
+		print_u64_to_buffer(buffer, a[1]);
 	}
-	print_u64_to_buffer(buffer, a[0])
+	print_u64_to_buffer(buffer, a[0]);
 }
 print_i128_to_buffer :: proc(buffer: ^[]byte, value: i128) {
-	i := value
-	neg := i < 0
+	i := value;
+	neg := i < 0;
 	if neg {
-		i = -i
-		print_rune_to_buffer(buffer, '-')
+		i = -i;
+		print_rune_to_buffer(buffer, '-');
 	}
-	print_u128_to_buffer(buffer, i as u128)
+	print_u128_to_buffer(buffer, i as u128);
 }
 
 
 
 print__f64 :: proc(buffer: ^[]byte, value: f64, decimal_places: int) {
-	f := value
+	f := value;
 	if f == 0 {
-		print_rune_to_buffer(buffer, '0')
-		return
+		print_rune_to_buffer(buffer, '0');
+		return;
 	}
 	if f < 0 {
-		print_rune_to_buffer(buffer, '-')
-		f = -f
+		print_rune_to_buffer(buffer, '-');
+		f = -f;
 	}
 
-	i := f as u64
-	print_u64_to_buffer(buffer, i)
-	f -= i as f64
+	i := f as u64;
+	print_u64_to_buffer(buffer, i);
+	f -= i as f64;
 
-	print_rune_to_buffer(buffer, '.')
+	print_rune_to_buffer(buffer, '.');
 
-	mult: f64 = 10.0
+	mult: f64 = 10.0;
 	for ; decimal_places >= 0; decimal_places-- {
-		i = (f * mult) as u64
-		print_u64_to_buffer(buffer, i as u64)
-		f -= i as f64 / mult
-		mult *= 10
+		i = (f * mult) as u64;
+		print_u64_to_buffer(buffer, i as u64);
+		f -= i as f64 / mult;
+		mult *= 10;
 	}
 }
 
 print_type_to_buffer :: proc(buf: ^[]byte, ti: ^Type_Info) {
-	if ti == nil { return }
+	if ti == nil {
+		return;
+	}
 
-	using Type_Info
+	using Type_Info;
 	match type info : ti {
 	case Named:
-		print_string_to_buffer(buf, info.name)
+		print_string_to_buffer(buf, info.name);
 	case Integer:
 		match {
 		case ti == type_info(int):
-			print_string_to_buffer(buf, "int")
+			print_string_to_buffer(buf, "int");
 		case ti == type_info(uint):
-			print_string_to_buffer(buf, "uint")
+			print_string_to_buffer(buf, "uint");
 		default:
 			if info.signed {
-				print_string_to_buffer(buf, "i")
+				print_string_to_buffer(buf, "i");
 			} else {
-				print_string_to_buffer(buf, "u")
+				print_string_to_buffer(buf, "u");
 			}
-			print_u64_to_buffer(buf, 8*info.size as u64)
+			print_u64_to_buffer(buf, 8*info.size as u64);
 		}
 
 	case Float:
 		match info.size {
-		case 4: print_string_to_buffer(buf, "f32")
-		case 8: print_string_to_buffer(buf, "f64")
+		case 4: print_string_to_buffer(buf, "f32");
+		case 8: print_string_to_buffer(buf, "f64");
 		}
-	case String:  print_string_to_buffer(buf, "string")
-	case Boolean: print_string_to_buffer(buf, "bool")
+	case String:  print_string_to_buffer(buf, "string");
+	case Boolean: print_string_to_buffer(buf, "bool");
 	case Pointer:
 		if info.elem == nil {
-			print_string_to_buffer(buf, "rawptr")
+			print_string_to_buffer(buf, "rawptr");
 		} else {
-			print_string_to_buffer(buf, "^")
-			print_type_to_buffer(buf, info.elem)
+			print_string_to_buffer(buf, "^");
+			print_type_to_buffer(buf, info.elem);
 		}
 	case Maybe:
-		print_string_to_buffer(buf, "?")
-		print_type_to_buffer(buf, info.elem)
+		print_string_to_buffer(buf, "?");
+		print_type_to_buffer(buf, info.elem);
 	case Procedure:
-		print_string_to_buffer(buf, "proc")
+		print_string_to_buffer(buf, "proc");
 		if info.params == nil {
-			print_string_to_buffer(buf, "()")
+			print_string_to_buffer(buf, "()");
 		} else {
-			count := (info.params as ^Tuple).fields.count
-			if count == 1 { print_string_to_buffer(buf, "(") }
-			print_type_to_buffer(buf, info.params)
-			if count == 1 { print_string_to_buffer(buf, ")") }
+			count := (info.params as ^Tuple).fields.count;
+			if count == 1 { print_string_to_buffer(buf, "("); }
+			print_type_to_buffer(buf, info.params);
+			if count == 1 { print_string_to_buffer(buf, ")"); }
 		}
 		if info.results != nil {
-			print_string_to_buffer(buf, " -> ")
-			print_type_to_buffer(buf, info.results)
+			print_string_to_buffer(buf, " -> ");
+			print_type_to_buffer(buf, info.results);
 		}
 	case Tuple:
-		count := info.fields.count
-		if count != 1 { print_string_to_buffer(buf, "(") }
+		count := info.fields.count;
+		if count != 1 { print_string_to_buffer(buf, "("); }
 		for i := 0; i < count; i++ {
-			if i > 0 { print_string_to_buffer(buf, ", ") }
+			if i > 0 { print_string_to_buffer(buf, ", "); }
 
-			f := info.fields[i]
+			f := info.fields[i];
 
 			if f.name.count > 0 {
-				print_string_to_buffer(buf, f.name)
-				print_string_to_buffer(buf, ": ")
+				print_string_to_buffer(buf, f.name);
+				print_string_to_buffer(buf, ": ");
 			}
-			print_type_to_buffer(buf, f.type_info)
+			print_type_to_buffer(buf, f.type_info);
 		}
-		if count != 1 { print_string_to_buffer(buf, ")") }
+		if count != 1 { print_string_to_buffer(buf, ")"); }
 
 	case Array:
-		print_string_to_buffer(buf, "[")
-		print_i64_to_buffer(buf, info.count as i64)
-		print_string_to_buffer(buf, "]")
-		print_type_to_buffer(buf, info.elem)
+		print_string_to_buffer(buf, "[");
+		print_i64_to_buffer(buf, info.count as i64);
+		print_string_to_buffer(buf, "]");
+		print_type_to_buffer(buf, info.elem);
 	case Slice:
-		print_string_to_buffer(buf, "[")
-		print_string_to_buffer(buf, "]")
-		print_type_to_buffer(buf, info.elem)
+		print_string_to_buffer(buf, "[");
+		print_string_to_buffer(buf, "]");
+		print_type_to_buffer(buf, info.elem);
 	case Vector:
-		print_string_to_buffer(buf, "[vector ")
-		print_i64_to_buffer(buf, info.count as i64)
-		print_string_to_buffer(buf, "]")
-		print_type_to_buffer(buf, info.elem)
+		print_string_to_buffer(buf, "[vector ");
+		print_i64_to_buffer(buf, info.count as i64);
+		print_string_to_buffer(buf, "]");
+		print_type_to_buffer(buf, info.elem);
 
 	case Struct:
-		print_string_to_buffer(buf, "struct ")
-		if info.packed  { print_string_to_buffer(buf, "#packed ") }
-		if info.ordered { print_string_to_buffer(buf, "#ordered ") }
-		print_string_to_buffer(buf, "{")
+		print_string_to_buffer(buf, "struct ");
+		if info.packed  { print_string_to_buffer(buf, "#packed "); }
+		if info.ordered { print_string_to_buffer(buf, "#ordered "); }
+		print_string_to_buffer(buf, "{");
 		for i := 0; i < info.fields.count; i++ {
 			if i > 0 {
-				print_string_to_buffer(buf, ", ")
+				print_string_to_buffer(buf, ", ");
 			}
-			print_any_to_buffer(buf, info.fields[i].name)
-			print_string_to_buffer(buf, ": ")
-			print_type_to_buffer(buf, info.fields[i].type_info)
+			print_any_to_buffer(buf, info.fields[i].name);
+			print_string_to_buffer(buf, ": ");
+			print_type_to_buffer(buf, info.fields[i].type_info);
 		}
-		print_string_to_buffer(buf, "}")
+		print_string_to_buffer(buf, "}");
 
 	case Union:
-		print_string_to_buffer(buf, "union {")
+		print_string_to_buffer(buf, "union {");
 		for i := 0; i < info.fields.count; i++ {
 			if i > 0 {
-				print_string_to_buffer(buf, ", ")
+				print_string_to_buffer(buf, ", ");
 			}
-			print_any_to_buffer(buf, info.fields[i].name)
-			print_string_to_buffer(buf, ": ")
-			print_type_to_buffer(buf, info.fields[i].type_info)
+			print_any_to_buffer(buf, info.fields[i].name);
+			print_string_to_buffer(buf, ": ");
+			print_type_to_buffer(buf, info.fields[i].type_info);
 		}
-		print_string_to_buffer(buf, "}")
+		print_string_to_buffer(buf, "}");
 
 	case Raw_Union:
-		print_string_to_buffer(buf, "raw_union {")
+		print_string_to_buffer(buf, "raw_union {");
 		for i := 0; i < info.fields.count; i++ {
 			if i > 0 {
-				print_string_to_buffer(buf, ", ")
+				print_string_to_buffer(buf, ", ");
 			}
-			print_any_to_buffer(buf, info.fields[i].name)
-			print_string_to_buffer(buf, ": ")
-			print_type_to_buffer(buf, info.fields[i].type_info)
+			print_any_to_buffer(buf, info.fields[i].name);
+			print_string_to_buffer(buf, ": ");
+			print_type_to_buffer(buf, info.fields[i].type_info);
 		}
-		print_string_to_buffer(buf, "}")
+		print_string_to_buffer(buf, "}");
 
 	case Enum:
-		print_string_to_buffer(buf, "enum ")
-		print_type_to_buffer(buf, info.base)
-		print_string_to_buffer(buf, "{}")
+		print_string_to_buffer(buf, "enum ");
+		print_type_to_buffer(buf, info.base);
+		print_string_to_buffer(buf, "{}");
 	}
 }
 
 
 make_any :: proc(type_info: ^Type_Info, data: rawptr) -> any {
-	a: any
-	a.type_info = type_info
-	a.data = data
-	return a
+	a: any;
+	a.type_info = type_info;
+	a.data = data;
+	return a;
 }
 
 print_any_to_buffer :: proc(buf: ^[]byte, arg: any) {
 	if arg.type_info == nil {
-		print_string_to_buffer(buf, "<nil>")
-		return
+		print_string_to_buffer(buf, "<nil>");
+		return;
 	}
 
 	if arg.data == nil {
-		print_string_to_buffer(buf, "<nil>")
-		return
+		print_string_to_buffer(buf, "<nil>");
+		return;
 	}
 
-	using Type_Info
+	using Type_Info;
 	match type info : arg.type_info {
 	case Named:
-		a := make_any(info.base, arg.data)
+		a := make_any(info.base, arg.data);
 		match type b : info.base {
 		case Struct:
-			print_string_to_buffer(buf, info.name)
-			print_string_to_buffer(buf, "{")
+			print_string_to_buffer(buf, info.name);
+			print_string_to_buffer(buf, "{");
 			for i := 0; i < b.fields.count; i++ {
 				f := b.fields[i];
 				if i > 0 {
-					print_string_to_buffer(buf, ", ")
+					print_string_to_buffer(buf, ", ");
 				}
-				print_string_to_buffer(buf, f.name)
-				// print_any_to_buffer(buf, f.offset)
-				print_string_to_buffer(buf, " = ")
-				data := arg.data as ^byte + f.offset
-				print_any_to_buffer(buf, make_any(f.type_info, data))
+				print_string_to_buffer(buf, f.name);
+				// print_any_to_buffer(buf, f.offset);
+				print_string_to_buffer(buf, " = ");
+				data := arg.data as ^byte + f.offset;
+				print_any_to_buffer(buf, make_any(f.type_info, data));
 			}
-			print_string_to_buffer(buf, "}")
+			print_string_to_buffer(buf, "}");
 
 		default:
-			print_any_to_buffer(buf, a)
+			print_any_to_buffer(buf, a);
 		}
 
 	case Integer:
 		match type i : arg {
-		case i8:   print_i64_to_buffer(buf, i as i64)
-		case u8:   print_u64_to_buffer(buf, i as u64)
-		case i16:  print_i64_to_buffer(buf, i as i64)
-		case u16:  print_u64_to_buffer(buf, i as u64)
-		case i32:  print_i64_to_buffer(buf, i as i64)
-		case u32:  print_u64_to_buffer(buf, i as u64)
-		case i64:  print_i64_to_buffer(buf, i as i64)
-		case u64:  print_u64_to_buffer(buf, i as u64)
-		case i128: print_i128_to_buffer(buf, i)
-		case u128: print_u128_to_buffer(buf, i)
+		case i8:   print_i64_to_buffer(buf, i as i64);
+		case u8:   print_u64_to_buffer(buf, i as u64);
+		case i16:  print_i64_to_buffer(buf, i as i64);
+		case u16:  print_u64_to_buffer(buf, i as u64);
+		case i32:  print_i64_to_buffer(buf, i as i64);
+		case u32:  print_u64_to_buffer(buf, i as u64);
+		case i64:  print_i64_to_buffer(buf, i as i64);
+		case u64:  print_u64_to_buffer(buf, i as u64);
+		case i128: print_i128_to_buffer(buf, i);
+		case u128: print_u128_to_buffer(buf, i);
 
-		case int:  print_u64_to_buffer(buf, i as u64)
-		case uint: print_u64_to_buffer(buf, i as u64)
+		case int:  print_u64_to_buffer(buf, i as u64);
+		case uint: print_u64_to_buffer(buf, i as u64);
 		}
 
 	case Float:
 		match type f : arg {
-		// case f16:  print_f64_to_buffer(buf, f as f64)
-		case f32:  print_f32_to_buffer(buf, f)
-		case f64:  print_f64_to_buffer(buf, f)
-		// case f128: print_f64_to_buffer(buf, f as f64)
+		// case f16:  print_f64_to_buffer(buf, f as f64);
+		case f32:  print_f32_to_buffer(buf, f);
+		case f64:  print_f64_to_buffer(buf, f);
+		// case f128: print_f64_to_buffer(buf, f as f64);
 		}
 
 	case String:
 		match type s : arg {
-		case string: print_string_to_buffer(buf, s)
+		case string: print_string_to_buffer(buf, s);
 		}
 
 	case Boolean:
 		match type b : arg {
-		case bool: print_bool_to_buffer(buf, b)
+		case bool: print_bool_to_buffer(buf, b);
 		}
 
 	case Pointer:
 		match type p : arg {
-		case ^Type_Info: print_type_to_buffer(buf, p)
-		default:         print_pointer_to_buffer(buf, (arg.data as ^rawptr)^)
+		case ^Type_Info: print_type_to_buffer(buf, p);
+		default:         print_pointer_to_buffer(buf, (arg.data as ^rawptr)^);
 		}
 
 	case Maybe:
-		size := mem.size_of_type_info(info.elem)
-		data := slice_ptr(arg.data as ^byte, size+1)
+		size := mem.size_of_type_info(info.elem);
+		data := slice_ptr(arg.data as ^byte, size+1);
 		if data[size] != 0 {
-			print_any_to_buffer(buf, make_any(info.elem, arg.data))
+			print_any_to_buffer(buf, make_any(info.elem, arg.data));
 		} else {
-			print_string_to_buffer(buf, "nil")
+			print_string_to_buffer(buf, "nil");
 		}
 
 	case Enum:
-		value: i64 = 0
+		value: i64 = 0;
 
 		match type i : make_any(info.base, arg.data) {
-		case i8:   value = i as i64
-		case i16:  value = i as i64
-		case i32:  value = i as i64
-		case i64:  value = i as i64
-		case u8:   value = i as i64
-		case u16:  value = i as i64
-		case u32:  value = i as i64
-		case u64:  value = i as i64
+		case i8:   value = i as i64;
+		case i16:  value = i as i64;
+		case i32:  value = i as i64;
+		case i64:  value = i as i64;
+		case u8:   value = i as i64;
+		case u16:  value = i as i64;
+		case u32:  value = i as i64;
+		case u64:  value = i as i64;
 		}
-		print_string_to_buffer(buf, __enum_to_string(arg.type_info, value))
+		print_string_to_buffer(buf, __enum_to_string(arg.type_info, value));
 
 	case Array:
-		bprintf(buf, "[%]%{", info.count, info.elem)
-		defer print_string_to_buffer(buf, "}")
+		bprintf(buf, "[%]%{", info.count, info.elem);
+		defer print_string_to_buffer(buf, "}");
 
 		for i := 0; i < info.count; i++ {
 			if i > 0 {
-				print_string_to_buffer(buf, ", ")
+				print_string_to_buffer(buf, ", ");
 			}
 
-			data := arg.data as ^byte + i*info.elem_size
-			print_any_to_buffer(buf, make_any(info.elem, data))
+			data := arg.data as ^byte + i*info.elem_size;
+			print_any_to_buffer(buf, make_any(info.elem, data));
 		}
 
 	case Slice:
-		slice := arg.data as ^[]byte
-		bprintf(buf, "[]%{", info.elem)
-		defer print_string_to_buffer(buf, "}")
+		slice := arg.data as ^[]byte;
+		bprintf(buf, "[]%{", info.elem);
+		defer print_string_to_buffer(buf, "}");
 
 		for i := 0; i < slice.count; i++ {
 			if i > 0 {
-				print_string_to_buffer(buf, ", ")
+				print_string_to_buffer(buf, ", ");
 			}
 
-			data := slice.data + i*info.elem_size
-			print_any_to_buffer(buf, make_any(info.elem, data))
+			data := slice.data + i*info.elem_size;
+			print_any_to_buffer(buf, make_any(info.elem, data));
 		}
 
 	case Vector:
 		is_bool :: proc(type_info: ^Type_Info) -> bool {
 			match type info : type_info {
 			case Named:
-				return is_bool(info.base)
+				return is_bool(info.base);
 			case Boolean:
-				return true
+				return true;
 			}
-			return false
+			return false;
 		}
 
-		bprintf(buf, "[vector %]%{", info.count, info.elem)
-		defer print_string_to_buffer(buf, "}")
+		bprintf(buf, "[vector %]%{", info.count, info.elem);
+		defer print_string_to_buffer(buf, "}");
 
 		if is_bool(info.elem) {
-			return
+			return;
 		}
 
 		for i := 0; i < info.count; i++ {
 			if i > 0 {
-				print_string_to_buffer(buf, ", ")
+				print_string_to_buffer(buf, ", ");
 			}
 
-			data := arg.data as ^byte + i*info.elem_size
-			print_any_to_buffer(buf, make_any(info.elem, data))
+			data := arg.data as ^byte + i*info.elem_size;
+			print_any_to_buffer(buf, make_any(info.elem, data));
 		}
 
 
 	case Struct:
-		bprintf(buf, "%{", arg.type_info)
-		defer print_string_to_buffer(buf, "}")
+		bprintf(buf, "%{", arg.type_info);
+		defer print_string_to_buffer(buf, "}");
 
 		for i := 0; i < info.fields.count; i++ {
 			if i > 0 {
-				print_string_to_buffer(buf, ", ")
+				print_string_to_buffer(buf, ", ");
 			}
-			print_string_to_buffer(buf, info.fields[i].name)
-			print_string_to_buffer(buf, " = ")
-			data := arg.data as ^byte + info.fields[i].offset
-			ti := info.fields[i].type_info
-			print_any_to_buffer(buf, make_any(ti, data))
+			print_string_to_buffer(buf, info.fields[i].name);
+			print_string_to_buffer(buf, " = ");
+			data := arg.data as ^byte + info.fields[i].offset;
+			ti := info.fields[i].type_info;
+			print_any_to_buffer(buf, make_any(ti, data));
 		}
 
 	case Union:
-		print_string_to_buffer(buf, "(union)")
+		print_string_to_buffer(buf, "(union)");
 	case Raw_Union:
-		print_string_to_buffer(buf, "(raw_union)")
+		print_string_to_buffer(buf, "(raw_union)");
 	case Procedure:
-		print_type_to_buffer(buf, arg.type_info)
-		print_string_to_buffer(buf, " @ 0x")
-		print_pointer_to_buffer(buf, (arg.data as ^rawptr)^)
+		print_type_to_buffer(buf, arg.type_info);
+		print_string_to_buffer(buf, " @ 0x");
+		print_pointer_to_buffer(buf, (arg.data as ^rawptr)^);
 	}
 }
 
 
 bprintf :: proc(buf: ^[]byte, fmt: string, args: ..any) -> int {
 	is_digit :: proc(r: rune) -> bool #inline {
-		return '0' <= r && r <= '9'
+		return '0' <= r && r <= '9';
 	}
 
 	parse_int :: proc(s: string, offset: int) -> (int, int) {
-		result := 0
+		result := 0;
 
 		for ; offset < s.count; offset++ {
-			c := s[offset] as rune
+			c := s[offset] as rune;
 			if !is_digit(c) {
-				break
+				break;
 			}
 
-			result *= 10
-			result += (c - '0') as int
+			result *= 10;
+			result += (c - '0') as int;
 		}
 
-		return result, offset
+		return result, offset;
 	}
 
-	prev := 0
-	implicit_index := 0
+	prev := 0;
+	implicit_index := 0;
 
 	for i := 0; i < fmt.count; i++ {
-		r := fmt[i] as rune
-		index := implicit_index
+		r := fmt[i] as rune;
+		index := implicit_index;
 
 		if r != '%' {
-			continue
+			continue;
 		}
 
-		print_string_to_buffer(buf, fmt[prev:i])
-		i++ // Skip %
+		print_string_to_buffer(buf, fmt[prev:i]);
+		i++; // Skip %
 		if i < fmt.count {
-			next := fmt[i] as rune
+			next := fmt[i] as rune;
 
 			if next == '%' {
-				print_string_to_buffer(buf, "%")
-				i++
-				prev = i
-				continue
+				print_string_to_buffer(buf, "%");
+				i++;
+				prev = i;
+				continue;
 			}
 
 			if is_digit(next) {
-				index, i = parse_int(fmt, i)
+				index, i = parse_int(fmt, i);
 			}
 		}
 
 		if 0 <= index && index < args.count {
-			print_any_to_buffer(buf, args[index])
-			implicit_index = index+1
+			print_any_to_buffer(buf, args[index]);
+			implicit_index = index+1;
 		} else {
 			// TODO(bill): Error check index out bounds
-			print_string_to_buffer(buf, "<invalid>")
+			print_string_to_buffer(buf, "<invalid>");
 		}
 
-		prev = i
+		prev = i;
 	}
 
-	print_string_to_buffer(buf, fmt[prev:])
-	return buf.count
+	print_string_to_buffer(buf, fmt[prev:]);
+	return buf.count;
 }
 
 
 bprint :: proc(buf: ^[]byte, args: ..any) -> int {
 	is_type_string :: proc(info: ^Type_Info) -> bool {
-		using Type_Info
+		using Type_Info;
 		if info == nil {
-			return false
+			return false;
 		}
 
 		match type i : type_info_base(info) {
 		case String:
-			return true
+			return true;
 		}
-		return false
+		return false;
 	}
 
 
-	prev_string := false
+	prev_string := false;
 	for i := 0; i < args.count; i++ {
-		arg := args[i]
-		is_string := arg.data != nil && is_type_string(arg.type_info)
+		arg := args[i];
+		is_string := arg.data != nil && is_type_string(arg.type_info);
 		if i > 0 && !is_string && !prev_string {
-			print_space_to_buffer(buf)
+			print_space_to_buffer(buf);
 		}
-		print_any_to_buffer(buf, arg)
+		print_any_to_buffer(buf, arg);
 		prev_string = is_string;
 	}
-	return buf.count
+	return buf.count;
 }
 
 bprintln :: proc(buf: ^[]byte, args: ..any) -> int {
 	for i := 0; i < args.count; i++ {
 		if i > 0 {
-			append(buf, ' ')
+			append(buf, ' ');
 		}
-		print_any_to_buffer(buf, args[i])
+		print_any_to_buffer(buf, args[i]);
 	}
-	print_nl_to_buffer(buf)
-	return buf.count
+	print_nl_to_buffer(buf);
+	return buf.count;
 }

+ 96 - 96
core/hash.odin

@@ -1,164 +1,164 @@
 crc32 :: proc(data: rawptr, len: int) -> u32 {
-	result := ~(0 as u32)
-	s := slice_ptr(data as ^u8, len)
+	result := ~(0 as u32);
+	s := slice_ptr(data as ^u8, len);
 	for i := 0; i < len; i++ {
-		b := s[i] as u32
-		result = result>>8 ~ __CRC32_TABLE[(result ~ b) & 0xff]
+		b := s[i] as u32;
+		result = result>>8 ~ __CRC32_TABLE[(result ~ b) & 0xff];
 	}
-	return ~result
+	return ~result;
 }
 crc64 :: proc(data: rawptr, len: int) -> u64 {
-	result := ~(0 as u64)
-	s := slice_ptr(data as ^u8, len)
+	result := ~(0 as u64);
+	s := slice_ptr(data as ^u8, len);
 	for i := 0; i < len; i++ {
-		b := s[i] as u64
-		result = result>>8 ~ __CRC64_TABLE[(result ~ b) & 0xff]
+		b := s[i] as u64;
+		result = result>>8 ~ __CRC64_TABLE[(result ~ b) & 0xff];
 	}
-	return ~result
+	return ~result;
 }
 
 fnv32 :: proc(data: rawptr, len: int) -> u32 {
-	s := slice_ptr(data as ^u8, len)
+	s := slice_ptr(data as ^u8, len);
 
-	h: u32 = 0x811c9dc5
+	h: u32 = 0x811c9dc5;
 	for i := 0; i < len; i++ {
-		h = (h * 0x01000193) ~ s[i] as u32
+		h = (h * 0x01000193) ~ s[i] as u32;
 	}
-	return h
+	return h;
 }
 
 fnv64 :: proc(data: rawptr, len: int) -> u64 {
-	s := slice_ptr(data as ^u8, len)
+	s := slice_ptr(data as ^u8, len);
 
-	h: u64 = 0xcbf29ce484222325
+	h: u64 = 0xcbf29ce484222325;
 	for i := 0; i < len; i++ {
-		h = (h * 0x100000001b3) ~ s[i] as u64
+		h = (h * 0x100000001b3) ~ s[i] as u64;
 	}
-	return h
+	return h;
 }
 
 fnv32a :: proc(data: rawptr, len: int) -> u32 {
-	s := slice_ptr(data as ^u8, len)
+	s := slice_ptr(data as ^u8, len);
 
-	h: u32 = 0x811c9dc5
+	h: u32 = 0x811c9dc5;
 	for i := 0; i < len; i++ {
-		h = (h ~ s[i] as u32) * 0x01000193
+		h = (h ~ s[i] as u32) * 0x01000193;
 	}
-	return h
+	return h;
 }
 
 fnv64a :: proc(data: rawptr, len: int) -> u64 {
-	s := slice_ptr(data as ^u8, len)
+	s := slice_ptr(data as ^u8, len);
 
-	h: u64 = 0xcbf29ce484222325
+	h: u64 = 0xcbf29ce484222325;
 	for i := 0; i < len; i++ {
-		h = (h ~ s[i] as u64) * 0x100000001b3
+		h = (h ~ s[i] as u64) * 0x100000001b3;
 	}
-	return h
+	return h;
 }
 
 
 murmur64 :: proc(data_: rawptr, len: int) -> u64 {
-	SEED :: 0x9747b28c
+	SEED :: 0x9747b28c;
 
 	if size_of(int) == 8 {
-		m :: 0xc6a4a7935bd1e995
-		r :: 47
+		m :: 0xc6a4a7935bd1e995;
+		r :: 47;
 
-		h: u64 = SEED ~ (len as u64 * m)
+		h: u64 = SEED ~ (len as u64 * m);
 
-		data := slice_ptr(data_ as ^u64, len/size_of(u64))
-		data2 := slice_ptr(data_ as ^u8, len)
+		data := slice_ptr(data_ as ^u64, len/size_of(u64));
+		data2 := slice_ptr(data_ as ^u8, len);
 
 		for i := 0; i < data.count; i++ {
-			k := data[i]
+			k := data[i];
 
-			k *= m
-			k ~= k>>r
-			k *= m
+			k *= m;
+			k ~= k>>r;
+			k *= m;
 
-			h ~= k
-			h *= m
+			h ~= k;
+			h *= m;
 		}
 
 		match len & 7 {
-		case 7: h ~= data2[6] as u64 << 48; fallthrough
-		case 6: h ~= data2[5] as u64 << 40; fallthrough
-		case 5: h ~= data2[4] as u64 << 32; fallthrough
-		case 4: h ~= data2[3] as u64 << 24; fallthrough
-		case 3: h ~= data2[2] as u64 << 16; fallthrough
-		case 2: h ~= data2[1] as u64 << 8;  fallthrough
+		case 7: h ~= data2[6] as u64 << 48; fallthrough;
+		case 6: h ~= data2[5] as u64 << 40; fallthrough;
+		case 5: h ~= data2[4] as u64 << 32; fallthrough;
+		case 4: h ~= data2[3] as u64 << 24; fallthrough;
+		case 3: h ~= data2[2] as u64 << 16; fallthrough;
+		case 2: h ~= data2[1] as u64 << 8;  fallthrough;
 		case 1:
-			h ~= data2[0] as u64
-			h *= m
+			h ~= data2[0] as u64;
+			h *= m;
 		}
 
-		h ~= h>>r
-		h *= m
-		h ~= h>>r
+		h ~= h>>r;
+		h *= m;
+		h ~= h>>r;
 
-		return h
+		return h;
 	} else {
-		m :: 0x5bd1e995
-		r :: 24
+		m :: 0x5bd1e995;
+		r :: 24;
 
-		h1: u32 = SEED as u32 ~ len as u32
-		h2: u32 = SEED >> 32
+		h1: u32 = SEED as u32 ~ len as u32;
+		h2: u32 = SEED >> 32;
 
-		data := slice_ptr(data_ as ^u32, len/size_of(u32))
+		data := slice_ptr(data_ as ^u32, len/size_of(u32));
 
-		i := 0
+		i := 0;
 		for len >= 8 {
-			k1, k2: u32
-			k1 = data[i]; i++
-			k1 *= m
-			k1 ~= k1>>r
-			k1 *= m
-			h1 *= m
-			h1 ~= k1
-			len -= 4
+			k1, k2: u32;
+			k1 = data[i]; i++;
+			k1 *= m;
+			k1 ~= k1>>r;
+			k1 *= m;
+			h1 *= m;
+			h1 ~= k1;
+			len -= 4;
 
-			k2 = data[i]; i++
-			k2 *= m
-			k2 ~= k2>>r
-			k2 *= m
-			h2 *= m
-			h2 ~= k2
-			len -= 4
+			k2 = data[i]; i++;
+			k2 *= m;
+			k2 ~= k2>>r;
+			k2 *= m;
+			h2 *= m;
+			h2 ~= k2;
+			len -= 4;
 		}
 
 		if (len >= 4) {
-			k1: u32
-			k1 = data[i]; i++
-			k1 *= m
-			k1 ~= k1>>r
-			k1 *= m
-			h1 *= m
-			h1 ~= k1
-			len -= 4
+			k1: u32;
+			k1 = data[i]; i++;
+			k1 *= m;
+			k1 ~= k1>>r;
+			k1 *= m;
+			h1 *= m;
+			h1 ~= k1;
+			len -= 4;
 		}
 
-		data8 := slice_ptr((data.data+i) as ^u8, 3) // NOTE(bill): This is unsafe
+		data8 := slice_ptr((data.data+i) as ^u8, 3); // NOTE(bill): This is unsafe
 
 		match len {
-		case 3: h2 ~= data8[2] as u32 << 16; fallthrough
-		case 2: h2 ~= data8[1] as u32 << 8;  fallthrough
+		case 3: h2 ~= data8[2] as u32 << 16; fallthrough;
+		case 2: h2 ~= data8[1] as u32 << 8;  fallthrough;
 		case 1:
-			h2 ~= data8[0] as u32
-			h2 *= m
+			h2 ~= data8[0] as u32;
+			h2 *= m;
 		}
 
-		h1 ~= h2>>18
-		h1 *= m
-		h2 ~= h1>>22
-		h2 *= m
-		h1 ~= h2>>17
-		h1 *= m
-		h2 ~= h1>>19
-		h2 *= m
+		h1 ~= h2>>18;
+		h1 *= m;
+		h2 ~= h1>>22;
+		h2 *= m;
+		h1 ~= h2>>17;
+		h1 *= m;
+		h2 ~= h1>>19;
+		h2 *= m;
 
-		h := (h1 as u64)<<32 | h2 as u64
-		return h
+		h := (h1 as u64)<<32 | h2 as u64;
+		return h;
 	}
 }
 
@@ -229,7 +229,7 @@ __CRC32_TABLE := [256]u32{
 	0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
 	0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
 	0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
-}
+};
 __CRC64_TABLE := [256]u64{
 	0x0000000000000000, 0x42f0e1eba9ea3693, 0x85e1c3d753d46d26, 0xc711223cfa3e5bb5,
 	0x493366450e42ecdf, 0x0bc387aea7a8da4c, 0xccd2a5925d9681f9, 0x8e224479f47cb76a,
@@ -295,4 +295,4 @@ __CRC64_TABLE := [256]u64{
 	0xcf8b0890283e370c, 0x8d7be97b81d4019f, 0x4a6acb477bea5a2a, 0x089a2aacd2006cb9,
 	0x14dea25f3af9026d, 0x562e43b4931334fe, 0x913f6188692d6f4b, 0xd3cf8063c0c759d8,
 	0x5dedc41a34bbeeb2, 0x1f1d25f19d51d821, 0xd80c07cd676f8394, 0x9afce626ce85b507,
-}
+};

+ 214 - 217
core/math.odin

@@ -1,29 +1,29 @@
-TAU          :: 6.28318530717958647692528676655900576
-PI           :: 3.14159265358979323846264338327950288
-ONE_OVER_TAU :: 0.636619772367581343075535053490057448
-ONE_OVER_PI  :: 0.159154943091895335768883763372514362
+TAU          :: 6.28318530717958647692528676655900576;
+PI           :: 3.14159265358979323846264338327950288;
+ONE_OVER_TAU :: 0.636619772367581343075535053490057448;
+ONE_OVER_PI  :: 0.159154943091895335768883763372514362;
 
-E            :: 2.71828182845904523536
-SQRT_TWO     :: 1.41421356237309504880168872420969808
-SQRT_THREE   :: 1.73205080756887729352744634150587236
-SQRT_FIVE    :: 2.23606797749978969640917366873127623
+E            :: 2.71828182845904523536;
+SQRT_TWO     :: 1.41421356237309504880168872420969808;
+SQRT_THREE   :: 1.73205080756887729352744634150587236;
+SQRT_FIVE    :: 2.23606797749978969640917366873127623;
 
-LOG_TWO      :: 0.693147180559945309417232121458176568
-LOG_TEN      :: 2.30258509299404568401799145468436421
+LOG_TWO      :: 0.693147180559945309417232121458176568;
+LOG_TEN      :: 2.30258509299404568401799145468436421;
 
-EPSILON      :: 1.19209290e-7
+EPSILON      :: 1.19209290e-7;
 
-τ :: TAU
-π :: PI
+τ :: TAU;
+π :: PI;
 
 
-Vec2 :: type {2}f32
-Vec3 :: type {3}f32
-Vec4 :: type {4}f32
+Vec2 :: type [vector 2]f32;
+Vec3 :: type [vector 3]f32;
+Vec4 :: type [vector 4]f32;
 
-Mat2 :: type [2]Vec2
-Mat3 :: type [3]Vec3
-Mat4 :: type [4]Vec4
+Mat2 :: type [2]Vec2;
+Mat3 :: type [3]Vec3;
+Mat4 :: type [4]Vec4;
 
 
 sqrt32  :: proc(x: f32) -> f32 #foreign "llvm.sqrt.f32"
@@ -35,107 +35,104 @@ sin64   :: proc(x: f64) -> f64 #foreign "llvm.sin.f64"
 cos32   :: proc(x: f32) -> f32 #foreign "llvm.cos.f32"
 cos64   :: proc(x: f64) -> f64 #foreign "llvm.cos.f64"
 
-tan32   :: proc(x: f32) -> f32 #inline { return sin32(x)/cos32(x) }
-tan64   :: proc(x: f64) -> f64 #inline { return sin64(x)/cos64(x) }
+tan32   :: proc(x: f32) -> f32 #inline { return sin32(x)/cos32(x); }
+tan64   :: proc(x: f64) -> f64 #inline { return sin64(x)/cos64(x); }
 
-lerp32  :: proc(a, b, t: f32) -> f32 { return a*(1-t) + b*t }
-lerp64  :: proc(a, b, t: f64) -> f64 { return a*(1-t) + b*t }
+lerp32  :: proc(a, b, t: f32) -> f32 { return a*(1-t) + b*t; }
+lerp64  :: proc(a, b, t: f64) -> f64 { return a*(1-t) + b*t; }
 
-clamp32 :: proc(x, lower, upper: f32) -> f32 { return min(max(x, lower), upper) }
-clamp64 :: proc(x, lower, upper: f64) -> f64 { return min(max(x, lower), upper) }
-
-sign32  :: proc(x: f32) -> f32 { if x >= 0 { return +1 } return -1 }
-sign64  :: proc(x: f64) -> f64 { if x >= 0 { return +1 } return -1 }
+sign32  :: proc(x: f32) -> f32 { if x >= 0 { return +1; } return -1; }
+sign64  :: proc(x: f64) -> f64 { if x >= 0 { return +1; } return -1; }
 
 
 
 copy_sign32 :: proc(x, y: f32) -> f32 {
-	ix := x transmute u32
-	iy := y transmute u32
-	ix &= 0x7fffffff
-	ix |= iy & 0x80000000
-	return ix transmute f32
+	ix := x transmute u32;
+	iy := y transmute u32;
+	ix &= 0x7fffffff;
+	ix |= iy & 0x80000000;
+	return ix transmute f32;
 }
 round32 :: proc(x: f32) -> f32 {
 	if x >= 0 {
-		return floor32(x + 0.5)
+		return floor32(x + 0.5);
 	}
-	return ceil32(x - 0.5)
+	return ceil32(x - 0.5);
 }
 floor32 :: proc(x: f32) -> f32 {
 	if x >= 0 {
-		return x as int as f32
+		return x as int as f32;
 	}
-	return (x-0.5) as int as f32
+	return (x-0.5) as int as f32;
 }
 ceil32 :: proc(x: f32) -> f32 {
 	if x < 0 {
-		return x as int as f32
+		return x as int as f32;
 	}
-	return ((x as int)+1) as f32
+	return ((x as int)+1) as f32;
 }
 
 remainder32 :: proc(x, y: f32) -> f32 {
-	return x - round32(x/y) * y
+	return x - round32(x/y) * y;
 }
 
 fmod32 :: proc(x, y: f32) -> f32 {
-	y = abs(y)
-	result := remainder32(abs(x), y)
+	y = abs(y);
+	result := remainder32(abs(x), y);
 	if sign32(result) < 0 {
-		result += y
+		result += y;
 	}
-	return copy_sign32(result, x)
+	return copy_sign32(result, x);
 }
 
 
-to_radians :: proc(degrees: f32) -> f32 { return degrees * TAU / 360 }
-to_degrees :: proc(radians: f32) -> f32 { return radians * 360 / TAU }
+to_radians :: proc(degrees: f32) -> f32 { return degrees * TAU / 360; }
+to_degrees :: proc(radians: f32) -> f32 { return radians * 360 / TAU; }
 
 
 
 
-dot2 :: proc(a, b: Vec2) -> f32 { c := a*b; return c.x + c.y }
-dot3 :: proc(a, b: Vec3) -> f32 { c := a*b; return c.x + c.y + c.z }
-dot4 :: proc(a, b: Vec4) -> f32 { c := a*b; return c.x + c.y + c.z + c.w }
+dot2 :: proc(a, b: Vec2) -> f32 { c := a*b; return c.x + c.y; }
+dot3 :: proc(a, b: Vec3) -> f32 { c := a*b; return c.x + c.y + c.z; }
+dot4 :: proc(a, b: Vec4) -> f32 { c := a*b; return c.x + c.y + c.z + c.w; }
 
 cross3 :: proc(x, y: Vec3) -> Vec3 {
-	a := swizzle(x, 1, 2, 0) * swizzle(y, 2, 0, 1)
-	b := swizzle(x, 2, 0, 1) * swizzle(y, 1, 2, 0)
-	return a - b
+	a := swizzle(x, 1, 2, 0) * swizzle(y, 2, 0, 1);
+	b := swizzle(x, 2, 0, 1) * swizzle(y, 1, 2, 0);
+	return a - b;
 }
 
 
-vec2_mag :: proc(v: Vec2) -> f32 { return sqrt32(dot2(v, v)) }
-vec3_mag :: proc(v: Vec3) -> f32 { return sqrt32(dot3(v, v)) }
-vec4_mag :: proc(v: Vec4) -> f32 { return sqrt32(dot4(v, v)) }
+vec2_mag :: proc(v: Vec2) -> f32 { return sqrt32(dot2(v, v)); }
+vec3_mag :: proc(v: Vec3) -> f32 { return sqrt32(dot3(v, v)); }
+vec4_mag :: proc(v: Vec4) -> f32 { return sqrt32(dot4(v, v)); }
 
-vec2_norm :: proc(v: Vec2) -> Vec2 { return v / Vec2{vec2_mag(v)} }
-vec3_norm :: proc(v: Vec3) -> Vec3 { return v / Vec3{vec3_mag(v)} }
-vec4_norm :: proc(v: Vec4) -> Vec4 { return v / Vec4{vec4_mag(v)} }
+vec2_norm :: proc(v: Vec2) -> Vec2 { return v / Vec2{vec2_mag(v)}; }
+vec3_norm :: proc(v: Vec3) -> Vec3 { return v / Vec3{vec3_mag(v)}; }
+vec4_norm :: proc(v: Vec4) -> Vec4 { return v / Vec4{vec4_mag(v)}; }
 
 vec2_norm0 :: proc(v: Vec2) -> Vec2 {
-	m := vec2_mag(v)
+	m := vec2_mag(v);
 	if m == 0 {
-		return Vec2{0}
+		return Vec2{0};
 	}
-	return v / Vec2{m}
+	return v / Vec2{m};
 }
 
 vec3_norm0 :: proc(v: Vec3) -> Vec3 {
-	m := vec3_mag(v)
+	m := vec3_mag(v);
 	if m == 0 {
-		return Vec3{0}
+		return Vec3{0};
 	}
-	return v / Vec3{m}
+	return v / Vec3{m};
 }
 
 vec4_norm0 :: proc(v: Vec4) -> Vec4 {
-	m := vec4_mag(v)
+	m := vec4_mag(v);
 	if m == 0 {
-		return Vec4{0}
+		return Vec4{0};
 	}
-	return v / Vec4{m}
+	return v / Vec4{m};
 }
 
 
@@ -146,29 +143,29 @@ mat4_identity :: proc() -> Mat4 {
 		{0, 1, 0, 0},
 		{0, 0, 1, 0},
 		{0, 0, 0, 1},
-	}
+	};
 }
 
 mat4_transpose :: proc(m: Mat4) -> Mat4 {
 	for j := 0; j < 4; j++ {
 		for i := 0; i < 4; i++ {
-			m[i][j], m[j][i] = m[j][i], m[i][j]
+			m[i][j], m[j][i] = m[j][i], m[i][j];
 		}
 	}
-	return m
+	return m;
 }
 
 mat4_mul :: proc(a, b: Mat4) -> Mat4 {
-	c: Mat4
+	c: Mat4;
 	for j := 0; j < 4; j++ {
 		for i := 0; i < 4; i++ {
 			c[j][i] = a[0][i]*b[j][0]
 			        + a[1][i]*b[j][1]
 			        + a[2][i]*b[j][2]
-			        + a[3][i]*b[j][3]
+			        + a[3][i]*b[j][3];
 		}
 	}
-	return c
+	return c;
 }
 
 mat4_mul_vec4 :: proc(m: Mat4, v: Vec4) -> Vec4 {
@@ -177,197 +174,197 @@ mat4_mul_vec4 :: proc(m: Mat4, v: Vec4) -> Vec4 {
 		m[0][1]*v.x + m[1][1]*v.y + m[2][1]*v.z + m[3][1]*v.w,
 		m[0][2]*v.x + m[1][2]*v.y + m[2][2]*v.z + m[3][2]*v.w,
 		m[0][3]*v.x + m[1][3]*v.y + m[2][3]*v.z + m[3][3]*v.w,
-	}
+	};
 }
 
 mat4_inverse :: proc(m: Mat4) -> Mat4 {
-	o: Mat4
-
-	sf00 := m[2][2] * m[3][3] - m[3][2] * m[2][3]
-	sf01 := m[2][1] * m[3][3] - m[3][1] * m[2][3]
-	sf02 := m[2][1] * m[3][2] - m[3][1] * m[2][2]
-	sf03 := m[2][0] * m[3][3] - m[3][0] * m[2][3]
-	sf04 := m[2][0] * m[3][2] - m[3][0] * m[2][2]
-	sf05 := m[2][0] * m[3][1] - m[3][0] * m[2][1]
-	sf06 := m[1][2] * m[3][3] - m[3][2] * m[1][3]
-	sf07 := m[1][1] * m[3][3] - m[3][1] * m[1][3]
-	sf08 := m[1][1] * m[3][2] - m[3][1] * m[1][2]
-	sf09 := m[1][0] * m[3][3] - m[3][0] * m[1][3]
-	sf10 := m[1][0] * m[3][2] - m[3][0] * m[1][2]
-	sf11 := m[1][1] * m[3][3] - m[3][1] * m[1][3]
-	sf12 := m[1][0] * m[3][1] - m[3][0] * m[1][1]
-	sf13 := m[1][2] * m[2][3] - m[2][2] * m[1][3]
-	sf14 := m[1][1] * m[2][3] - m[2][1] * m[1][3]
-	sf15 := m[1][1] * m[2][2] - m[2][1] * m[1][2]
-	sf16 := m[1][0] * m[2][3] - m[2][0] * m[1][3]
-	sf17 := m[1][0] * m[2][2] - m[2][0] * m[1][2]
-	sf18 := m[1][0] * m[2][1] - m[2][0] * m[1][1]
-
-	o[0][0] = +(m[1][1] * sf00 - m[1][2] * sf01 + m[1][3] * sf02)
-	o[0][1] = -(m[1][0] * sf00 - m[1][2] * sf03 + m[1][3] * sf04)
-	o[0][2] = +(m[1][0] * sf01 - m[1][1] * sf03 + m[1][3] * sf05)
-	o[0][3] = -(m[1][0] * sf02 - m[1][1] * sf04 + m[1][2] * sf05)
-
-	o[1][0] = -(m[0][1] * sf00 - m[0][2] * sf01 + m[0][3] * sf02)
-	o[1][1] = +(m[0][0] * sf00 - m[0][2] * sf03 + m[0][3] * sf04)
-	o[1][2] = -(m[0][0] * sf01 - m[0][1] * sf03 + m[0][3] * sf05)
-	o[1][3] = +(m[0][0] * sf02 - m[0][1] * sf04 + m[0][2] * sf05)
-
-	o[2][0] = +(m[0][1] * sf06 - m[0][2] * sf07 + m[0][3] * sf08)
-	o[2][1] = -(m[0][0] * sf06 - m[0][2] * sf09 + m[0][3] * sf10)
-	o[2][2] = +(m[0][0] * sf11 - m[0][1] * sf09 + m[0][3] * sf12)
-	o[2][3] = -(m[0][0] * sf08 - m[0][1] * sf10 + m[0][2] * sf12)
-
-	o[3][0] = -(m[0][1] * sf13 - m[0][2] * sf14 + m[0][3] * sf15)
-	o[3][1] = +(m[0][0] * sf13 - m[0][2] * sf16 + m[0][3] * sf17)
-	o[3][2] = -(m[0][0] * sf14 - m[0][1] * sf16 + m[0][3] * sf18)
-	o[3][3] = +(m[0][0] * sf15 - m[0][1] * sf17 + m[0][2] * sf18)
+	o: Mat4;
+
+	sf00 := m[2][2] * m[3][3] - m[3][2] * m[2][3];
+	sf01 := m[2][1] * m[3][3] - m[3][1] * m[2][3];
+	sf02 := m[2][1] * m[3][2] - m[3][1] * m[2][2];
+	sf03 := m[2][0] * m[3][3] - m[3][0] * m[2][3];
+	sf04 := m[2][0] * m[3][2] - m[3][0] * m[2][2];
+	sf05 := m[2][0] * m[3][1] - m[3][0] * m[2][1];
+	sf06 := m[1][2] * m[3][3] - m[3][2] * m[1][3];
+	sf07 := m[1][1] * m[3][3] - m[3][1] * m[1][3];
+	sf08 := m[1][1] * m[3][2] - m[3][1] * m[1][2];
+	sf09 := m[1][0] * m[3][3] - m[3][0] * m[1][3];
+	sf10 := m[1][0] * m[3][2] - m[3][0] * m[1][2];
+	sf11 := m[1][1] * m[3][3] - m[3][1] * m[1][3];
+	sf12 := m[1][0] * m[3][1] - m[3][0] * m[1][1];
+	sf13 := m[1][2] * m[2][3] - m[2][2] * m[1][3];
+	sf14 := m[1][1] * m[2][3] - m[2][1] * m[1][3];
+	sf15 := m[1][1] * m[2][2] - m[2][1] * m[1][2];
+	sf16 := m[1][0] * m[2][3] - m[2][0] * m[1][3];
+	sf17 := m[1][0] * m[2][2] - m[2][0] * m[1][2];
+	sf18 := m[1][0] * m[2][1] - m[2][0] * m[1][1];
+
+	o[0][0] = +(m[1][1] * sf00 - m[1][2] * sf01 + m[1][3] * sf02);
+	o[0][1] = -(m[1][0] * sf00 - m[1][2] * sf03 + m[1][3] * sf04);
+	o[0][2] = +(m[1][0] * sf01 - m[1][1] * sf03 + m[1][3] * sf05);
+	o[0][3] = -(m[1][0] * sf02 - m[1][1] * sf04 + m[1][2] * sf05);
+
+	o[1][0] = -(m[0][1] * sf00 - m[0][2] * sf01 + m[0][3] * sf02);
+	o[1][1] = +(m[0][0] * sf00 - m[0][2] * sf03 + m[0][3] * sf04);
+	o[1][2] = -(m[0][0] * sf01 - m[0][1] * sf03 + m[0][3] * sf05);
+	o[1][3] = +(m[0][0] * sf02 - m[0][1] * sf04 + m[0][2] * sf05);
+
+	o[2][0] = +(m[0][1] * sf06 - m[0][2] * sf07 + m[0][3] * sf08);
+	o[2][1] = -(m[0][0] * sf06 - m[0][2] * sf09 + m[0][3] * sf10);
+	o[2][2] = +(m[0][0] * sf11 - m[0][1] * sf09 + m[0][3] * sf12);
+	o[2][3] = -(m[0][0] * sf08 - m[0][1] * sf10 + m[0][2] * sf12);
+
+	o[3][0] = -(m[0][1] * sf13 - m[0][2] * sf14 + m[0][3] * sf15);
+	o[3][1] = +(m[0][0] * sf13 - m[0][2] * sf16 + m[0][3] * sf17);
+	o[3][2] = -(m[0][0] * sf14 - m[0][1] * sf16 + m[0][3] * sf18);
+	o[3][3] = +(m[0][0] * sf15 - m[0][1] * sf17 + m[0][2] * sf18);
 
 	ood := 1.0 / (m[0][0] * o[0][0] +
 	              m[0][1] * o[0][1] +
 	              m[0][2] * o[0][2] +
-	              m[0][3] * o[0][3])
-
-	o[0][0] *= ood
-	o[0][1] *= ood
-	o[0][2] *= ood
-	o[0][3] *= ood
-	o[1][0] *= ood
-	o[1][1] *= ood
-	o[1][2] *= ood
-	o[1][3] *= ood
-	o[2][0] *= ood
-	o[2][1] *= ood
-	o[2][2] *= ood
-	o[2][3] *= ood
-	o[3][0] *= ood
-	o[3][1] *= ood
-	o[3][2] *= ood
-	o[3][3] *= ood
-
-	return o
+	              m[0][3] * o[0][3]);
+
+	o[0][0] *= ood;
+	o[0][1] *= ood;
+	o[0][2] *= ood;
+	o[0][3] *= ood;
+	o[1][0] *= ood;
+	o[1][1] *= ood;
+	o[1][2] *= ood;
+	o[1][3] *= ood;
+	o[2][0] *= ood;
+	o[2][1] *= ood;
+	o[2][2] *= ood;
+	o[2][3] *= ood;
+	o[3][0] *= ood;
+	o[3][1] *= ood;
+	o[3][2] *= ood;
+	o[3][3] *= ood;
+
+	return o;
 }
 
 
 mat4_translate :: proc(v: Vec3) -> Mat4 {
-	m := mat4_identity()
-	m[3][0] = v.x
-	m[3][1] = v.y
-	m[3][2] = v.z
-	m[3][3] = 1
-	return m
+	m := mat4_identity();
+	m[3][0] = v.x;
+	m[3][1] = v.y;
+	m[3][2] = v.z;
+	m[3][3] = 1;
+	return m;
 }
 
 mat4_rotate :: proc(v: Vec3, angle_radians: f32) -> Mat4 {
-	c := cos32(angle_radians)
-	s := sin32(angle_radians)
+	c := cos32(angle_radians);
+	s := sin32(angle_radians);
 
-	a := vec3_norm(v)
-	t := a * Vec3{1-c}
+	a := vec3_norm(v);
+	t := a * Vec3{1-c};
 
-	rot := mat4_identity()
+	rot := mat4_identity();
 
-	rot[0][0] = c + t.x*a.x
-	rot[0][1] = 0 + t.x*a.y + s*a.z
-	rot[0][2] = 0 + t.x*a.z - s*a.y
-	rot[0][3] = 0
+	rot[0][0] = c + t.x*a.x;
+	rot[0][1] = 0 + t.x*a.y + s*a.z;
+	rot[0][2] = 0 + t.x*a.z - s*a.y;
+	rot[0][3] = 0;
 
-	rot[1][0] = 0 + t.y*a.x - s*a.z
-	rot[1][1] = c + t.y*a.y
-	rot[1][2] = 0 + t.y*a.z + s*a.x
-	rot[1][3] = 0
+	rot[1][0] = 0 + t.y*a.x - s*a.z;
+	rot[1][1] = c + t.y*a.y;
+	rot[1][2] = 0 + t.y*a.z + s*a.x;
+	rot[1][3] = 0;
 
-	rot[2][0] = 0 + t.z*a.x + s*a.y
-	rot[2][1] = 0 + t.z*a.y - s*a.x
-	rot[2][2] = c + t.z*a.z
-	rot[2][3] = 0
+	rot[2][0] = 0 + t.z*a.x + s*a.y;
+	rot[2][1] = 0 + t.z*a.y - s*a.x;
+	rot[2][2] = c + t.z*a.z;
+	rot[2][3] = 0;
 
-	return rot
+	return rot;
 }
 
 mat4_scale :: proc(m: Mat4, v: Vec3) -> Mat4 {
-	m[0][0] = v.x
-	m[1][1] = v.y
-	m[2][2] = v.z
-	return m
+	m[0][0] = v.x;
+	m[1][1] = v.y;
+	m[2][2] = v.z;
+	return m;
 }
 
 mat4_scalef :: proc(m: Mat4, s: f32) -> Mat4 {
-	m[0][0] = s
-	m[1][1] = s
-	m[2][2] = s
-	return m
+	m[0][0] = s;
+	m[1][1] = s;
+	m[2][2] = s;
+	return m;
 }
 
 
 mat4_look_at :: proc(eye, centre, up: Vec3) -> Mat4 {
-	f := vec3_norm(centre - eye)
-	s := vec3_norm(cross3(f, up))
-	u := cross3(s, f)
+	f := vec3_norm(centre - eye);
+	s := vec3_norm(cross3(f, up));
+	u := cross3(s, f);
 
-	m: Mat4
+	m: Mat4;
 
-	m[0] = Vec4{+s.x, +s.y, +s.z, 0}
-	m[1] = Vec4{+u.x, +u.y, +u.z, 0}
-	m[2] = Vec4{-f.x, -f.y, -f.z, 0}
-	m[3] = Vec4{dot3(s, eye), dot3(u, eye), dot3(f, eye), 1}
+	m[0] = Vec4{+s.x, +s.y, +s.z, 0};
+	m[1] = Vec4{+u.x, +u.y, +u.z, 0};
+	m[2] = Vec4{-f.x, -f.y, -f.z, 0};
+	m[3] = Vec4{dot3(s, eye), dot3(u, eye), dot3(f, eye), 1};
 
-	return m
+	return m;
 }
 mat4_perspective :: proc(fovy, aspect, near, far: f32) -> Mat4 {
-	m: Mat4
-	tan_half_fovy := tan32(0.5 * fovy)
-	m[0][0] = 1.0 / (aspect*tan_half_fovy)
-	m[1][1] = 1.0 / (tan_half_fovy)
-	m[2][2] = -(far + near) / (far - near)
-	m[2][3] = -1.0
-	m[3][2] = -2.0*far*near / (far - near)
-	return m
+	m: Mat4;
+	tan_half_fovy := tan32(0.5 * fovy);
+	m[0][0] = 1.0 / (aspect*tan_half_fovy);
+	m[1][1] = 1.0 / (tan_half_fovy);
+	m[2][2] = -(far + near) / (far - near);
+	m[2][3] = -1.0;
+	m[3][2] = -2.0*far*near / (far - near);
+	return m;
 }
 
 
 mat4_ortho3d :: proc(left, right, bottom, top, near, far: f32) -> Mat4 {
-	m := mat4_identity()
+	m := mat4_identity();
 
-	m[0][0] = +2.0 / (right - left)
-	m[1][1] = +2.0 / (top - bottom)
-	m[2][2] = -2.0 / (far - near)
-	m[3][0] = -(right + left)   / (right - left)
-	m[3][1] = -(top   + bottom) / (top   - bottom)
-	m[3][2] = -(far + near) / (far - near)
+	m[0][0] = +2.0 / (right - left);
+	m[1][1] = +2.0 / (top - bottom);
+	m[2][2] = -2.0 / (far - near);
+	m[3][0] = -(right + left)   / (right - left);
+	m[3][1] = -(top   + bottom) / (top   - bottom);
+	m[3][2] = -(far + near) / (far - near);
 
-	return m
+	return m;
 }
 
 
 
 
 
-F32_DIG        :: 6
-F32_EPSILON    :: 1.192092896e-07
-F32_GUARD      :: 0
-F32_MANT_DIG   :: 24
-F32_MAX        :: 3.402823466e+38
-F32_MAX_10_EXP :: 38
-F32_MAX_EXP    :: 128
-F32_MIN        :: 1.175494351e-38
-F32_MIN_10_EXP :: -37
-F32_MIN_EXP    :: -125
-F32_NORMALIZE  :: 0
-F32_RADIX      :: 2
-F32_ROUNDS     :: 1
-
-F64_DIG        :: 15                      // # of decimal digits of precision
-F64_EPSILON    :: 2.2204460492503131e-016 // smallest such that 1.0+F64_EPSILON != 1.0
-F64_MANT_DIG   :: 53                      // # of bits in mantissa
-F64_MAX        :: 1.7976931348623158e+308 // max value
-F64_MAX_10_EXP :: 308                     // max decimal exponent
-F64_MAX_EXP    :: 1024                    // max binary exponent
-F64_MIN        :: 2.2250738585072014e-308 // min positive value
-F64_MIN_10_EXP :: -307                    // min decimal exponent
-F64_MIN_EXP    :: -1021                   // min binary exponent
-F64_RADIX      :: 2                       // exponent radix
-F64_ROUNDS     :: 1                       // addition rounding: near
+F32_DIG        :: 6;
+F32_EPSILON    :: 1.192092896e-07;
+F32_GUARD      :: 0;
+F32_MANT_DIG   :: 24;
+F32_MAX        :: 3.402823466e+38;
+F32_MAX_10_EXP :: 38;
+F32_MAX_EXP    :: 128;
+F32_MIN        :: 1.175494351e-38;
+F32_MIN_10_EXP :: -37;
+F32_MIN_EXP    :: -125;
+F32_NORMALIZE  :: 0;
+F32_RADIX      :: 2;
+F32_ROUNDS     :: 1;
+
+F64_DIG        :: 15;                       // # of decimal digits of precision
+F64_EPSILON    :: 2.2204460492503131e-016;  // smallest such that 1.0+F64_EPSILON != 1.0
+F64_MANT_DIG   :: 53;                       // # of bits in mantissa
+F64_MAX        :: 1.7976931348623158e+308;  // max value
+F64_MAX_10_EXP :: 308;                      // max decimal exponent
+F64_MAX_EXP    :: 1024;                     // max binary exponent
+F64_MIN        :: 2.2250738585072014e-308;  // min positive value
+F64_MIN_10_EXP :: -307;                     // min decimal exponent
+F64_MIN_EXP    :: -1021;                    // min binary exponent
+F64_RADIX      :: 2;                        // exponent radix
+F64_ROUNDS     :: 1;                        // addition rounding: near
 
 
 

+ 127 - 127
core/mem.odin

@@ -1,51 +1,51 @@
-#import "fmt.odin"
-#import "os.odin"
+#import "fmt.odin";
+#import "os.odin";
 
 set :: proc(data: rawptr, value: i32, len: int) -> rawptr #link_name "__mem_set" {
 	llvm_memset_64bit :: proc(dst: rawptr, val: byte, len: int, align: i32, is_volatile: bool) #foreign "llvm.memset.p0i8.i64"
-	llvm_memset_64bit(data, value as byte, len, 1, false)
-	return data
+	llvm_memset_64bit(data, value as byte, len, 1, false);
+	return data;
 }
 
 zero :: proc(data: rawptr, len: int) -> rawptr {
-	return set(data, 0, len)
+	return set(data, 0, len);
 }
 
 copy :: proc(dst, src: rawptr, len: int) -> rawptr #link_name "__mem_copy" {
 	// NOTE(bill): This _must_ implemented like C's memmove
 	llvm_memmove_64bit :: proc(dst, src: rawptr, len: int, align: i32, is_volatile: bool) #foreign "llvm.memmove.p0i8.p0i8.i64"
-	llvm_memmove_64bit(dst, src, len, 1, false)
-	return dst
+	llvm_memmove_64bit(dst, src, len, 1, false);
+	return dst;
 }
 
 copy_non_overlapping :: proc(dst, src: rawptr, len: int) -> rawptr #link_name "__mem_copy_non_overlapping" {
 	// NOTE(bill): This _must_ implemented like C's memcpy
 	llvm_memcpy_64bit :: proc(dst, src: rawptr, len: int, align: i32, is_volatile: bool) #foreign "llvm.memcpy.p0i8.p0i8.i64"
-	llvm_memcpy_64bit(dst, src, len, 1, false)
-	return dst
+	llvm_memcpy_64bit(dst, src, len, 1, false);
+	return dst;
 }
 
 
 compare :: proc(dst, src: rawptr, n: int) -> int #link_name "__mem_compare" {
 	// Translation of http://mgronhol.github.io/fast-strcmp/
-	a := slice_ptr(dst as ^byte, n)
-	b := slice_ptr(src as ^byte, n)
+	a := slice_ptr(dst as ^byte, n);
+	b := slice_ptr(src as ^byte, n);
 
-	fast := n/size_of(int) + 1
-	offset := (fast-1)*size_of(int)
-	curr_block := 0
+	fast := n/size_of(int) + 1;
+	offset := (fast-1)*size_of(int);
+	curr_block := 0;
 	if n <= size_of(int) {
-		fast = 0
+		fast = 0;
 	}
 
-	la := slice_ptr(^a[0] as ^int, fast)
-	lb := slice_ptr(^b[0] as ^int, fast)
+	la := slice_ptr(^a[0] as ^int, fast);
+	lb := slice_ptr(^b[0] as ^int, fast);
 
 	for ; curr_block < fast; curr_block++ {
 		if (la[curr_block] ~ lb[curr_block]) != 0 {
 			for pos := curr_block*size_of(int); pos < n; pos++ {
 				if (a[pos] ~ b[pos]) != 0 {
-					return a[pos] as int - b[pos] as int
+					return a[pos] as int - b[pos] as int;
 				}
 			}
 		}
@@ -54,58 +54,58 @@ compare :: proc(dst, src: rawptr, n: int) -> int #link_name "__mem_compare" {
 
 	for ; offset < n; offset++ {
 		if (a[offset] ~ b[offset]) != 0 {
-			return a[offset] as int - b[offset] as int
+			return a[offset] as int - b[offset] as int;
 		}
 	}
 
-	return 0
+	return 0;
 }
 
 
 
-kilobytes :: proc(x: int) -> int #inline { return          (x) * 1024 }
-megabytes :: proc(x: int) -> int #inline { return kilobytes(x) * 1024 }
-gigabytes :: proc(x: int) -> int #inline { return gigabytes(x) * 1024 }
-terabytes :: proc(x: int) -> int #inline { return terabytes(x) * 1024 }
+kilobytes :: proc(x: int) -> int #inline { return          (x) * 1024; }
+megabytes :: proc(x: int) -> int #inline { return kilobytes(x) * 1024; }
+gigabytes :: proc(x: int) -> int #inline { return gigabytes(x) * 1024; }
+terabytes :: proc(x: int) -> int #inline { return terabytes(x) * 1024; }
 
 is_power_of_two :: proc(x: int) -> bool {
 	if x <= 0 {
-		return false
+		return false;
 	}
-	return (x & (x-1)) == 0
+	return (x & (x-1)) == 0;
 }
 
 align_forward :: proc(ptr: rawptr, align: int) -> rawptr {
-	assert(is_power_of_two(align))
+	assert(is_power_of_two(align));
 
-	a := align as uint
-	p := ptr as uint
-	modulo := p & (a-1)
+	a := align as uint;
+	p := ptr as uint;
+	modulo := p & (a-1);
 	if modulo != 0 {
-		p += a - modulo
+		p += a - modulo;
 	}
-	return p as rawptr
+	return p as rawptr;
 }
 
 
 
 AllocationHeader :: struct {
-	size: int
+	size: int;
 }
 allocation_header_fill :: proc(header: ^AllocationHeader, data: rawptr, size: int) {
-	header.size = size
-	ptr := (header+1) as ^int
+	header.size = size;
+	ptr := (header+1) as ^int;
 
 	for i := 0; ptr as rawptr < data; i++ {
-		(ptr+i)^ = -1
+		(ptr+i)^ = -1;
 	}
 }
 allocation_header :: proc(data: rawptr) -> ^AllocationHeader {
-	p := data as ^int
+	p := data as ^int;
 	for (p-1)^ == -1 {
-		p = (p-1)
+		p = (p-1);
 	}
-	return (p as ^AllocationHeader)-1
+	return (p as ^AllocationHeader)-1;
 }
 
 
@@ -115,13 +115,13 @@ allocation_header :: proc(data: rawptr) -> ^AllocationHeader {
 // Custom allocators
 
 Arena :: struct {
-	backing:    Allocator
-	memory:     []byte
-	temp_count: int
+	backing:    Allocator;
+	memory:     []byte;
+	temp_count: int;
 
 	Temp_Memory :: struct {
-		arena:          ^Arena
-		original_count: int
+		arena:          ^Arena;
+		original_count: int;
 	}
 }
 
@@ -130,22 +130,22 @@ Arena :: struct {
 
 
 init_arena_from_memory :: proc(using a: ^Arena, data: []byte) {
-	backing    = Allocator{}
-	memory     = data[:0]
-	temp_count = 0
+	backing    = Allocator{};
+	memory     = data[:0];
+	temp_count = 0;
 }
 
 init_arena_from_context :: proc(using a: ^Arena, size: int) {
-	backing = context.allocator
-	memory = new_slice(byte, 0, size)
-	temp_count = 0
+	backing = context.allocator;
+	memory = new_slice(byte, 0, size);
+	temp_count = 0;
 }
 
 free_arena :: proc(using a: ^Arena) {
 	if backing.procedure != nil {
 		push_allocator backing {
-			free(memory.data)
-			memory = memory[0:0:0]
+			free(memory.data);
+			memory = memory[0:0:0];
 		}
 	}
 }
@@ -154,57 +154,57 @@ arena_allocator :: proc(arena: ^Arena) -> Allocator {
 	return Allocator{
 		procedure = arena_allocator_proc,
 		data = arena,
-	}
+	};
 }
 
 arena_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator.Mode,
                              size, alignment: int,
                              old_memory: rawptr, old_size: int, flags: u64) -> rawptr {
-	arena := allocator_data as ^Arena
+	arena := allocator_data as ^Arena;
 
-	using Allocator.Mode
+	using Allocator.Mode;
 	match mode {
 	case ALLOC:
-		total_size := size + alignment
+		total_size := size + alignment;
 
 		if arena.memory.count + total_size > arena.memory.capacity {
-			fmt.fprintln(os.stderr, "Arena out of memory")
-			return nil
+			fmt.fprintln(os.stderr, "Arena out of memory");
+			return nil;
 		}
 
-		#no_bounds_check end := ^arena.memory[arena.memory.count]
+		#no_bounds_check end := ^arena.memory[arena.memory.count];
 
-		ptr := align_forward(end, alignment)
-		arena.memory.count += total_size
-		return zero(ptr, size)
+		ptr := align_forward(end, alignment);
+		arena.memory.count += total_size;
+		return zero(ptr, size);
 
 	case FREE:
 		// NOTE(bill): Free all at once
 		// Use Arena.Temp_Memory if you want to free a block
 
 	case FREE_ALL:
-		arena.memory.count = 0
+		arena.memory.count = 0;
 
 	case RESIZE:
-		return default_resize_align(old_memory, old_size, size, alignment)
+		return default_resize_align(old_memory, old_size, size, alignment);
 	}
 
-	return nil
+	return nil;
 }
 
 begin_arena_temp_memory :: proc(a: ^Arena) -> Arena.Temp_Memory {
-	tmp: Arena.Temp_Memory
-	tmp.arena = a
-	tmp.original_count = a.memory.count
-	a.temp_count++
-	return tmp
+	tmp: Arena.Temp_Memory;
+	tmp.arena = a;
+	tmp.original_count = a.memory.count;
+	a.temp_count++;
+	return tmp;
 }
 
 end_arena_temp_memory :: proc(using tmp: Arena.Temp_Memory) {
-	assert(arena.memory.count >= original_count)
-	assert(arena.temp_count > 0)
-	arena.memory.count = original_count
-	arena.temp_count--
+	assert(arena.memory.count >= original_count);
+	assert(arena.temp_count > 0);
+	arena.memory.count = original_count;
+	arena.temp_count--;
 }
 
 
@@ -214,119 +214,119 @@ end_arena_temp_memory :: proc(using tmp: Arena.Temp_Memory) {
 
 
 align_of_type_info :: proc(type_info: ^Type_Info) -> int {
-	WORD_SIZE :: size_of(int)
-	using Type_Info
+	WORD_SIZE :: size_of(int);
+	using Type_Info;
 
 	match type info : type_info {
 	case Named:
-		return align_of_type_info(info.base)
+		return align_of_type_info(info.base);
 	case Integer:
-		return info.size
+		return info.size;
 	case Float:
-		return info.size
+		return info.size;
 	case String:
-		return WORD_SIZE
+		return WORD_SIZE;
 	case Boolean:
-		return 1
+		return 1;
 	case Pointer:
-		return WORD_SIZE
+		return WORD_SIZE;
 	case Maybe:
-		return max(align_of_type_info(info.elem), 1)
+		return max(align_of_type_info(info.elem), 1);
 	case Procedure:
-		return WORD_SIZE
+		return WORD_SIZE;
 	case Array:
-		return align_of_type_info(info.elem)
+		return align_of_type_info(info.elem);
 	case Slice:
-		return WORD_SIZE
+		return WORD_SIZE;
 	case Vector:
-		return align_of_type_info(info.elem)
+		return align_of_type_info(info.elem);
 	case Struct:
-		return info.align
+		return info.align;
 	case Union:
-		return info.align
+		return info.align;
 	case Raw_Union:
-		return info.align
+		return info.align;
 	case Enum:
-		return align_of_type_info(info.base)
+		return align_of_type_info(info.base);
 	}
 
-	return 0
+	return 0;
 }
 
 align_formula :: proc(size, align: int) -> int {
-	result := size + align-1
-	return result - result%align
+	result := size + align-1;
+	return result - result%align;
 }
 
 size_of_type_info :: proc(type_info: ^Type_Info) -> int {
-	WORD_SIZE :: size_of(int)
-	using Type_Info
+	WORD_SIZE :: size_of(int);
+	using Type_Info;
 
 	match type info : type_info {
 	case Named:
-		return size_of_type_info(info.base)
+		return size_of_type_info(info.base);
 	case Integer:
-		return info.size
+		return info.size;
 	case Float:
-		return info.size
+		return info.size;
 	case Any:
-		return 2*WORD_SIZE
+		return 2*WORD_SIZE;
 	case String:
-		return 2*WORD_SIZE
+		return 2*WORD_SIZE;
 	case Boolean:
-		return 1
+		return 1;
 	case Pointer:
-		return WORD_SIZE
+		return WORD_SIZE;
 	case Maybe:
-		return size_of_type_info(info.elem) + 1
+		return size_of_type_info(info.elem) + 1;
 	case Procedure:
-		return WORD_SIZE
+		return WORD_SIZE;
 	case Array:
-		count := info.count
+		count := info.count;
 		if count == 0 {
-			return 0
+			return 0;
 		}
-		size      := size_of_type_info(info.elem)
-		align     := align_of_type_info(info.elem)
-		alignment := align_formula(size, align)
-		return alignment*(count-1) + size
+		size      := size_of_type_info(info.elem);
+		align     := align_of_type_info(info.elem);
+		alignment := align_formula(size, align);
+		return alignment*(count-1) + size;
 	case Slice:
-		return 3*WORD_SIZE
+		return 3*WORD_SIZE;
 	case Vector:
 		is_bool :: proc(type_info: ^Type_Info) -> bool {
 			match type info : type_info {
 			case Named:
-				return is_bool(info.base)
+				return is_bool(info.base);
 			case Boolean:
-				return true
+				return true;
 			}
-			return false
+			return false;
 		}
 
-		count := info.count
+		count := info.count;
 		if count == 0 {
-			return 0
+			return 0;
 		}
-		bit_size := 8*size_of_type_info(info.elem)
+		bit_size := 8*size_of_type_info(info.elem);
 		if is_bool(info.elem) {
 			// NOTE(bill): LLVM can store booleans as 1 bit because a boolean _is_ an `i1`
 			// Silly LLVM spec
-			bit_size = 1
+			bit_size = 1;
 		}
-		total_size_in_bits := bit_size * count
-		total_size := (total_size_in_bits+7)/8
-		return total_size
+		total_size_in_bits := bit_size * count;
+		total_size := (total_size_in_bits+7)/8;
+		return total_size;
 
 	case Struct:
-		return info.size
+		return info.size;
 	case Union:
-		return info.size
+		return info.size;
 	case Raw_Union:
-		return info.size
+		return info.size;
 	case Enum:
-		return size_of_type_info(info.base)
+		return size_of_type_info(info.base);
 	}
 
-	return 0
+	return 0;
 }
 

+ 114 - 116
core/opengl.odin

@@ -1,8 +1,6 @@
-when ODIN_OS == "windows" {
-	#foreign_system_library "opengl32"
-}
-#import "win32.odin"
-#load "opengl_constants.odin"
+#foreign_system_library "opengl32" when ODIN_OS == "windows";
+#import "win32.odin" when ODIN_OS == "windows";
+#include "opengl_constants.odin";
 
 Clear          :: proc(mask: u32)                                #foreign "glClear"
 ClearColor     :: proc(r, g, b, a: f32)                          #foreign "glClearColor"
@@ -32,126 +30,126 @@ GetIntegerv :: proc(name: i32, v: ^i32) #foreign "glGetIntegerv"
 
 
 
-_libgl := win32.LoadLibraryA(("opengl32.dll\x00" as string).data)
+_libgl := win32.LoadLibraryA(("opengl32.dll\x00" as string).data);
 
 GetProcAddress :: proc(name: string) -> proc() {
-	assert(name[name.count-1] == 0)
-	res := win32.wglGetProcAddress(name.data)
+	assert(name[name.count-1] == 0);
+	res := win32.wglGetProcAddress(name.data);
 	if res == nil {
 		res = win32.GetProcAddress(_libgl, name.data);
 	}
-	return res
+	return res;
 }
 
 
-GenBuffers:      proc(count: i32, buffers: ^u32)
-GenVertexArrays: proc(count: i32, buffers: ^u32)
-GenSamplers:     proc(count: i32, buffers: ^u32)
-BindBuffer:      proc(target: i32, buffer: u32)
-BindVertexArray: proc(buffer: u32)
-BindSampler:     proc(position: i32, sampler: u32)
-BufferData:      proc(target: i32, size: int, data: rawptr, usage: i32)
-BufferSubData:   proc(target: i32, offset, size: int, data: rawptr)
-
-DrawArrays:      proc(mode, first: i32, count: u32)
-DrawElements:    proc(mode: i32, count: u32, type_: i32, indices: rawptr)
-
-MapBuffer:       proc(target, access: i32) -> rawptr
-UnmapBuffer:     proc(target: i32)
-
-VertexAttribPointer: proc(index: u32, size, type_: i32, normalized: i32, stride: u32, pointer: rawptr)
-EnableVertexAttribArray: proc(index: u32)
-
-CreateShader:  proc(shader_type: i32) -> u32
-ShaderSource:  proc(shader: u32, count: u32, string: ^^byte, length: ^i32)
-CompileShader: proc(shader: u32)
-CreateProgram: proc() -> u32
-AttachShader:  proc(program, shader: u32)
-DetachShader:  proc(program, shader: u32)
-DeleteShader:  proc(shader: u32)
-LinkProgram:   proc(program: u32)
-UseProgram:    proc(program: u32)
-DeleteProgram: proc(program: u32)
-
-
-GetShaderiv:       proc(shader:  u32, pname: i32, params: ^i32)
-GetProgramiv:      proc(program: u32, pname: i32, params: ^i32)
-GetShaderInfoLog:  proc(shader:  u32, max_length: u32, length: ^u32, info_long: ^byte)
-GetProgramInfoLog: proc(program: u32, max_length: u32, length: ^u32, info_long: ^byte)
-
-ActiveTexture:  proc(texture: i32)
-GenerateMipmap: proc(target: i32)
-
-SamplerParameteri:    proc(sampler: u32, pname: i32, param: i32)
-SamplerParameterf:    proc(sampler: u32, pname: i32, param: f32)
-SamplerParameteriv:   proc(sampler: u32, pname: i32, params: ^i32)
-SamplerParameterfv:   proc(sampler: u32, pname: i32, params: ^f32)
-SamplerParameterIiv:  proc(sampler: u32, pname: i32, params: ^i32)
-SamplerParameterIuiv: proc(sampler: u32, pname: i32, params: ^u32)
-
-
-Uniform1i:        proc(loc: i32, v0: i32)
-Uniform2i:        proc(loc: i32, v0, v1: i32)
-Uniform3i:        proc(loc: i32, v0, v1, v2: i32)
-Uniform4i:        proc(loc: i32, v0, v1, v2, v3: i32)
-Uniform1f:        proc(loc: i32, v0: f32)
-Uniform2f:        proc(loc: i32, v0, v1: f32)
-Uniform3f:        proc(loc: i32, v0, v1, v2: f32)
-Uniform4f:        proc(loc: i32, v0, v1, v2, v3: f32)
-UniformMatrix4fv: proc(loc: i32, count: u32, transpose: i32, value: ^f32)
-
-GetUniformLocation: proc(program: u32, name: ^byte) -> i32
+GenBuffers:      proc(count: i32, buffers: ^u32);
+GenVertexArrays: proc(count: i32, buffers: ^u32);
+GenSamplers:     proc(count: i32, buffers: ^u32);
+BindBuffer:      proc(target: i32, buffer: u32);
+BindVertexArray: proc(buffer: u32);
+BindSampler:     proc(position: i32, sampler: u32);
+BufferData:      proc(target: i32, size: int, data: rawptr, usage: i32);
+BufferSubData:   proc(target: i32, offset, size: int, data: rawptr);
+
+DrawArrays:      proc(mode, first: i32, count: u32);
+DrawElements:    proc(mode: i32, count: u32, type_: i32, indices: rawptr);
+
+MapBuffer:       proc(target, access: i32) -> rawptr;
+UnmapBuffer:     proc(target: i32);
+
+VertexAttribPointer: proc(index: u32, size, type_: i32, normalized: i32, stride: u32, pointer: rawptr);
+EnableVertexAttribArray: proc(index: u32);
+
+CreateShader:  proc(shader_type: i32) -> u32;
+ShaderSource:  proc(shader: u32, count: u32, string: ^^byte, length: ^i32);
+CompileShader: proc(shader: u32);
+CreateProgram: proc() -> u32;
+AttachShader:  proc(program, shader: u32);
+DetachShader:  proc(program, shader: u32);
+DeleteShader:  proc(shader: u32);
+LinkProgram:   proc(program: u32);
+UseProgram:    proc(program: u32);
+DeleteProgram: proc(program: u32);
+
+
+GetShaderiv:       proc(shader:  u32, pname: i32, params: ^i32);
+GetProgramiv:      proc(program: u32, pname: i32, params: ^i32);
+GetShaderInfoLog:  proc(shader:  u32, max_length: u32, length: ^u32, info_long: ^byte);
+GetProgramInfoLog: proc(program: u32, max_length: u32, length: ^u32, info_long: ^byte);
+
+ActiveTexture:  proc(texture: i32);
+GenerateMipmap: proc(target: i32);
+
+SamplerParameteri:    proc(sampler: u32, pname: i32, param: i32);
+SamplerParameterf:    proc(sampler: u32, pname: i32, param: f32);
+SamplerParameteriv:   proc(sampler: u32, pname: i32, params: ^i32);
+SamplerParameterfv:   proc(sampler: u32, pname: i32, params: ^f32);
+SamplerParameterIiv:  proc(sampler: u32, pname: i32, params: ^i32);
+SamplerParameterIuiv: proc(sampler: u32, pname: i32, params: ^u32);
+
+
+Uniform1i:        proc(loc: i32, v0: i32);
+Uniform2i:        proc(loc: i32, v0, v1: i32);
+Uniform3i:        proc(loc: i32, v0, v1, v2: i32);
+Uniform4i:        proc(loc: i32, v0, v1, v2, v3: i32);
+Uniform1f:        proc(loc: i32, v0: f32);
+Uniform2f:        proc(loc: i32, v0, v1: f32);
+Uniform3f:        proc(loc: i32, v0, v1, v2: f32);
+Uniform4f:        proc(loc: i32, v0, v1, v2, v3: f32);
+UniformMatrix4fv: proc(loc: i32, count: u32, transpose: i32, value: ^f32);
+
+GetUniformLocation: proc(program: u32, name: ^byte) -> i32;
 
 init :: proc() {
-	set_proc_address :: proc(p: rawptr, name: string) #inline { (p as ^proc())^ = GetProcAddress(name) }
-
-	set_proc_address(^GenBuffers,      "glGenBuffers\x00")
-	set_proc_address(^GenVertexArrays, "glGenVertexArrays\x00")
-	set_proc_address(^GenSamplers,     "glGenSamplers\x00")
-	set_proc_address(^BindBuffer,      "glBindBuffer\x00")
-	set_proc_address(^BindSampler,     "glBindSampler\x00")
-	set_proc_address(^BindVertexArray, "glBindVertexArray\x00")
-	set_proc_address(^BufferData,      "glBufferData\x00")
-	set_proc_address(^BufferSubData,   "glBufferSubData\x00")
-
-	set_proc_address(^DrawArrays,      "glDrawArrays\x00")
-	set_proc_address(^DrawElements,    "glDrawElements\x00")
-
-	set_proc_address(^MapBuffer,   "glMapBuffer\x00")
-	set_proc_address(^UnmapBuffer, "glUnmapBuffer\x00")
-
-	set_proc_address(^VertexAttribPointer,     "glVertexAttribPointer\x00")
-	set_proc_address(^EnableVertexAttribArray, "glEnableVertexAttribArray\x00")
-
-	set_proc_address(^CreateShader,  "glCreateShader\x00")
-	set_proc_address(^ShaderSource,  "glShaderSource\x00")
-	set_proc_address(^CompileShader, "glCompileShader\x00")
-	set_proc_address(^CreateProgram, "glCreateProgram\x00")
-	set_proc_address(^AttachShader,  "glAttachShader\x00")
-	set_proc_address(^DetachShader,  "glDetachShader\x00")
-	set_proc_address(^DeleteShader,  "glDeleteShader\x00")
-	set_proc_address(^LinkProgram,   "glLinkProgram\x00")
-	set_proc_address(^UseProgram,    "glUseProgram\x00")
-	set_proc_address(^DeleteProgram, "glDeleteProgram\x00")
-
-	set_proc_address(^GetShaderiv,       "glGetShaderiv\x00")
-	set_proc_address(^GetProgramiv,      "glGetProgramiv\x00")
-	set_proc_address(^GetShaderInfoLog,  "glGetShaderInfoLog\x00")
-	set_proc_address(^GetProgramInfoLog, "glGetProgramInfoLog\x00")
-
-	set_proc_address(^ActiveTexture,  "glActiveTexture\x00")
-	set_proc_address(^GenerateMipmap, "glGenerateMipmap\x00")
-
-	set_proc_address(^Uniform1i,        "glUniform1i\x00")
-	set_proc_address(^UniformMatrix4fv, "glUniformMatrix4fv\x00")
-
-	set_proc_address(^GetUniformLocation, "glGetUniformLocation\x00")
-
-	set_proc_address(^SamplerParameteri,    "glSamplerParameteri\x00")
-	set_proc_address(^SamplerParameterf,    "glSamplerParameterf\x00")
-	set_proc_address(^SamplerParameteriv,   "glSamplerParameteriv\x00")
-	set_proc_address(^SamplerParameterfv,   "glSamplerParameterfv\x00")
-	set_proc_address(^SamplerParameterIiv,  "glSamplerParameterIiv\x00")
-	set_proc_address(^SamplerParameterIuiv, "glSamplerParameterIuiv\x00")
+	set_proc_address :: proc(p: rawptr, name: string) #inline { (p as ^proc())^ = GetProcAddress(name); }
+
+	set_proc_address(^GenBuffers,      "glGenBuffers\x00");
+	set_proc_address(^GenVertexArrays, "glGenVertexArrays\x00");
+	set_proc_address(^GenSamplers,     "glGenSamplers\x00");
+	set_proc_address(^BindBuffer,      "glBindBuffer\x00");
+	set_proc_address(^BindSampler,     "glBindSampler\x00");
+	set_proc_address(^BindVertexArray, "glBindVertexArray\x00");
+	set_proc_address(^BufferData,      "glBufferData\x00");
+	set_proc_address(^BufferSubData,   "glBufferSubData\x00");
+
+	set_proc_address(^DrawArrays,      "glDrawArrays\x00");
+	set_proc_address(^DrawElements,    "glDrawElements\x00");
+
+	set_proc_address(^MapBuffer,   "glMapBuffer\x00");
+	set_proc_address(^UnmapBuffer, "glUnmapBuffer\x00");
+
+	set_proc_address(^VertexAttribPointer,     "glVertexAttribPointer\x00");
+	set_proc_address(^EnableVertexAttribArray, "glEnableVertexAttribArray\x00");
+
+	set_proc_address(^CreateShader,  "glCreateShader\x00");
+	set_proc_address(^ShaderSource,  "glShaderSource\x00");
+	set_proc_address(^CompileShader, "glCompileShader\x00");
+	set_proc_address(^CreateProgram, "glCreateProgram\x00");
+	set_proc_address(^AttachShader,  "glAttachShader\x00");
+	set_proc_address(^DetachShader,  "glDetachShader\x00");
+	set_proc_address(^DeleteShader,  "glDeleteShader\x00");
+	set_proc_address(^LinkProgram,   "glLinkProgram\x00");
+	set_proc_address(^UseProgram,    "glUseProgram\x00");
+	set_proc_address(^DeleteProgram, "glDeleteProgram\x00");
+
+	set_proc_address(^GetShaderiv,       "glGetShaderiv\x00");
+	set_proc_address(^GetProgramiv,      "glGetProgramiv\x00");
+	set_proc_address(^GetShaderInfoLog,  "glGetShaderInfoLog\x00");
+	set_proc_address(^GetProgramInfoLog, "glGetProgramInfoLog\x00");
+
+	set_proc_address(^ActiveTexture,  "glActiveTexture\x00");
+	set_proc_address(^GenerateMipmap, "glGenerateMipmap\x00");
+
+	set_proc_address(^Uniform1i,        "glUniform1i\x00");
+	set_proc_address(^UniformMatrix4fv, "glUniformMatrix4fv\x00");
+
+	set_proc_address(^GetUniformLocation, "glGetUniformLocation\x00");
+
+	set_proc_address(^SamplerParameteri,    "glSamplerParameteri\x00");
+	set_proc_address(^SamplerParameterf,    "glSamplerParameterf\x00");
+	set_proc_address(^SamplerParameteriv,   "glSamplerParameteriv\x00");
+	set_proc_address(^SamplerParameterfv,   "glSamplerParameterfv\x00");
+	set_proc_address(^SamplerParameterIiv,  "glSamplerParameterIiv\x00");
+	set_proc_address(^SamplerParameterIuiv, "glSamplerParameterIuiv\x00");
 }
 

+ 1365 - 1365
core/opengl_constants.odin

@@ -1,1384 +1,1384 @@
-FALSE                          :: 0
-TRUE                           :: 1
+FALSE                          :: 0;
+TRUE                           :: 1;
 
-DEPTH_BUFFER_BIT               :: 0x00000100
-STENCIL_BUFFER_BIT             :: 0x00000400
-COLOR_BUFFER_BIT               :: 0x00004000
-POINTS                         :: 0x0000
-LINES                          :: 0x0001
-LINE_LOOP                      :: 0x0002
-LINE_STRIP                     :: 0x0003
-TRIANGLES                      :: 0x0004
-TRIANGLE_STRIP                 :: 0x0005
-TRIANGLE_FAN                   :: 0x0006
-QUADS                          :: 0x0007
-NEVER                          :: 0x0200
-LESS                           :: 0x0201
-EQUAL                          :: 0x0202
-LEQUAL                         :: 0x0203
-GREATER                        :: 0x0204
-NOTEQUAL                       :: 0x0205
-GEQUAL                         :: 0x0206
-ALWAYS                         :: 0x0207
-ZERO                           :: 0
-ONE                            :: 1
-SRC_COLOR                      :: 0x0300
-ONE_MINUS_SRC_COLOR            :: 0x0301
-SRC_ALPHA                      :: 0x0302
-ONE_MINUS_SRC_ALPHA            :: 0x0303
-DST_ALPHA                      :: 0x0304
-ONE_MINUS_DST_ALPHA            :: 0x0305
-DST_COLOR                      :: 0x0306
-ONE_MINUS_DST_COLOR            :: 0x0307
-SRC_ALPHA_SATURATE             :: 0x0308
-NONE                           :: 0
-FRONT_LEFT                     :: 0x0400
-FRONT_RIGHT                    :: 0x0401
-BACK_LEFT                      :: 0x0402
-BACK_RIGHT                     :: 0x0403
-FRONT                          :: 0x0404
-BACK                           :: 0x0405
-LEFT                           :: 0x0406
-RIGHT                          :: 0x0407
-FRONT_AND_BACK                 :: 0x0408
-NO_ERROR                       :: 0
-INVALID_ENUM                   :: 0x0500
-INVALID_VALUE                  :: 0x0501
-INVALID_OPERATION              :: 0x0502
-OUT_OF_MEMORY                  :: 0x0505
-CW                             :: 0x0900
-CCW                            :: 0x0901
-POINT_SIZE                     :: 0x0B11
-POINT_SIZE_RANGE               :: 0x0B12
-POINT_SIZE_GRANULARITY         :: 0x0B13
-LINE_SMOOTH                    :: 0x0B20
-LINE_WIDTH                     :: 0x0B21
-LINE_WIDTH_RANGE               :: 0x0B22
-LINE_WIDTH_GRANULARITY         :: 0x0B23
-POLYGON_MODE                   :: 0x0B40
-POLYGON_SMOOTH                 :: 0x0B41
-CULL_FACE                      :: 0x0B44
-CULL_FACE_MODE                 :: 0x0B45
-FRONT_FACE                     :: 0x0B46
-DEPTH_RANGE                    :: 0x0B70
-DEPTH_TEST                     :: 0x0B71
-DEPTH_WRITEMASK                :: 0x0B72
-DEPTH_CLEAR_VALUE              :: 0x0B73
-DEPTH_FUNC                     :: 0x0B74
-STENCIL_TEST                   :: 0x0B90
-STENCIL_CLEAR_VALUE            :: 0x0B91
-STENCIL_FUNC                   :: 0x0B92
-STENCIL_VALUE_MASK             :: 0x0B93
-STENCIL_FAIL                   :: 0x0B94
-STENCIL_PASS_DEPTH_FAIL        :: 0x0B95
-STENCIL_PASS_DEPTH_PASS        :: 0x0B96
-STENCIL_REF                    :: 0x0B97
-STENCIL_WRITEMASK              :: 0x0B98
-VIEWPORT                       :: 0x0BA2
-DITHER                         :: 0x0BD0
-BLEND_DST                      :: 0x0BE0
-BLEND_SRC                      :: 0x0BE1
-BLEND                          :: 0x0BE2
-LOGIC_OP_MODE                  :: 0x0BF0
-COLOR_LOGIC_OP                 :: 0x0BF2
-DRAW_BUFFER                    :: 0x0C01
-READ_BUFFER                    :: 0x0C02
-SCISSOR_BOX                    :: 0x0C10
-SCISSOR_TEST                   :: 0x0C11
-COLOR_CLEAR_VALUE              :: 0x0C22
-COLOR_WRITEMASK                :: 0x0C23
-DOUBLEBUFFER                   :: 0x0C32
-STEREO                         :: 0x0C33
-LINE_SMOOTH_HINT               :: 0x0C52
-POLYGON_SMOOTH_HINT            :: 0x0C53
-UNPACK_SWAP_BYTES              :: 0x0CF0
-UNPACK_LSB_FIRST               :: 0x0CF1
-UNPACK_ROW_LENGTH              :: 0x0CF2
-UNPACK_SKIP_ROWS               :: 0x0CF3
-UNPACK_SKIP_PIXELS             :: 0x0CF4
-UNPACK_ALIGNMENT               :: 0x0CF5
-PACK_SWAP_BYTES                :: 0x0D00
-PACK_LSB_FIRST                 :: 0x0D01
-PACK_ROW_LENGTH                :: 0x0D02
-PACK_SKIP_ROWS                 :: 0x0D03
-PACK_SKIP_PIXELS               :: 0x0D04
-PACK_ALIGNMENT                 :: 0x0D05
-MAX_TEXTURE_SIZE               :: 0x0D33
-MAX_VIEWPORT_DIMS              :: 0x0D3A
-SUBPIXEL_BITS                  :: 0x0D50
-TEXTURE_1D                     :: 0x0DE0
-TEXTURE_2D                     :: 0x0DE1
-POLYGON_OFFSET_UNITS           :: 0x2A00
-POLYGON_OFFSET_POINT           :: 0x2A01
-POLYGON_OFFSET_LINE            :: 0x2A02
-POLYGON_OFFSET_FILL            :: 0x8037
-POLYGON_OFFSET_FACTOR          :: 0x8038
-TEXTURE_BINDING_1D             :: 0x8068
-TEXTURE_BINDING_2D             :: 0x8069
-TEXTURE_WIDTH                  :: 0x1000
-TEXTURE_HEIGHT                 :: 0x1001
-TEXTURE_INTERNAL_FORMAT        :: 0x1003
-TEXTURE_BORDER_COLOR           :: 0x1004
-TEXTURE_RED_SIZE               :: 0x805C
-TEXTURE_GREEN_SIZE             :: 0x805D
-TEXTURE_BLUE_SIZE              :: 0x805E
-TEXTURE_ALPHA_SIZE             :: 0x805F
-DONT_CARE                      :: 0x1100
-FASTEST                        :: 0x1101
-NICEST                         :: 0x1102
-BYTE                           :: 0x1400
-UNSIGNED_BYTE                  :: 0x1401
-SHORT                          :: 0x1402
-UNSIGNED_SHORT                 :: 0x1403
-INT                            :: 0x1404
-UNSIGNED_INT                   :: 0x1405
-FLOAT                          :: 0x1406
-DOUBLE                         :: 0x140A
-STACK_OVERFLOW                 :: 0x0503
-STACK_UNDERFLOW                :: 0x0504
-CLEAR                          :: 0x1500
-AND                            :: 0x1501
-AND_REVERSE                    :: 0x1502
-COPY                           :: 0x1503
-AND_INVERTED                   :: 0x1504
-NOOP                           :: 0x1505
-XOR                            :: 0x1506
-OR                             :: 0x1507
-NOR                            :: 0x1508
-EQUIV                          :: 0x1509
-INVERT                         :: 0x150A
-OR_REVERSE                     :: 0x150B
-COPY_INVERTED                  :: 0x150C
-OR_INVERTED                    :: 0x150D
-NAND                           :: 0x150E
-SET                            :: 0x150F
-TEXTURE                        :: 0x1702
-COLOR                          :: 0x1800
-DEPTH                          :: 0x1801
-STENCIL                        :: 0x1802
-STENCIL_INDEX                  :: 0x1901
-DEPTH_COMPONENT                :: 0x1902
-RED                            :: 0x1903
-GREEN                          :: 0x1904
-BLUE                           :: 0x1905
-ALPHA                          :: 0x1906
-RGB                            :: 0x1907
-RGBA                           :: 0x1908
-POINT                          :: 0x1B00
-LINE                           :: 0x1B01
-FILL                           :: 0x1B02
-KEEP                           :: 0x1E00
-REPLACE                        :: 0x1E01
-INCR                           :: 0x1E02
-DECR                           :: 0x1E03
-VENDOR                         :: 0x1F00
-RENDERER                       :: 0x1F01
-VERSION                        :: 0x1F02
-EXTENSIONS                     :: 0x1F03
-NEAREST                        :: 0x2600
-LINEAR                         :: 0x2601
-NEAREST_MIPMAP_NEAREST         :: 0x2700
-LINEAR_MIPMAP_NEAREST          :: 0x2701
-NEAREST_MIPMAP_LINEAR          :: 0x2702
-LINEAR_MIPMAP_LINEAR           :: 0x2703
-TEXTURE_MAG_FILTER             :: 0x2800
-TEXTURE_MIN_FILTER             :: 0x2801
-TEXTURE_WRAP_S                 :: 0x2802
-TEXTURE_WRAP_T                 :: 0x2803
-PROXY_TEXTURE_1D               :: 0x8063
-PROXY_TEXTURE_2D               :: 0x8064
-REPEAT                         :: 0x2901
-R3_G3_B2                       :: 0x2A10
-RGB4                           :: 0x804F
-RGB5                           :: 0x8050
-RGB8                           :: 0x8051
-RGB10                          :: 0x8052
-RGB12                          :: 0x8053
-RGB16                          :: 0x8054
-RGBA2                          :: 0x8055
-RGBA4                          :: 0x8056
-RGB5_A1                        :: 0x8057
-RGBA8                          :: 0x8058
-RGB10_A2                       :: 0x8059
-RGBA12                         :: 0x805A
-RGBA16                         :: 0x805B
-VERTEX_ARRAY                   :: 0x8074
+DEPTH_BUFFER_BIT               :: 0x00000100;
+STENCIL_BUFFER_BIT             :: 0x00000400;
+COLOR_BUFFER_BIT               :: 0x00004000;
+POINTS                         :: 0x0000;
+LINES                          :: 0x0001;
+LINE_LOOP                      :: 0x0002;
+LINE_STRIP                     :: 0x0003;
+TRIANGLES                      :: 0x0004;
+TRIANGLE_STRIP                 :: 0x0005;
+TRIANGLE_FAN                   :: 0x0006;
+QUADS                          :: 0x0007;
+NEVER                          :: 0x0200;
+LESS                           :: 0x0201;
+EQUAL                          :: 0x0202;
+LEQUAL                         :: 0x0203;
+GREATER                        :: 0x0204;
+NOTEQUAL                       :: 0x0205;
+GEQUAL                         :: 0x0206;
+ALWAYS                         :: 0x0207;
+ZERO                           :: 0;
+ONE                            :: 1;
+SRC_COLOR                      :: 0x0300;
+ONE_MINUS_SRC_COLOR            :: 0x0301;
+SRC_ALPHA                      :: 0x0302;
+ONE_MINUS_SRC_ALPHA            :: 0x0303;
+DST_ALPHA                      :: 0x0304;
+ONE_MINUS_DST_ALPHA            :: 0x0305;
+DST_COLOR                      :: 0x0306;
+ONE_MINUS_DST_COLOR            :: 0x0307;
+SRC_ALPHA_SATURATE             :: 0x0308;
+NONE                           :: 0;
+FRONT_LEFT                     :: 0x0400;
+FRONT_RIGHT                    :: 0x0401;
+BACK_LEFT                      :: 0x0402;
+BACK_RIGHT                     :: 0x0403;
+FRONT                          :: 0x0404;
+BACK                           :: 0x0405;
+LEFT                           :: 0x0406;
+RIGHT                          :: 0x0407;
+FRONT_AND_BACK                 :: 0x0408;
+NO_ERROR                       :: 0;
+INVALID_ENUM                   :: 0x0500;
+INVALID_VALUE                  :: 0x0501;
+INVALID_OPERATION              :: 0x0502;
+OUT_OF_MEMORY                  :: 0x0505;
+CW                             :: 0x0900;
+CCW                            :: 0x0901;
+POINT_SIZE                     :: 0x0B11;
+POINT_SIZE_RANGE               :: 0x0B12;
+POINT_SIZE_GRANULARITY         :: 0x0B13;
+LINE_SMOOTH                    :: 0x0B20;
+LINE_WIDTH                     :: 0x0B21;
+LINE_WIDTH_RANGE               :: 0x0B22;
+LINE_WIDTH_GRANULARITY         :: 0x0B23;
+POLYGON_MODE                   :: 0x0B40;
+POLYGON_SMOOTH                 :: 0x0B41;
+CULL_FACE                      :: 0x0B44;
+CULL_FACE_MODE                 :: 0x0B45;
+FRONT_FACE                     :: 0x0B46;
+DEPTH_RANGE                    :: 0x0B70;
+DEPTH_TEST                     :: 0x0B71;
+DEPTH_WRITEMASK                :: 0x0B72;
+DEPTH_CLEAR_VALUE              :: 0x0B73;
+DEPTH_FUNC                     :: 0x0B74;
+STENCIL_TEST                   :: 0x0B90;
+STENCIL_CLEAR_VALUE            :: 0x0B91;
+STENCIL_FUNC                   :: 0x0B92;
+STENCIL_VALUE_MASK             :: 0x0B93;
+STENCIL_FAIL                   :: 0x0B94;
+STENCIL_PASS_DEPTH_FAIL        :: 0x0B95;
+STENCIL_PASS_DEPTH_PASS        :: 0x0B96;
+STENCIL_REF                    :: 0x0B97;
+STENCIL_WRITEMASK              :: 0x0B98;
+VIEWPORT                       :: 0x0BA2;
+DITHER                         :: 0x0BD0;
+BLEND_DST                      :: 0x0BE0;
+BLEND_SRC                      :: 0x0BE1;
+BLEND                          :: 0x0BE2;
+LOGIC_OP_MODE                  :: 0x0BF0;
+COLOR_LOGIC_OP                 :: 0x0BF2;
+DRAW_BUFFER                    :: 0x0C01;
+READ_BUFFER                    :: 0x0C02;
+SCISSOR_BOX                    :: 0x0C10;
+SCISSOR_TEST                   :: 0x0C11;
+COLOR_CLEAR_VALUE              :: 0x0C22;
+COLOR_WRITEMASK                :: 0x0C23;
+DOUBLEBUFFER                   :: 0x0C32;
+STEREO                         :: 0x0C33;
+LINE_SMOOTH_HINT               :: 0x0C52;
+POLYGON_SMOOTH_HINT            :: 0x0C53;
+UNPACK_SWAP_BYTES              :: 0x0CF0;
+UNPACK_LSB_FIRST               :: 0x0CF1;
+UNPACK_ROW_LENGTH              :: 0x0CF2;
+UNPACK_SKIP_ROWS               :: 0x0CF3;
+UNPACK_SKIP_PIXELS             :: 0x0CF4;
+UNPACK_ALIGNMENT               :: 0x0CF5;
+PACK_SWAP_BYTES                :: 0x0D00;
+PACK_LSB_FIRST                 :: 0x0D01;
+PACK_ROW_LENGTH                :: 0x0D02;
+PACK_SKIP_ROWS                 :: 0x0D03;
+PACK_SKIP_PIXELS               :: 0x0D04;
+PACK_ALIGNMENT                 :: 0x0D05;
+MAX_TEXTURE_SIZE               :: 0x0D33;
+MAX_VIEWPORT_DIMS              :: 0x0D3A;
+SUBPIXEL_BITS                  :: 0x0D50;
+TEXTURE_1D                     :: 0x0DE0;
+TEXTURE_2D                     :: 0x0DE1;
+POLYGON_OFFSET_UNITS           :: 0x2A00;
+POLYGON_OFFSET_POINT           :: 0x2A01;
+POLYGON_OFFSET_LINE            :: 0x2A02;
+POLYGON_OFFSET_FILL            :: 0x8037;
+POLYGON_OFFSET_FACTOR          :: 0x8038;
+TEXTURE_BINDING_1D             :: 0x8068;
+TEXTURE_BINDING_2D             :: 0x8069;
+TEXTURE_WIDTH                  :: 0x1000;
+TEXTURE_HEIGHT                 :: 0x1001;
+TEXTURE_INTERNAL_FORMAT        :: 0x1003;
+TEXTURE_BORDER_COLOR           :: 0x1004;
+TEXTURE_RED_SIZE               :: 0x805C;
+TEXTURE_GREEN_SIZE             :: 0x805D;
+TEXTURE_BLUE_SIZE              :: 0x805E;
+TEXTURE_ALPHA_SIZE             :: 0x805F;
+DONT_CARE                      :: 0x1100;
+FASTEST                        :: 0x1101;
+NICEST                         :: 0x1102;
+BYTE                           :: 0x1400;
+UNSIGNED_BYTE                  :: 0x1401;
+SHORT                          :: 0x1402;
+UNSIGNED_SHORT                 :: 0x1403;
+INT                            :: 0x1404;
+UNSIGNED_INT                   :: 0x1405;
+FLOAT                          :: 0x1406;
+DOUBLE                         :: 0x140A;
+STACK_OVERFLOW                 :: 0x0503;
+STACK_UNDERFLOW                :: 0x0504;
+CLEAR                          :: 0x1500;
+AND                            :: 0x1501;
+AND_REVERSE                    :: 0x1502;
+COPY                           :: 0x1503;
+AND_INVERTED                   :: 0x1504;
+NOOP                           :: 0x1505;
+XOR                            :: 0x1506;
+OR                             :: 0x1507;
+NOR                            :: 0x1508;
+EQUIV                          :: 0x1509;
+INVERT                         :: 0x150A;
+OR_REVERSE                     :: 0x150B;
+COPY_INVERTED                  :: 0x150C;
+OR_INVERTED                    :: 0x150D;
+NAND                           :: 0x150E;
+SET                            :: 0x150F;
+TEXTURE                        :: 0x1702;
+COLOR                          :: 0x1800;
+DEPTH                          :: 0x1801;
+STENCIL                        :: 0x1802;
+STENCIL_INDEX                  :: 0x1901;
+DEPTH_COMPONENT                :: 0x1902;
+RED                            :: 0x1903;
+GREEN                          :: 0x1904;
+BLUE                           :: 0x1905;
+ALPHA                          :: 0x1906;
+RGB                            :: 0x1907;
+RGBA                           :: 0x1908;
+POINT                          :: 0x1B00;
+LINE                           :: 0x1B01;
+FILL                           :: 0x1B02;
+KEEP                           :: 0x1E00;
+REPLACE                        :: 0x1E01;
+INCR                           :: 0x1E02;
+DECR                           :: 0x1E03;
+VENDOR                         :: 0x1F00;
+RENDERER                       :: 0x1F01;
+VERSION                        :: 0x1F02;
+EXTENSIONS                     :: 0x1F03;
+NEAREST                        :: 0x2600;
+LINEAR                         :: 0x2601;
+NEAREST_MIPMAP_NEAREST         :: 0x2700;
+LINEAR_MIPMAP_NEAREST          :: 0x2701;
+NEAREST_MIPMAP_LINEAR          :: 0x2702;
+LINEAR_MIPMAP_LINEAR           :: 0x2703;
+TEXTURE_MAG_FILTER             :: 0x2800;
+TEXTURE_MIN_FILTER             :: 0x2801;
+TEXTURE_WRAP_S                 :: 0x2802;
+TEXTURE_WRAP_T                 :: 0x2803;
+PROXY_TEXTURE_1D               :: 0x8063;
+PROXY_TEXTURE_2D               :: 0x8064;
+REPEAT                         :: 0x2901;
+R3_G3_B2                       :: 0x2A10;
+RGB4                           :: 0x804F;
+RGB5                           :: 0x8050;
+RGB8                           :: 0x8051;
+RGB10                          :: 0x8052;
+RGB12                          :: 0x8053;
+RGB16                          :: 0x8054;
+RGBA2                          :: 0x8055;
+RGBA4                          :: 0x8056;
+RGB5_A1                        :: 0x8057;
+RGBA8                          :: 0x8058;
+RGB10_A2                       :: 0x8059;
+RGBA12                         :: 0x805A;
+RGBA16                         :: 0x805B;
+VERTEX_ARRAY                   :: 0x8074;
 
-UNSIGNED_BYTE_3_3_2            :: 0x8032
-UNSIGNED_SHORT_4_4_4_4         :: 0x8033
-UNSIGNED_SHORT_5_5_5_1         :: 0x8034
-UNSIGNED_INT_8_8_8_8           :: 0x8035
-UNSIGNED_INT_10_10_10_2        :: 0x8036
-TEXTURE_BINDING_3D             :: 0x806A
-PACK_SKIP_IMAGES               :: 0x806B
-PACK_IMAGE_HEIGHT              :: 0x806C
-UNPACK_SKIP_IMAGES             :: 0x806D
-UNPACK_IMAGE_HEIGHT            :: 0x806E
-TEXTURE_3D                     :: 0x806F
-PROXY_TEXTURE_3D               :: 0x8070
-TEXTURE_DEPTH                  :: 0x8071
-TEXTURE_WRAP_R                 :: 0x8072
-MAX_3D_TEXTURE_SIZE            :: 0x8073
-UNSIGNED_BYTE_2_3_3_REV        :: 0x8362
-UNSIGNED_SHORT_5_6_5           :: 0x8363
-UNSIGNED_SHORT_5_6_5_REV       :: 0x8364
-UNSIGNED_SHORT_4_4_4_4_REV     :: 0x8365
-UNSIGNED_SHORT_1_5_5_5_REV     :: 0x8366
-UNSIGNED_INT_8_8_8_8_REV       :: 0x8367
-UNSIGNED_INT_2_10_10_10_REV    :: 0x8368
-BGR                            :: 0x80E0
-BGRA                           :: 0x80E1
-MAX_ELEMENTS_VERTICES          :: 0x80E8
-MAX_ELEMENTS_INDICES           :: 0x80E9
-CLAMP_TO_EDGE                  :: 0x812F
-TEXTURE_MIN_LOD                :: 0x813A
-TEXTURE_MAX_LOD                :: 0x813B
-TEXTURE_BASE_LEVEL             :: 0x813C
-TEXTURE_MAX_LEVEL              :: 0x813D
-SMOOTH_POINT_SIZE_RANGE        :: 0x0B12
-SMOOTH_POINT_SIZE_GRANULARITY  :: 0x0B13
-SMOOTH_LINE_WIDTH_RANGE        :: 0x0B22
-SMOOTH_LINE_WIDTH_GRANULARITY  :: 0x0B23
-ALIASED_LINE_WIDTH_RANGE       :: 0x846E
+UNSIGNED_BYTE_3_3_2            :: 0x8032;
+UNSIGNED_SHORT_4_4_4_4         :: 0x8033;
+UNSIGNED_SHORT_5_5_5_1         :: 0x8034;
+UNSIGNED_INT_8_8_8_8           :: 0x8035;
+UNSIGNED_INT_10_10_10_2        :: 0x8036;
+TEXTURE_BINDING_3D             :: 0x806A;
+PACK_SKIP_IMAGES               :: 0x806B;
+PACK_IMAGE_HEIGHT              :: 0x806C;
+UNPACK_SKIP_IMAGES             :: 0x806D;
+UNPACK_IMAGE_HEIGHT            :: 0x806E;
+TEXTURE_3D                     :: 0x806F;
+PROXY_TEXTURE_3D               :: 0x8070;
+TEXTURE_DEPTH                  :: 0x8071;
+TEXTURE_WRAP_R                 :: 0x8072;
+MAX_3D_TEXTURE_SIZE            :: 0x8073;
+UNSIGNED_BYTE_2_3_3_REV        :: 0x8362;
+UNSIGNED_SHORT_5_6_5           :: 0x8363;
+UNSIGNED_SHORT_5_6_5_REV       :: 0x8364;
+UNSIGNED_SHORT_4_4_4_4_REV     :: 0x8365;
+UNSIGNED_SHORT_1_5_5_5_REV     :: 0x8366;
+UNSIGNED_INT_8_8_8_8_REV       :: 0x8367;
+UNSIGNED_INT_2_10_10_10_REV    :: 0x8368;
+BGR                            :: 0x80E0;
+BGRA                           :: 0x80E1;
+MAX_ELEMENTS_VERTICES          :: 0x80E8;
+MAX_ELEMENTS_INDICES           :: 0x80E9;
+CLAMP_TO_EDGE                  :: 0x812F;
+TEXTURE_MIN_LOD                :: 0x813A;
+TEXTURE_MAX_LOD                :: 0x813B;
+TEXTURE_BASE_LEVEL             :: 0x813C;
+TEXTURE_MAX_LEVEL              :: 0x813D;
+SMOOTH_POINT_SIZE_RANGE        :: 0x0B12;
+SMOOTH_POINT_SIZE_GRANULARITY  :: 0x0B13;
+SMOOTH_LINE_WIDTH_RANGE        :: 0x0B22;
+SMOOTH_LINE_WIDTH_GRANULARITY  :: 0x0B23;
+ALIASED_LINE_WIDTH_RANGE       :: 0x846E;
 
-TEXTURE0                       :: 0x84C0
-TEXTURE1                       :: 0x84C1
-TEXTURE2                       :: 0x84C2
-TEXTURE3                       :: 0x84C3
-TEXTURE4                       :: 0x84C4
-TEXTURE5                       :: 0x84C5
-TEXTURE6                       :: 0x84C6
-TEXTURE7                       :: 0x84C7
-TEXTURE8                       :: 0x84C8
-TEXTURE9                       :: 0x84C9
-TEXTURE10                      :: 0x84CA
-TEXTURE11                      :: 0x84CB
-TEXTURE12                      :: 0x84CC
-TEXTURE13                      :: 0x84CD
-TEXTURE14                      :: 0x84CE
-TEXTURE15                      :: 0x84CF
-TEXTURE16                      :: 0x84D0
-TEXTURE17                      :: 0x84D1
-TEXTURE18                      :: 0x84D2
-TEXTURE19                      :: 0x84D3
-TEXTURE20                      :: 0x84D4
-TEXTURE21                      :: 0x84D5
-TEXTURE22                      :: 0x84D6
-TEXTURE23                      :: 0x84D7
-TEXTURE24                      :: 0x84D8
-TEXTURE25                      :: 0x84D9
-TEXTURE26                      :: 0x84DA
-TEXTURE27                      :: 0x84DB
-TEXTURE28                      :: 0x84DC
-TEXTURE29                      :: 0x84DD
-TEXTURE30                      :: 0x84DE
-TEXTURE31                      :: 0x84DF
-ACTIVE_TEXTURE                 :: 0x84E0
-MULTISAMPLE                    :: 0x809D
-SAMPLE_ALPHA_TO_COVERAGE       :: 0x809E
-SAMPLE_ALPHA_TO_ONE            :: 0x809F
-SAMPLE_COVERAGE                :: 0x80A0
-SAMPLE_BUFFERS                 :: 0x80A8
-SAMPLES                        :: 0x80A9
-SAMPLE_COVERAGE_VALUE          :: 0x80AA
-SAMPLE_COVERAGE_INVERT         :: 0x80AB
-TEXTURE_CUBE_MAP               :: 0x8513
-TEXTURE_BINDING_CUBE_MAP       :: 0x8514
-TEXTURE_CUBE_MAP_POSITIVE_X    :: 0x8515
-TEXTURE_CUBE_MAP_NEGATIVE_X    :: 0x8516
-TEXTURE_CUBE_MAP_POSITIVE_Y    :: 0x8517
-TEXTURE_CUBE_MAP_NEGATIVE_Y    :: 0x8518
-TEXTURE_CUBE_MAP_POSITIVE_Z    :: 0x8519
-TEXTURE_CUBE_MAP_NEGATIVE_Z    :: 0x851A
-PROXY_TEXTURE_CUBE_MAP         :: 0x851B
-MAX_CUBE_MAP_TEXTURE_SIZE      :: 0x851C
-COMPRESSED_RGB                 :: 0x84ED
-COMPRESSED_RGBA                :: 0x84EE
-TEXTURE_COMPRESSION_HINT       :: 0x84EF
-TEXTURE_COMPRESSED_IMAGE_SIZE  :: 0x86A0
-TEXTURE_COMPRESSED             :: 0x86A1
-NUM_COMPRESSED_TEXTURE_FORMATS :: 0x86A2
-COMPRESSED_TEXTURE_FORMATS     :: 0x86A3
-CLAMP_TO_BORDER                :: 0x812D
+TEXTURE0                       :: 0x84C0;
+TEXTURE1                       :: 0x84C1;
+TEXTURE2                       :: 0x84C2;
+TEXTURE3                       :: 0x84C3;
+TEXTURE4                       :: 0x84C4;
+TEXTURE5                       :: 0x84C5;
+TEXTURE6                       :: 0x84C6;
+TEXTURE7                       :: 0x84C7;
+TEXTURE8                       :: 0x84C8;
+TEXTURE9                       :: 0x84C9;
+TEXTURE10                      :: 0x84CA;
+TEXTURE11                      :: 0x84CB;
+TEXTURE12                      :: 0x84CC;
+TEXTURE13                      :: 0x84CD;
+TEXTURE14                      :: 0x84CE;
+TEXTURE15                      :: 0x84CF;
+TEXTURE16                      :: 0x84D0;
+TEXTURE17                      :: 0x84D1;
+TEXTURE18                      :: 0x84D2;
+TEXTURE19                      :: 0x84D3;
+TEXTURE20                      :: 0x84D4;
+TEXTURE21                      :: 0x84D5;
+TEXTURE22                      :: 0x84D6;
+TEXTURE23                      :: 0x84D7;
+TEXTURE24                      :: 0x84D8;
+TEXTURE25                      :: 0x84D9;
+TEXTURE26                      :: 0x84DA;
+TEXTURE27                      :: 0x84DB;
+TEXTURE28                      :: 0x84DC;
+TEXTURE29                      :: 0x84DD;
+TEXTURE30                      :: 0x84DE;
+TEXTURE31                      :: 0x84DF;
+ACTIVE_TEXTURE                 :: 0x84E0;
+MULTISAMPLE                    :: 0x809D;
+SAMPLE_ALPHA_TO_COVERAGE       :: 0x809E;
+SAMPLE_ALPHA_TO_ONE            :: 0x809F;
+SAMPLE_COVERAGE                :: 0x80A0;
+SAMPLE_BUFFERS                 :: 0x80A8;
+SAMPLES                        :: 0x80A9;
+SAMPLE_COVERAGE_VALUE          :: 0x80AA;
+SAMPLE_COVERAGE_INVERT         :: 0x80AB;
+TEXTURE_CUBE_MAP               :: 0x8513;
+TEXTURE_BINDING_CUBE_MAP       :: 0x8514;
+TEXTURE_CUBE_MAP_POSITIVE_X    :: 0x8515;
+TEXTURE_CUBE_MAP_NEGATIVE_X    :: 0x8516;
+TEXTURE_CUBE_MAP_POSITIVE_Y    :: 0x8517;
+TEXTURE_CUBE_MAP_NEGATIVE_Y    :: 0x8518;
+TEXTURE_CUBE_MAP_POSITIVE_Z    :: 0x8519;
+TEXTURE_CUBE_MAP_NEGATIVE_Z    :: 0x851A;
+PROXY_TEXTURE_CUBE_MAP         :: 0x851B;
+MAX_CUBE_MAP_TEXTURE_SIZE      :: 0x851C;
+COMPRESSED_RGB                 :: 0x84ED;
+COMPRESSED_RGBA                :: 0x84EE;
+TEXTURE_COMPRESSION_HINT       :: 0x84EF;
+TEXTURE_COMPRESSED_IMAGE_SIZE  :: 0x86A0;
+TEXTURE_COMPRESSED             :: 0x86A1;
+NUM_COMPRESSED_TEXTURE_FORMATS :: 0x86A2;
+COMPRESSED_TEXTURE_FORMATS     :: 0x86A3;
+CLAMP_TO_BORDER                :: 0x812D;
 
-BLEND_DST_RGB                  :: 0x80C8
-BLEND_SRC_RGB                  :: 0x80C9
-BLEND_DST_ALPHA                :: 0x80CA
-BLEND_SRC_ALPHA                :: 0x80CB
-POINT_FADE_THRESHOLD_SIZE      :: 0x8128
-DEPTH_COMPONENT16              :: 0x81A5
-DEPTH_COMPONENT24              :: 0x81A6
-DEPTH_COMPONENT32              :: 0x81A7
-MIRRORED_REPEAT                :: 0x8370
-MAX_TEXTURE_LOD_BIAS           :: 0x84FD
-TEXTURE_LOD_BIAS               :: 0x8501
-INCR_WRAP                      :: 0x8507
-DECR_WRAP                      :: 0x8508
-TEXTURE_DEPTH_SIZE             :: 0x884A
-TEXTURE_COMPARE_MODE           :: 0x884C
-TEXTURE_COMPARE_FUNC           :: 0x884D
-FUNC_ADD                       :: 0x8006
-FUNC_SUBTRACT                  :: 0x800A
-FUNC_REVERSE_SUBTRACT          :: 0x800B
-MIN                            :: 0x8007
-MAX                            :: 0x8008
-CONSTANT_COLOR                 :: 0x8001
-ONE_MINUS_CONSTANT_COLOR       :: 0x8002
-CONSTANT_ALPHA                 :: 0x8003
-ONE_MINUS_CONSTANT_ALPHA       :: 0x8004
+BLEND_DST_RGB                  :: 0x80C8;
+BLEND_SRC_RGB                  :: 0x80C9;
+BLEND_DST_ALPHA                :: 0x80CA;
+BLEND_SRC_ALPHA                :: 0x80CB;
+POINT_FADE_THRESHOLD_SIZE      :: 0x8128;
+DEPTH_COMPONENT16              :: 0x81A5;
+DEPTH_COMPONENT24              :: 0x81A6;
+DEPTH_COMPONENT32              :: 0x81A7;
+MIRRORED_REPEAT                :: 0x8370;
+MAX_TEXTURE_LOD_BIAS           :: 0x84FD;
+TEXTURE_LOD_BIAS               :: 0x8501;
+INCR_WRAP                      :: 0x8507;
+DECR_WRAP                      :: 0x8508;
+TEXTURE_DEPTH_SIZE             :: 0x884A;
+TEXTURE_COMPARE_MODE           :: 0x884C;
+TEXTURE_COMPARE_FUNC           :: 0x884D;
+FUNC_ADD                       :: 0x8006;
+FUNC_SUBTRACT                  :: 0x800A;
+FUNC_REVERSE_SUBTRACT          :: 0x800B;
+MIN                            :: 0x8007;
+MAX                            :: 0x8008;
+CONSTANT_COLOR                 :: 0x8001;
+ONE_MINUS_CONSTANT_COLOR       :: 0x8002;
+CONSTANT_ALPHA                 :: 0x8003;
+ONE_MINUS_CONSTANT_ALPHA       :: 0x8004;
 
-BUFFER_SIZE                    :: 0x8764
-BUFFER_USAGE                   :: 0x8765
-QUERY_COUNTER_BITS             :: 0x8864
-CURRENT_QUERY                  :: 0x8865
-QUERY_RESULT                   :: 0x8866
-QUERY_RESULT_AVAILABLE         :: 0x8867
-ARRAY_BUFFER                   :: 0x8892
-ELEMENT_ARRAY_BUFFER           :: 0x8893
-ARRAY_BUFFER_BINDING           :: 0x8894
-ELEMENT_ARRAY_BUFFER_BINDING   :: 0x8895
-VERTEX_ATTRIB_ARRAY_BUFFER_BINDING :: 0x889F
-READ_ONLY                      :: 0x88B8
-WRITE_ONLY                     :: 0x88B9
-READ_WRITE                     :: 0x88BA
-BUFFER_ACCESS                  :: 0x88BB
-BUFFER_MAPPED                  :: 0x88BC
-BUFFER_MAP_POINTER             :: 0x88BD
-STREAM_DRAW                    :: 0x88E0
-STREAM_READ                    :: 0x88E1
-STREAM_COPY                    :: 0x88E2
-STATIC_DRAW                    :: 0x88E4
-STATIC_READ                    :: 0x88E5
-STATIC_COPY                    :: 0x88E6
-DYNAMIC_DRAW                   :: 0x88E8
-DYNAMIC_READ                   :: 0x88E9
-DYNAMIC_COPY                   :: 0x88EA
-SAMPLES_PASSED                 :: 0x8914
-SRC1_ALPHA                     :: 0x8589
+BUFFER_SIZE                    :: 0x8764;
+BUFFER_USAGE                   :: 0x8765;
+QUERY_COUNTER_BITS             :: 0x8864;
+CURRENT_QUERY                  :: 0x8865;
+QUERY_RESULT                   :: 0x8866;
+QUERY_RESULT_AVAILABLE         :: 0x8867;
+ARRAY_BUFFER                   :: 0x8892;
+ELEMENT_ARRAY_BUFFER           :: 0x8893;
+ARRAY_BUFFER_BINDING           :: 0x8894;
+ELEMENT_ARRAY_BUFFER_BINDING   :: 0x8895;
+VERTEX_ATTRIB_ARRAY_BUFFER_BINDING :: 0x889F;
+READ_ONLY                      :: 0x88B8;
+WRITE_ONLY                     :: 0x88B9;
+READ_WRITE                     :: 0x88BA;
+BUFFER_ACCESS                  :: 0x88BB;
+BUFFER_MAPPED                  :: 0x88BC;
+BUFFER_MAP_POINTER             :: 0x88BD;
+STREAM_DRAW                    :: 0x88E0;
+STREAM_READ                    :: 0x88E1;
+STREAM_COPY                    :: 0x88E2;
+STATIC_DRAW                    :: 0x88E4;
+STATIC_READ                    :: 0x88E5;
+STATIC_COPY                    :: 0x88E6;
+DYNAMIC_DRAW                   :: 0x88E8;
+DYNAMIC_READ                   :: 0x88E9;
+DYNAMIC_COPY                   :: 0x88EA;
+SAMPLES_PASSED                 :: 0x8914;
+SRC1_ALPHA                     :: 0x8589;
 
-BLEND_EQUATION_RGB             :: 0x8009
-VERTEX_ATTRIB_ARRAY_ENABLED    :: 0x8622
-VERTEX_ATTRIB_ARRAY_SIZE       :: 0x8623
-VERTEX_ATTRIB_ARRAY_STRIDE     :: 0x8624
-VERTEX_ATTRIB_ARRAY_TYPE       :: 0x8625
-CURRENT_VERTEX_ATTRIB          :: 0x8626
-VERTEX_PROGRAM_POINT_SIZE      :: 0x8642
-VERTEX_ATTRIB_ARRAY_POINTER    :: 0x8645
-STENCIL_BACK_FUNC              :: 0x8800
-STENCIL_BACK_FAIL              :: 0x8801
-STENCIL_BACK_PASS_DEPTH_FAIL   :: 0x8802
-STENCIL_BACK_PASS_DEPTH_PASS   :: 0x8803
-MAX_DRAW_BUFFERS               :: 0x8824
-DRAW_BUFFER0                   :: 0x8825
-DRAW_BUFFER1                   :: 0x8826
-DRAW_BUFFER2                   :: 0x8827
-DRAW_BUFFER3                   :: 0x8828
-DRAW_BUFFER4                   :: 0x8829
-DRAW_BUFFER5                   :: 0x882A
-DRAW_BUFFER6                   :: 0x882B
-DRAW_BUFFER7                   :: 0x882C
-DRAW_BUFFER8                   :: 0x882D
-DRAW_BUFFER9                   :: 0x882E
-DRAW_BUFFER10                  :: 0x882F
-DRAW_BUFFER11                  :: 0x8830
-DRAW_BUFFER12                  :: 0x8831
-DRAW_BUFFER13                  :: 0x8832
-DRAW_BUFFER14                  :: 0x8833
-DRAW_BUFFER15                  :: 0x8834
-BLEND_EQUATION_ALPHA           :: 0x883D
-MAX_VERTEX_ATTRIBS             :: 0x8869
-VERTEX_ATTRIB_ARRAY_NORMALIZED :: 0x886A
-MAX_TEXTURE_IMAGE_UNITS        :: 0x8872
-FRAGMENT_SHADER                :: 0x8B30
-VERTEX_SHADER                  :: 0x8B31
-MAX_FRAGMENT_UNIFORM_COMPONENTS :: 0x8B49
-MAX_VERTEX_UNIFORM_COMPONENTS  :: 0x8B4A
-MAX_VARYING_FLOATS             :: 0x8B4B
-MAX_VERTEX_TEXTURE_IMAGE_UNITS :: 0x8B4C
-MAX_COMBINED_TEXTURE_IMAGE_UNITS :: 0x8B4D
-SHADER_TYPE                    :: 0x8B4F
-FLOAT_VEC2                     :: 0x8B50
-FLOAT_VEC3                     :: 0x8B51
-FLOAT_VEC4                     :: 0x8B52
-INT_VEC2                       :: 0x8B53
-INT_VEC3                       :: 0x8B54
-INT_VEC4                       :: 0x8B55
-BOOL                           :: 0x8B56
-BOOL_VEC2                      :: 0x8B57
-BOOL_VEC3                      :: 0x8B58
-BOOL_VEC4                      :: 0x8B59
-FLOAT_MAT2                     :: 0x8B5A
-FLOAT_MAT3                     :: 0x8B5B
-FLOAT_MAT4                     :: 0x8B5C
-SAMPLER_1D                     :: 0x8B5D
-SAMPLER_2D                     :: 0x8B5E
-SAMPLER_3D                     :: 0x8B5F
-SAMPLER_CUBE                   :: 0x8B60
-SAMPLER_1D_SHADOW              :: 0x8B61
-SAMPLER_2D_SHADOW              :: 0x8B62
-DELETE_STATUS                  :: 0x8B80
-COMPILE_STATUS                 :: 0x8B81
-LINK_STATUS                    :: 0x8B82
-VALIDATE_STATUS                :: 0x8B83
-INFO_LOG_LENGTH                :: 0x8B84
-ATTACHED_SHADERS               :: 0x8B85
-ACTIVE_UNIFORMS                :: 0x8B86
-ACTIVE_UNIFORM_MAX_LENGTH      :: 0x8B87
-SHADER_SOURCE_LENGTH           :: 0x8B88
-ACTIVE_ATTRIBUTES              :: 0x8B89
-ACTIVE_ATTRIBUTE_MAX_LENGTH    :: 0x8B8A
-FRAGMENT_SHADER_DERIVATIVE_HINT :: 0x8B8B
-SHADING_LANGUAGE_VERSION       :: 0x8B8C
-CURRENT_PROGRAM                :: 0x8B8D
-POINT_SPRITE_COORD_ORIGIN      :: 0x8CA0
-LOWER_LEFT                     :: 0x8CA1
-UPPER_LEFT                     :: 0x8CA2
-STENCIL_BACK_REF               :: 0x8CA3
-STENCIL_BACK_VALUE_MASK        :: 0x8CA4
-STENCIL_BACK_WRITEMASK         :: 0x8CA5
+BLEND_EQUATION_RGB             :: 0x8009;
+VERTEX_ATTRIB_ARRAY_ENABLED    :: 0x8622;
+VERTEX_ATTRIB_ARRAY_SIZE       :: 0x8623;
+VERTEX_ATTRIB_ARRAY_STRIDE     :: 0x8624;
+VERTEX_ATTRIB_ARRAY_TYPE       :: 0x8625;
+CURRENT_VERTEX_ATTRIB          :: 0x8626;
+VERTEX_PROGRAM_POINT_SIZE      :: 0x8642;
+VERTEX_ATTRIB_ARRAY_POINTER    :: 0x8645;
+STENCIL_BACK_FUNC              :: 0x8800;
+STENCIL_BACK_FAIL              :: 0x8801;
+STENCIL_BACK_PASS_DEPTH_FAIL   :: 0x8802;
+STENCIL_BACK_PASS_DEPTH_PASS   :: 0x8803;
+MAX_DRAW_BUFFERS               :: 0x8824;
+DRAW_BUFFER0                   :: 0x8825;
+DRAW_BUFFER1                   :: 0x8826;
+DRAW_BUFFER2                   :: 0x8827;
+DRAW_BUFFER3                   :: 0x8828;
+DRAW_BUFFER4                   :: 0x8829;
+DRAW_BUFFER5                   :: 0x882A;
+DRAW_BUFFER6                   :: 0x882B;
+DRAW_BUFFER7                   :: 0x882C;
+DRAW_BUFFER8                   :: 0x882D;
+DRAW_BUFFER9                   :: 0x882E;
+DRAW_BUFFER10                  :: 0x882F;
+DRAW_BUFFER11                  :: 0x8830;
+DRAW_BUFFER12                  :: 0x8831;
+DRAW_BUFFER13                  :: 0x8832;
+DRAW_BUFFER14                  :: 0x8833;
+DRAW_BUFFER15                  :: 0x8834;
+BLEND_EQUATION_ALPHA           :: 0x883D;
+MAX_VERTEX_ATTRIBS             :: 0x8869;
+VERTEX_ATTRIB_ARRAY_NORMALIZED :: 0x886A;
+MAX_TEXTURE_IMAGE_UNITS        :: 0x8872;
+FRAGMENT_SHADER                :: 0x8B30;
+VERTEX_SHADER                  :: 0x8B31;
+MAX_FRAGMENT_UNIFORM_COMPONENTS :: 0x8B49;
+MAX_VERTEX_UNIFORM_COMPONENTS  :: 0x8B4A;
+MAX_VARYING_FLOATS             :: 0x8B4B;
+MAX_VERTEX_TEXTURE_IMAGE_UNITS :: 0x8B4C;
+MAX_COMBINED_TEXTURE_IMAGE_UNITS :: 0x8B4D;
+SHADER_TYPE                    :: 0x8B4F;
+FLOAT_VEC2                     :: 0x8B50;
+FLOAT_VEC3                     :: 0x8B51;
+FLOAT_VEC4                     :: 0x8B52;
+INT_VEC2                       :: 0x8B53;
+INT_VEC3                       :: 0x8B54;
+INT_VEC4                       :: 0x8B55;
+BOOL                           :: 0x8B56;
+BOOL_VEC2                      :: 0x8B57;
+BOOL_VEC3                      :: 0x8B58;
+BOOL_VEC4                      :: 0x8B59;
+FLOAT_MAT2                     :: 0x8B5A;
+FLOAT_MAT3                     :: 0x8B5B;
+FLOAT_MAT4                     :: 0x8B5C;
+SAMPLER_1D                     :: 0x8B5D;
+SAMPLER_2D                     :: 0x8B5E;
+SAMPLER_3D                     :: 0x8B5F;
+SAMPLER_CUBE                   :: 0x8B60;
+SAMPLER_1D_SHADOW              :: 0x8B61;
+SAMPLER_2D_SHADOW              :: 0x8B62;
+DELETE_STATUS                  :: 0x8B80;
+COMPILE_STATUS                 :: 0x8B81;
+LINK_STATUS                    :: 0x8B82;
+VALIDATE_STATUS                :: 0x8B83;
+INFO_LOG_LENGTH                :: 0x8B84;
+ATTACHED_SHADERS               :: 0x8B85;
+ACTIVE_UNIFORMS                :: 0x8B86;
+ACTIVE_UNIFORM_MAX_LENGTH      :: 0x8B87;
+SHADER_SOURCE_LENGTH           :: 0x8B88;
+ACTIVE_ATTRIBUTES              :: 0x8B89;
+ACTIVE_ATTRIBUTE_MAX_LENGTH    :: 0x8B8A;
+FRAGMENT_SHADER_DERIVATIVE_HINT :: 0x8B8B;
+SHADING_LANGUAGE_VERSION       :: 0x8B8C;
+CURRENT_PROGRAM                :: 0x8B8D;
+POINT_SPRITE_COORD_ORIGIN      :: 0x8CA0;
+LOWER_LEFT                     :: 0x8CA1;
+UPPER_LEFT                     :: 0x8CA2;
+STENCIL_BACK_REF               :: 0x8CA3;
+STENCIL_BACK_VALUE_MASK        :: 0x8CA4;
+STENCIL_BACK_WRITEMASK         :: 0x8CA5;
 
-PIXEL_PACK_BUFFER              :: 0x88EB
-PIXEL_UNPACK_BUFFER            :: 0x88EC
-PIXEL_PACK_BUFFER_BINDING      :: 0x88ED
-PIXEL_UNPACK_BUFFER_BINDING    :: 0x88EF
-FLOAT_MAT2x3                   :: 0x8B65
-FLOAT_MAT2x4                   :: 0x8B66
-FLOAT_MAT3x2                   :: 0x8B67
-FLOAT_MAT3x4                   :: 0x8B68
-FLOAT_MAT4x2                   :: 0x8B69
-FLOAT_MAT4x3                   :: 0x8B6A
-SRGB                           :: 0x8C40
-SRGB8                          :: 0x8C41
-SRGB_ALPHA                     :: 0x8C42
-SRGB8_ALPHA8                   :: 0x8C43
-COMPRESSED_SRGB                :: 0x8C48
-COMPRESSED_SRGB_ALPHA          :: 0x8C49
+PIXEL_PACK_BUFFER              :: 0x88EB;
+PIXEL_UNPACK_BUFFER            :: 0x88EC;
+PIXEL_PACK_BUFFER_BINDING      :: 0x88ED;
+PIXEL_UNPACK_BUFFER_BINDING    :: 0x88EF;
+FLOAT_MAT2x3                   :: 0x8B65;
+FLOAT_MAT2x4                   :: 0x8B66;
+FLOAT_MAT3x2                   :: 0x8B67;
+FLOAT_MAT3x4                   :: 0x8B68;
+FLOAT_MAT4x2                   :: 0x8B69;
+FLOAT_MAT4x3                   :: 0x8B6A;
+SRGB                           :: 0x8C40;
+SRGB8                          :: 0x8C41;
+SRGB_ALPHA                     :: 0x8C42;
+SRGB8_ALPHA8                   :: 0x8C43;
+COMPRESSED_SRGB                :: 0x8C48;
+COMPRESSED_SRGB_ALPHA          :: 0x8C49;
 
-COMPARE_REF_TO_TEXTURE         :: 0x884E
-CLIP_DISTANCE0                 :: 0x3000
-CLIP_DISTANCE1                 :: 0x3001
-CLIP_DISTANCE2                 :: 0x3002
-CLIP_DISTANCE3                 :: 0x3003
-CLIP_DISTANCE4                 :: 0x3004
-CLIP_DISTANCE5                 :: 0x3005
-CLIP_DISTANCE6                 :: 0x3006
-CLIP_DISTANCE7                 :: 0x3007
-MAX_CLIP_DISTANCES             :: 0x0D32
-MAJOR_VERSION                  :: 0x821B
-MINOR_VERSION                  :: 0x821C
-NUM_EXTENSIONS                 :: 0x821D
-CONTEXT_FLAGS                  :: 0x821E
-COMPRESSED_RED                 :: 0x8225
-COMPRESSED_RG                  :: 0x8226
-CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT :: 0x00000001
-RGBA32F                        :: 0x8814
-RGB32F                         :: 0x8815
-RGBA16F                        :: 0x881A
-RGB16F                         :: 0x881B
-VERTEX_ATTRIB_ARRAY_INTEGER    :: 0x88FD
-MAX_ARRAY_TEXTURE_LAYERS       :: 0x88FF
-MIN_PROGRAM_TEXEL_OFFSET       :: 0x8904
-MAX_PROGRAM_TEXEL_OFFSET       :: 0x8905
-CLAMP_READ_COLOR               :: 0x891C
-FIXED_ONLY                     :: 0x891D
-MAX_VARYING_COMPONENTS         :: 0x8B4B
-TEXTURE_1D_ARRAY               :: 0x8C18
-PROXY_TEXTURE_1D_ARRAY         :: 0x8C19
-TEXTURE_2D_ARRAY               :: 0x8C1A
-PROXY_TEXTURE_2D_ARRAY         :: 0x8C1B
-TEXTURE_BINDING_1D_ARRAY       :: 0x8C1C
-TEXTURE_BINDING_2D_ARRAY       :: 0x8C1D
-R11F_G11F_B10F                 :: 0x8C3A
-UNSIGNED_INT_10F_11F_11F_REV   :: 0x8C3B
-RGB9_E5                        :: 0x8C3D
-UNSIGNED_INT_5_9_9_9_REV       :: 0x8C3E
-TEXTURE_SHARED_SIZE            :: 0x8C3F
-TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH :: 0x8C76
-TRANSFORM_FEEDBACK_BUFFER_MODE :: 0x8C7F
-MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS :: 0x8C80
-TRANSFORM_FEEDBACK_VARYINGS    :: 0x8C83
-TRANSFORM_FEEDBACK_BUFFER_START :: 0x8C84
-TRANSFORM_FEEDBACK_BUFFER_SIZE :: 0x8C85
-PRIMITIVES_GENERATED           :: 0x8C87
-TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN :: 0x8C88
-RASTERIZER_DISCARD             :: 0x8C89
-MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS :: 0x8C8A
-MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS :: 0x8C8B
-INTERLEAVED_ATTRIBS            :: 0x8C8C
-SEPARATE_ATTRIBS               :: 0x8C8D
-TRANSFORM_FEEDBACK_BUFFER      :: 0x8C8E
-TRANSFORM_FEEDBACK_BUFFER_BINDING :: 0x8C8F
-RGBA32UI                       :: 0x8D70
-RGB32UI                        :: 0x8D71
-RGBA16UI                       :: 0x8D76
-RGB16UI                        :: 0x8D77
-RGBA8UI                        :: 0x8D7C
-RGB8UI                         :: 0x8D7D
-RGBA32I                        :: 0x8D82
-RGB32I                         :: 0x8D83
-RGBA16I                        :: 0x8D88
-RGB16I                         :: 0x8D89
-RGBA8I                         :: 0x8D8E
-RGB8I                          :: 0x8D8F
-RED_INTEGER                    :: 0x8D94
-GREEN_INTEGER                  :: 0x8D95
-BLUE_INTEGER                   :: 0x8D96
-RGB_INTEGER                    :: 0x8D98
-RGBA_INTEGER                   :: 0x8D99
-BGR_INTEGER                    :: 0x8D9A
-BGRA_INTEGER                   :: 0x8D9B
-SAMPLER_1D_ARRAY               :: 0x8DC0
-SAMPLER_2D_ARRAY               :: 0x8DC1
-SAMPLER_1D_ARRAY_SHADOW        :: 0x8DC3
-SAMPLER_2D_ARRAY_SHADOW        :: 0x8DC4
-SAMPLER_CUBE_SHADOW            :: 0x8DC5
-UNSIGNED_INT_VEC2              :: 0x8DC6
-UNSIGNED_INT_VEC3              :: 0x8DC7
-UNSIGNED_INT_VEC4              :: 0x8DC8
-INT_SAMPLER_1D                 :: 0x8DC9
-INT_SAMPLER_2D                 :: 0x8DCA
-INT_SAMPLER_3D                 :: 0x8DCB
-INT_SAMPLER_CUBE               :: 0x8DCC
-INT_SAMPLER_1D_ARRAY           :: 0x8DCE
-INT_SAMPLER_2D_ARRAY           :: 0x8DCF
-UNSIGNED_INT_SAMPLER_1D        :: 0x8DD1
-UNSIGNED_INT_SAMPLER_2D        :: 0x8DD2
-UNSIGNED_INT_SAMPLER_3D        :: 0x8DD3
-UNSIGNED_INT_SAMPLER_CUBE      :: 0x8DD4
-UNSIGNED_INT_SAMPLER_1D_ARRAY  :: 0x8DD6
-UNSIGNED_INT_SAMPLER_2D_ARRAY  :: 0x8DD7
-QUERY_WAIT                     :: 0x8E13
-QUERY_NO_WAIT                  :: 0x8E14
-QUERY_BY_REGION_WAIT           :: 0x8E15
-QUERY_BY_REGION_NO_WAIT        :: 0x8E16
-BUFFER_ACCESS_FLAGS            :: 0x911F
-BUFFER_MAP_LENGTH              :: 0x9120
-BUFFER_MAP_OFFSET              :: 0x9121
-DEPTH_COMPONENT32F             :: 0x8CAC
-DEPTH32F_STENCIL8              :: 0x8CAD
-FLOAT_32_UNSIGNED_INT_24_8_REV :: 0x8DAD
-INVALID_FRAMEBUFFER_OPERATION  :: 0x0506
-FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING :: 0x8210
-FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE :: 0x8211
-FRAMEBUFFER_ATTACHMENT_RED_SIZE :: 0x8212
-FRAMEBUFFER_ATTACHMENT_GREEN_SIZE :: 0x8213
-FRAMEBUFFER_ATTACHMENT_BLUE_SIZE :: 0x8214
-FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE :: 0x8215
-FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE :: 0x8216
-FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE :: 0x8217
-FRAMEBUFFER_DEFAULT            :: 0x8218
-FRAMEBUFFER_UNDEFINED          :: 0x8219
-DEPTH_STENCIL_ATTACHMENT       :: 0x821A
-MAX_RENDERBUFFER_SIZE          :: 0x84E8
-DEPTH_STENCIL                  :: 0x84F9
-UNSIGNED_INT_24_8              :: 0x84FA
-DEPTH24_STENCIL8               :: 0x88F0
-TEXTURE_STENCIL_SIZE           :: 0x88F1
-TEXTURE_RED_TYPE               :: 0x8C10
-TEXTURE_GREEN_TYPE             :: 0x8C11
-TEXTURE_BLUE_TYPE              :: 0x8C12
-TEXTURE_ALPHA_TYPE             :: 0x8C13
-TEXTURE_DEPTH_TYPE             :: 0x8C16
-UNSIGNED_NORMALIZED            :: 0x8C17
-FRAMEBUFFER_BINDING            :: 0x8CA6
-DRAW_FRAMEBUFFER_BINDING       :: 0x8CA6
-RENDERBUFFER_BINDING           :: 0x8CA7
-READ_FRAMEBUFFER               :: 0x8CA8
-DRAW_FRAMEBUFFER               :: 0x8CA9
-READ_FRAMEBUFFER_BINDING       :: 0x8CAA
-RENDERBUFFER_SAMPLES           :: 0x8CAB
-FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE :: 0x8CD0
-FRAMEBUFFER_ATTACHMENT_OBJECT_NAME :: 0x8CD1
-FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL :: 0x8CD2
-FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE :: 0x8CD3
-FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER :: 0x8CD4
-FRAMEBUFFER_COMPLETE           :: 0x8CD5
-FRAMEBUFFER_INCOMPLETE_ATTACHMENT :: 0x8CD6
-FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT :: 0x8CD7
-FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER :: 0x8CDB
-FRAMEBUFFER_INCOMPLETE_READ_BUFFER :: 0x8CDC
-FRAMEBUFFER_UNSUPPORTED        :: 0x8CDD
-MAX_COLOR_ATTACHMENTS          :: 0x8CDF
-COLOR_ATTACHMENT0              :: 0x8CE0
-COLOR_ATTACHMENT1              :: 0x8CE1
-COLOR_ATTACHMENT2              :: 0x8CE2
-COLOR_ATTACHMENT3              :: 0x8CE3
-COLOR_ATTACHMENT4              :: 0x8CE4
-COLOR_ATTACHMENT5              :: 0x8CE5
-COLOR_ATTACHMENT6              :: 0x8CE6
-COLOR_ATTACHMENT7              :: 0x8CE7
-COLOR_ATTACHMENT8              :: 0x8CE8
-COLOR_ATTACHMENT9              :: 0x8CE9
-COLOR_ATTACHMENT10             :: 0x8CEA
-COLOR_ATTACHMENT11             :: 0x8CEB
-COLOR_ATTACHMENT12             :: 0x8CEC
-COLOR_ATTACHMENT13             :: 0x8CED
-COLOR_ATTACHMENT14             :: 0x8CEE
-COLOR_ATTACHMENT15             :: 0x8CEF
-COLOR_ATTACHMENT16             :: 0x8CF0
-COLOR_ATTACHMENT17             :: 0x8CF1
-COLOR_ATTACHMENT18             :: 0x8CF2
-COLOR_ATTACHMENT19             :: 0x8CF3
-COLOR_ATTACHMENT20             :: 0x8CF4
-COLOR_ATTACHMENT21             :: 0x8CF5
-COLOR_ATTACHMENT22             :: 0x8CF6
-COLOR_ATTACHMENT23             :: 0x8CF7
-COLOR_ATTACHMENT24             :: 0x8CF8
-COLOR_ATTACHMENT25             :: 0x8CF9
-COLOR_ATTACHMENT26             :: 0x8CFA
-COLOR_ATTACHMENT27             :: 0x8CFB
-COLOR_ATTACHMENT28             :: 0x8CFC
-COLOR_ATTACHMENT29             :: 0x8CFD
-COLOR_ATTACHMENT30             :: 0x8CFE
-COLOR_ATTACHMENT31             :: 0x8CFF
-DEPTH_ATTACHMENT               :: 0x8D00
-STENCIL_ATTACHMENT             :: 0x8D20
-FRAMEBUFFER                    :: 0x8D40
-RENDERBUFFER                   :: 0x8D41
-RENDERBUFFER_WIDTH             :: 0x8D42
-RENDERBUFFER_HEIGHT            :: 0x8D43
-RENDERBUFFER_INTERNAL_FORMAT   :: 0x8D44
-STENCIL_INDEX1                 :: 0x8D46
-STENCIL_INDEX4                 :: 0x8D47
-STENCIL_INDEX8                 :: 0x8D48
-STENCIL_INDEX16                :: 0x8D49
-RENDERBUFFER_RED_SIZE          :: 0x8D50
-RENDERBUFFER_GREEN_SIZE        :: 0x8D51
-RENDERBUFFER_BLUE_SIZE         :: 0x8D52
-RENDERBUFFER_ALPHA_SIZE        :: 0x8D53
-RENDERBUFFER_DEPTH_SIZE        :: 0x8D54
-RENDERBUFFER_STENCIL_SIZE      :: 0x8D55
-FRAMEBUFFER_INCOMPLETE_MULTISAMPLE :: 0x8D56
-MAX_SAMPLES                    :: 0x8D57
-FRAMEBUFFER_SRGB               :: 0x8DB9
-HALF_FLOAT                     :: 0x140B
-MAP_READ_BIT                   :: 0x0001
-MAP_WRITE_BIT                  :: 0x0002
-MAP_INVALIDATE_RANGE_BIT       :: 0x0004
-MAP_INVALIDATE_BUFFER_BIT      :: 0x0008
-MAP_FLUSH_EXPLICIT_BIT         :: 0x0010
-MAP_UNSYNCHRONIZED_BIT         :: 0x0020
-COMPRESSED_RED_RGTC1           :: 0x8DBB
-COMPRESSED_SIGNED_RED_RGTC1    :: 0x8DBC
-COMPRESSED_RG_RGTC2            :: 0x8DBD
-COMPRESSED_SIGNED_RG_RGTC2     :: 0x8DBE
-RG                             :: 0x8227
-RG_INTEGER                     :: 0x8228
-R8                             :: 0x8229
-R16                            :: 0x822A
-RG8                            :: 0x822B
-RG16                           :: 0x822C
-R16F                           :: 0x822D
-R32F                           :: 0x822E
-RG16F                          :: 0x822F
-RG32F                          :: 0x8230
-R8I                            :: 0x8231
-R8UI                           :: 0x8232
-R16I                           :: 0x8233
-R16UI                          :: 0x8234
-R32I                           :: 0x8235
-R32UI                          :: 0x8236
-RG8I                           :: 0x8237
-RG8UI                          :: 0x8238
-RG16I                          :: 0x8239
-RG16UI                         :: 0x823A
-RG32I                          :: 0x823B
-RG32UI                         :: 0x823C
-VERTEX_ARRAY_BINDING           :: 0x85B5
+COMPARE_REF_TO_TEXTURE         :: 0x884E;
+CLIP_DISTANCE0                 :: 0x3000;
+CLIP_DISTANCE1                 :: 0x3001;
+CLIP_DISTANCE2                 :: 0x3002;
+CLIP_DISTANCE3                 :: 0x3003;
+CLIP_DISTANCE4                 :: 0x3004;
+CLIP_DISTANCE5                 :: 0x3005;
+CLIP_DISTANCE6                 :: 0x3006;
+CLIP_DISTANCE7                 :: 0x3007;
+MAX_CLIP_DISTANCES             :: 0x0D32;
+MAJOR_VERSION                  :: 0x821B;
+MINOR_VERSION                  :: 0x821C;
+NUM_EXTENSIONS                 :: 0x821D;
+CONTEXT_FLAGS                  :: 0x821E;
+COMPRESSED_RED                 :: 0x8225;
+COMPRESSED_RG                  :: 0x8226;
+CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT :: 0x00000001;
+RGBA32F                        :: 0x8814;
+RGB32F                         :: 0x8815;
+RGBA16F                        :: 0x881A;
+RGB16F                         :: 0x881B;
+VERTEX_ATTRIB_ARRAY_INTEGER    :: 0x88FD;
+MAX_ARRAY_TEXTURE_LAYERS       :: 0x88FF;
+MIN_PROGRAM_TEXEL_OFFSET       :: 0x8904;
+MAX_PROGRAM_TEXEL_OFFSET       :: 0x8905;
+CLAMP_READ_COLOR               :: 0x891C;
+FIXED_ONLY                     :: 0x891D;
+MAX_VARYING_COMPONENTS         :: 0x8B4B;
+TEXTURE_1D_ARRAY               :: 0x8C18;
+PROXY_TEXTURE_1D_ARRAY         :: 0x8C19;
+TEXTURE_2D_ARRAY               :: 0x8C1A;
+PROXY_TEXTURE_2D_ARRAY         :: 0x8C1B;
+TEXTURE_BINDING_1D_ARRAY       :: 0x8C1C;
+TEXTURE_BINDING_2D_ARRAY       :: 0x8C1D;
+R11F_G11F_B10F                 :: 0x8C3A;
+UNSIGNED_INT_10F_11F_11F_REV   :: 0x8C3B;
+RGB9_E5                        :: 0x8C3D;
+UNSIGNED_INT_5_9_9_9_REV       :: 0x8C3E;
+TEXTURE_SHARED_SIZE            :: 0x8C3F;
+TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH :: 0x8C76;
+TRANSFORM_FEEDBACK_BUFFER_MODE :: 0x8C7F;
+MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS :: 0x8C80;
+TRANSFORM_FEEDBACK_VARYINGS    :: 0x8C83;
+TRANSFORM_FEEDBACK_BUFFER_START :: 0x8C84;
+TRANSFORM_FEEDBACK_BUFFER_SIZE :: 0x8C85;
+PRIMITIVES_GENERATED           :: 0x8C87;
+TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN :: 0x8C88;
+RASTERIZER_DISCARD             :: 0x8C89;
+MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS :: 0x8C8A;
+MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS :: 0x8C8B;
+INTERLEAVED_ATTRIBS            :: 0x8C8C;
+SEPARATE_ATTRIBS               :: 0x8C8D;
+TRANSFORM_FEEDBACK_BUFFER      :: 0x8C8E;
+TRANSFORM_FEEDBACK_BUFFER_BINDING :: 0x8C8F;
+RGBA32UI                       :: 0x8D70;
+RGB32UI                        :: 0x8D71;
+RGBA16UI                       :: 0x8D76;
+RGB16UI                        :: 0x8D77;
+RGBA8UI                        :: 0x8D7C;
+RGB8UI                         :: 0x8D7D;
+RGBA32I                        :: 0x8D82;
+RGB32I                         :: 0x8D83;
+RGBA16I                        :: 0x8D88;
+RGB16I                         :: 0x8D89;
+RGBA8I                         :: 0x8D8E;
+RGB8I                          :: 0x8D8F;
+RED_INTEGER                    :: 0x8D94;
+GREEN_INTEGER                  :: 0x8D95;
+BLUE_INTEGER                   :: 0x8D96;
+RGB_INTEGER                    :: 0x8D98;
+RGBA_INTEGER                   :: 0x8D99;
+BGR_INTEGER                    :: 0x8D9A;
+BGRA_INTEGER                   :: 0x8D9B;
+SAMPLER_1D_ARRAY               :: 0x8DC0;
+SAMPLER_2D_ARRAY               :: 0x8DC1;
+SAMPLER_1D_ARRAY_SHADOW        :: 0x8DC3;
+SAMPLER_2D_ARRAY_SHADOW        :: 0x8DC4;
+SAMPLER_CUBE_SHADOW            :: 0x8DC5;
+UNSIGNED_INT_VEC2              :: 0x8DC6;
+UNSIGNED_INT_VEC3              :: 0x8DC7;
+UNSIGNED_INT_VEC4              :: 0x8DC8;
+INT_SAMPLER_1D                 :: 0x8DC9;
+INT_SAMPLER_2D                 :: 0x8DCA;
+INT_SAMPLER_3D                 :: 0x8DCB;
+INT_SAMPLER_CUBE               :: 0x8DCC;
+INT_SAMPLER_1D_ARRAY           :: 0x8DCE;
+INT_SAMPLER_2D_ARRAY           :: 0x8DCF;
+UNSIGNED_INT_SAMPLER_1D        :: 0x8DD1;
+UNSIGNED_INT_SAMPLER_2D        :: 0x8DD2;
+UNSIGNED_INT_SAMPLER_3D        :: 0x8DD3;
+UNSIGNED_INT_SAMPLER_CUBE      :: 0x8DD4;
+UNSIGNED_INT_SAMPLER_1D_ARRAY  :: 0x8DD6;
+UNSIGNED_INT_SAMPLER_2D_ARRAY  :: 0x8DD7;
+QUERY_WAIT                     :: 0x8E13;
+QUERY_NO_WAIT                  :: 0x8E14;
+QUERY_BY_REGION_WAIT           :: 0x8E15;
+QUERY_BY_REGION_NO_WAIT        :: 0x8E16;
+BUFFER_ACCESS_FLAGS            :: 0x911F;
+BUFFER_MAP_LENGTH              :: 0x9120;
+BUFFER_MAP_OFFSET              :: 0x9121;
+DEPTH_COMPONENT32F             :: 0x8CAC;
+DEPTH32F_STENCIL8              :: 0x8CAD;
+FLOAT_32_UNSIGNED_INT_24_8_REV :: 0x8DAD;
+INVALID_FRAMEBUFFER_OPERATION  :: 0x0506;
+FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING :: 0x8210;
+FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE :: 0x8211;
+FRAMEBUFFER_ATTACHMENT_RED_SIZE :: 0x8212;
+FRAMEBUFFER_ATTACHMENT_GREEN_SIZE :: 0x8213;
+FRAMEBUFFER_ATTACHMENT_BLUE_SIZE :: 0x8214;
+FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE :: 0x8215;
+FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE :: 0x8216;
+FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE :: 0x8217;
+FRAMEBUFFER_DEFAULT            :: 0x8218;
+FRAMEBUFFER_UNDEFINED          :: 0x8219;
+DEPTH_STENCIL_ATTACHMENT       :: 0x821A;
+MAX_RENDERBUFFER_SIZE          :: 0x84E8;
+DEPTH_STENCIL                  :: 0x84F9;
+UNSIGNED_INT_24_8              :: 0x84FA;
+DEPTH24_STENCIL8               :: 0x88F0;
+TEXTURE_STENCIL_SIZE           :: 0x88F1;
+TEXTURE_RED_TYPE               :: 0x8C10;
+TEXTURE_GREEN_TYPE             :: 0x8C11;
+TEXTURE_BLUE_TYPE              :: 0x8C12;
+TEXTURE_ALPHA_TYPE             :: 0x8C13;
+TEXTURE_DEPTH_TYPE             :: 0x8C16;
+UNSIGNED_NORMALIZED            :: 0x8C17;
+FRAMEBUFFER_BINDING            :: 0x8CA6;
+DRAW_FRAMEBUFFER_BINDING       :: 0x8CA6;
+RENDERBUFFER_BINDING           :: 0x8CA7;
+READ_FRAMEBUFFER               :: 0x8CA8;
+DRAW_FRAMEBUFFER               :: 0x8CA9;
+READ_FRAMEBUFFER_BINDING       :: 0x8CAA;
+RENDERBUFFER_SAMPLES           :: 0x8CAB;
+FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE :: 0x8CD0;
+FRAMEBUFFER_ATTACHMENT_OBJECT_NAME :: 0x8CD1;
+FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL :: 0x8CD2;
+FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE :: 0x8CD3;
+FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER :: 0x8CD4;
+FRAMEBUFFER_COMPLETE           :: 0x8CD5;
+FRAMEBUFFER_INCOMPLETE_ATTACHMENT :: 0x8CD6;
+FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT :: 0x8CD7;
+FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER :: 0x8CDB;
+FRAMEBUFFER_INCOMPLETE_READ_BUFFER :: 0x8CDC;
+FRAMEBUFFER_UNSUPPORTED        :: 0x8CDD;
+MAX_COLOR_ATTACHMENTS          :: 0x8CDF;
+COLOR_ATTACHMENT0              :: 0x8CE0;
+COLOR_ATTACHMENT1              :: 0x8CE1;
+COLOR_ATTACHMENT2              :: 0x8CE2;
+COLOR_ATTACHMENT3              :: 0x8CE3;
+COLOR_ATTACHMENT4              :: 0x8CE4;
+COLOR_ATTACHMENT5              :: 0x8CE5;
+COLOR_ATTACHMENT6              :: 0x8CE6;
+COLOR_ATTACHMENT7              :: 0x8CE7;
+COLOR_ATTACHMENT8              :: 0x8CE8;
+COLOR_ATTACHMENT9              :: 0x8CE9;
+COLOR_ATTACHMENT10             :: 0x8CEA;
+COLOR_ATTACHMENT11             :: 0x8CEB;
+COLOR_ATTACHMENT12             :: 0x8CEC;
+COLOR_ATTACHMENT13             :: 0x8CED;
+COLOR_ATTACHMENT14             :: 0x8CEE;
+COLOR_ATTACHMENT15             :: 0x8CEF;
+COLOR_ATTACHMENT16             :: 0x8CF0;
+COLOR_ATTACHMENT17             :: 0x8CF1;
+COLOR_ATTACHMENT18             :: 0x8CF2;
+COLOR_ATTACHMENT19             :: 0x8CF3;
+COLOR_ATTACHMENT20             :: 0x8CF4;
+COLOR_ATTACHMENT21             :: 0x8CF5;
+COLOR_ATTACHMENT22             :: 0x8CF6;
+COLOR_ATTACHMENT23             :: 0x8CF7;
+COLOR_ATTACHMENT24             :: 0x8CF8;
+COLOR_ATTACHMENT25             :: 0x8CF9;
+COLOR_ATTACHMENT26             :: 0x8CFA;
+COLOR_ATTACHMENT27             :: 0x8CFB;
+COLOR_ATTACHMENT28             :: 0x8CFC;
+COLOR_ATTACHMENT29             :: 0x8CFD;
+COLOR_ATTACHMENT30             :: 0x8CFE;
+COLOR_ATTACHMENT31             :: 0x8CFF;
+DEPTH_ATTACHMENT               :: 0x8D00;
+STENCIL_ATTACHMENT             :: 0x8D20;
+FRAMEBUFFER                    :: 0x8D40;
+RENDERBUFFER                   :: 0x8D41;
+RENDERBUFFER_WIDTH             :: 0x8D42;
+RENDERBUFFER_HEIGHT            :: 0x8D43;
+RENDERBUFFER_INTERNAL_FORMAT   :: 0x8D44;
+STENCIL_INDEX1                 :: 0x8D46;
+STENCIL_INDEX4                 :: 0x8D47;
+STENCIL_INDEX8                 :: 0x8D48;
+STENCIL_INDEX16                :: 0x8D49;
+RENDERBUFFER_RED_SIZE          :: 0x8D50;
+RENDERBUFFER_GREEN_SIZE        :: 0x8D51;
+RENDERBUFFER_BLUE_SIZE         :: 0x8D52;
+RENDERBUFFER_ALPHA_SIZE        :: 0x8D53;
+RENDERBUFFER_DEPTH_SIZE        :: 0x8D54;
+RENDERBUFFER_STENCIL_SIZE      :: 0x8D55;
+FRAMEBUFFER_INCOMPLETE_MULTISAMPLE :: 0x8D56;
+MAX_SAMPLES                    :: 0x8D57;
+FRAMEBUFFER_SRGB               :: 0x8DB9;
+HALF_FLOAT                     :: 0x140B;
+MAP_READ_BIT                   :: 0x0001;
+MAP_WRITE_BIT                  :: 0x0002;
+MAP_INVALIDATE_RANGE_BIT       :: 0x0004;
+MAP_INVALIDATE_BUFFER_BIT      :: 0x0008;
+MAP_FLUSH_EXPLICIT_BIT         :: 0x0010;
+MAP_UNSYNCHRONIZED_BIT         :: 0x0020;
+COMPRESSED_RED_RGTC1           :: 0x8DBB;
+COMPRESSED_SIGNED_RED_RGTC1    :: 0x8DBC;
+COMPRESSED_RG_RGTC2            :: 0x8DBD;
+COMPRESSED_SIGNED_RG_RGTC2     :: 0x8DBE;
+RG                             :: 0x8227;
+RG_INTEGER                     :: 0x8228;
+R8                             :: 0x8229;
+R16                            :: 0x822A;
+RG8                            :: 0x822B;
+RG16                           :: 0x822C;
+R16F                           :: 0x822D;
+R32F                           :: 0x822E;
+RG16F                          :: 0x822F;
+RG32F                          :: 0x8230;
+R8I                            :: 0x8231;
+R8UI                           :: 0x8232;
+R16I                           :: 0x8233;
+R16UI                          :: 0x8234;
+R32I                           :: 0x8235;
+R32UI                          :: 0x8236;
+RG8I                           :: 0x8237;
+RG8UI                          :: 0x8238;
+RG16I                          :: 0x8239;
+RG16UI                         :: 0x823A;
+RG32I                          :: 0x823B;
+RG32UI                         :: 0x823C;
+VERTEX_ARRAY_BINDING           :: 0x85B5;
 
-SAMPLER_2D_RECT                :: 0x8B63
-SAMPLER_2D_RECT_SHADOW         :: 0x8B64
-SAMPLER_BUFFER                 :: 0x8DC2
-INT_SAMPLER_2D_RECT            :: 0x8DCD
-INT_SAMPLER_BUFFER             :: 0x8DD0
-UNSIGNED_INT_SAMPLER_2D_RECT   :: 0x8DD5
-UNSIGNED_INT_SAMPLER_BUFFER    :: 0x8DD8
-TEXTURE_BUFFER                 :: 0x8C2A
-MAX_TEXTURE_BUFFER_SIZE        :: 0x8C2B
-TEXTURE_BINDING_BUFFER         :: 0x8C2C
-TEXTURE_BUFFER_DATA_STORE_BINDING :: 0x8C2D
-TEXTURE_RECTANGLE              :: 0x84F5
-TEXTURE_BINDING_RECTANGLE      :: 0x84F6
-PROXY_TEXTURE_RECTANGLE        :: 0x84F7
-MAX_RECTANGLE_TEXTURE_SIZE     :: 0x84F8
-R8_SNORM                       :: 0x8F94
-RG8_SNORM                      :: 0x8F95
-RGB8_SNORM                     :: 0x8F96
-RGBA8_SNORM                    :: 0x8F97
-R16_SNORM                      :: 0x8F98
-RG16_SNORM                     :: 0x8F99
-RGB16_SNORM                    :: 0x8F9A
-RGBA16_SNORM                   :: 0x8F9B
-SIGNED_NORMALIZED              :: 0x8F9C
-PRIMITIVE_RESTART              :: 0x8F9D
-PRIMITIVE_RESTART_INDEX        :: 0x8F9E
-COPY_READ_BUFFER               :: 0x8F36
-COPY_WRITE_BUFFER              :: 0x8F37
-UNIFORM_BUFFER                 :: 0x8A11
-UNIFORM_BUFFER_BINDING         :: 0x8A28
-UNIFORM_BUFFER_START           :: 0x8A29
-UNIFORM_BUFFER_SIZE            :: 0x8A2A
-MAX_VERTEX_UNIFORM_BLOCKS      :: 0x8A2B
-MAX_GEOMETRY_UNIFORM_BLOCKS    :: 0x8A2C
-MAX_FRAGMENT_UNIFORM_BLOCKS    :: 0x8A2D
-MAX_COMBINED_UNIFORM_BLOCKS    :: 0x8A2E
-MAX_UNIFORM_BUFFER_BINDINGS    :: 0x8A2F
-MAX_UNIFORM_BLOCK_SIZE         :: 0x8A30
-MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS :: 0x8A31
-MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS :: 0x8A32
-MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS :: 0x8A33
-UNIFORM_BUFFER_OFFSET_ALIGNMENT :: 0x8A34
-ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH :: 0x8A35
-ACTIVE_UNIFORM_BLOCKS          :: 0x8A36
-UNIFORM_TYPE                   :: 0x8A37
-UNIFORM_SIZE                   :: 0x8A38
-UNIFORM_NAME_LENGTH            :: 0x8A39
-UNIFORM_BLOCK_INDEX            :: 0x8A3A
-UNIFORM_OFFSET                 :: 0x8A3B
-UNIFORM_ARRAY_STRIDE           :: 0x8A3C
-UNIFORM_MATRIX_STRIDE          :: 0x8A3D
-UNIFORM_IS_ROW_MAJOR           :: 0x8A3E
-UNIFORM_BLOCK_BINDING          :: 0x8A3F
-UNIFORM_BLOCK_DATA_SIZE        :: 0x8A40
-UNIFORM_BLOCK_NAME_LENGTH      :: 0x8A41
-UNIFORM_BLOCK_ACTIVE_UNIFORMS  :: 0x8A42
-UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES :: 0x8A43
-UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER :: 0x8A44
-UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER :: 0x8A45
-UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER :: 0x8A46
-INVALID_INDEX                  :: 0xFFFFFFFF
+SAMPLER_2D_RECT                :: 0x8B63;
+SAMPLER_2D_RECT_SHADOW         :: 0x8B64;
+SAMPLER_BUFFER                 :: 0x8DC2;
+INT_SAMPLER_2D_RECT            :: 0x8DCD;
+INT_SAMPLER_BUFFER             :: 0x8DD0;
+UNSIGNED_INT_SAMPLER_2D_RECT   :: 0x8DD5;
+UNSIGNED_INT_SAMPLER_BUFFER    :: 0x8DD8;
+TEXTURE_BUFFER                 :: 0x8C2A;
+MAX_TEXTURE_BUFFER_SIZE        :: 0x8C2B;
+TEXTURE_BINDING_BUFFER         :: 0x8C2C;
+TEXTURE_BUFFER_DATA_STORE_BINDING :: 0x8C2D;
+TEXTURE_RECTANGLE              :: 0x84F5;
+TEXTURE_BINDING_RECTANGLE      :: 0x84F6;
+PROXY_TEXTURE_RECTANGLE        :: 0x84F7;
+MAX_RECTANGLE_TEXTURE_SIZE     :: 0x84F8;
+R8_SNORM                       :: 0x8F94;
+RG8_SNORM                      :: 0x8F95;
+RGB8_SNORM                     :: 0x8F96;
+RGBA8_SNORM                    :: 0x8F97;
+R16_SNORM                      :: 0x8F98;
+RG16_SNORM                     :: 0x8F99;
+RGB16_SNORM                    :: 0x8F9A;
+RGBA16_SNORM                   :: 0x8F9B;
+SIGNED_NORMALIZED              :: 0x8F9C;
+PRIMITIVE_RESTART              :: 0x8F9D;
+PRIMITIVE_RESTART_INDEX        :: 0x8F9E;
+COPY_READ_BUFFER               :: 0x8F36;
+COPY_WRITE_BUFFER              :: 0x8F37;
+UNIFORM_BUFFER                 :: 0x8A11;
+UNIFORM_BUFFER_BINDING         :: 0x8A28;
+UNIFORM_BUFFER_START           :: 0x8A29;
+UNIFORM_BUFFER_SIZE            :: 0x8A2A;
+MAX_VERTEX_UNIFORM_BLOCKS      :: 0x8A2B;
+MAX_GEOMETRY_UNIFORM_BLOCKS    :: 0x8A2C;
+MAX_FRAGMENT_UNIFORM_BLOCKS    :: 0x8A2D;
+MAX_COMBINED_UNIFORM_BLOCKS    :: 0x8A2E;
+MAX_UNIFORM_BUFFER_BINDINGS    :: 0x8A2F;
+MAX_UNIFORM_BLOCK_SIZE         :: 0x8A30;
+MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS :: 0x8A31;
+MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS :: 0x8A32;
+MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS :: 0x8A33;
+UNIFORM_BUFFER_OFFSET_ALIGNMENT :: 0x8A34;
+ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH :: 0x8A35;
+ACTIVE_UNIFORM_BLOCKS          :: 0x8A36;
+UNIFORM_TYPE                   :: 0x8A37;
+UNIFORM_SIZE                   :: 0x8A38;
+UNIFORM_NAME_LENGTH            :: 0x8A39;
+UNIFORM_BLOCK_INDEX            :: 0x8A3A;
+UNIFORM_OFFSET                 :: 0x8A3B;
+UNIFORM_ARRAY_STRIDE           :: 0x8A3C;
+UNIFORM_MATRIX_STRIDE          :: 0x8A3D;
+UNIFORM_IS_ROW_MAJOR           :: 0x8A3E;
+UNIFORM_BLOCK_BINDING          :: 0x8A3F;
+UNIFORM_BLOCK_DATA_SIZE        :: 0x8A40;
+UNIFORM_BLOCK_NAME_LENGTH      :: 0x8A41;
+UNIFORM_BLOCK_ACTIVE_UNIFORMS  :: 0x8A42;
+UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES :: 0x8A43;
+UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER :: 0x8A44;
+UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER :: 0x8A45;
+UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER :: 0x8A46;
+INVALID_INDEX                  :: 0xFFFFFFFF;
 
 
-CONTEXT_CORE_PROFILE_BIT       :: 0x00000001
-CONTEXT_COMPATIBILITY_PROFILE_BIT :: 0x00000002
-LINES_ADJACENCY                :: 0x000A
-LINE_STRIP_ADJACENCY           :: 0x000B
-TRIANGLES_ADJACENCY            :: 0x000C
-TRIANGLE_STRIP_ADJACENCY       :: 0x000D
-PROGRAM_POINT_SIZE             :: 0x8642
-MAX_GEOMETRY_TEXTURE_IMAGE_UNITS :: 0x8C29
-FRAMEBUFFER_ATTACHMENT_LAYERED :: 0x8DA7
-FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS :: 0x8DA8
-GEOMETRY_SHADER                :: 0x8DD9
-GEOMETRY_VERTICES_OUT          :: 0x8916
-GEOMETRY_INPUT_TYPE            :: 0x8917
-GEOMETRY_OUTPUT_TYPE           :: 0x8918
-MAX_GEOMETRY_UNIFORM_COMPONENTS :: 0x8DDF
-MAX_GEOMETRY_OUTPUT_VERTICES   :: 0x8DE0
-MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS :: 0x8DE1
-MAX_VERTEX_OUTPUT_COMPONENTS   :: 0x9122
-MAX_GEOMETRY_INPUT_COMPONENTS  :: 0x9123
-MAX_GEOMETRY_OUTPUT_COMPONENTS :: 0x9124
-MAX_FRAGMENT_INPUT_COMPONENTS  :: 0x9125
-CONTEXT_PROFILE_MASK           :: 0x9126
-DEPTH_CLAMP                    :: 0x864F
-QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION :: 0x8E4C
-FIRST_VERTEX_CONVENTION        :: 0x8E4D
-LAST_VERTEX_CONVENTION         :: 0x8E4E
-PROVOKING_VERTEX               :: 0x8E4F
-TEXTURE_CUBE_MAP_SEAMLESS      :: 0x884F
-MAX_SERVER_WAIT_TIMEOUT        :: 0x9111
-OBJECT_TYPE                    :: 0x9112
-SYNC_CONDITION                 :: 0x9113
-SYNC_STATUS                    :: 0x9114
-SYNC_FLAGS                     :: 0x9115
-SYNC_FENCE                     :: 0x9116
-SYNC_GPU_COMMANDS_COMPLETE     :: 0x9117
-UNSIGNALED                     :: 0x9118
-SIGNALED                       :: 0x9119
-ALREADY_SIGNALED               :: 0x911A
-TIMEOUT_EXPIRED                :: 0x911B
-CONDITION_SATISFIED            :: 0x911C
-WAIT_FAILED                    :: 0x911D
-TIMEOUT_IGNORED                :: 0xFFFFFFFFFFFFFFFF
-SYNC_FLUSH_COMMANDS_BIT        :: 0x00000001
-SAMPLE_POSITION                :: 0x8E50
-SAMPLE_MASK                    :: 0x8E51
-SAMPLE_MASK_VALUE              :: 0x8E52
-MAX_SAMPLE_MASK_WORDS          :: 0x8E59
-TEXTURE_2D_MULTISAMPLE         :: 0x9100
-PROXY_TEXTURE_2D_MULTISAMPLE   :: 0x9101
-TEXTURE_2D_MULTISAMPLE_ARRAY   :: 0x9102
-PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY :: 0x9103
-TEXTURE_BINDING_2D_MULTISAMPLE :: 0x9104
-TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY :: 0x9105
-TEXTURE_SAMPLES                :: 0x9106
-TEXTURE_FIXED_SAMPLE_LOCATIONS :: 0x9107
-SAMPLER_2D_MULTISAMPLE         :: 0x9108
-INT_SAMPLER_2D_MULTISAMPLE     :: 0x9109
-UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE :: 0x910A
-SAMPLER_2D_MULTISAMPLE_ARRAY   :: 0x910B
-INT_SAMPLER_2D_MULTISAMPLE_ARRAY :: 0x910C
-UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY :: 0x910D
-MAX_COLOR_TEXTURE_SAMPLES      :: 0x910E
-MAX_DEPTH_TEXTURE_SAMPLES      :: 0x910F
-MAX_INTEGER_SAMPLES            :: 0x9110
+CONTEXT_CORE_PROFILE_BIT       :: 0x00000001;
+CONTEXT_COMPATIBILITY_PROFILE_BIT :: 0x00000002;
+LINES_ADJACENCY                :: 0x000A;
+LINE_STRIP_ADJACENCY           :: 0x000B;
+TRIANGLES_ADJACENCY            :: 0x000C;
+TRIANGLE_STRIP_ADJACENCY       :: 0x000D;
+PROGRAM_POINT_SIZE             :: 0x8642;
+MAX_GEOMETRY_TEXTURE_IMAGE_UNITS :: 0x8C29;
+FRAMEBUFFER_ATTACHMENT_LAYERED :: 0x8DA7;
+FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS :: 0x8DA8;
+GEOMETRY_SHADER                :: 0x8DD9;
+GEOMETRY_VERTICES_OUT          :: 0x8916;
+GEOMETRY_INPUT_TYPE            :: 0x8917;
+GEOMETRY_OUTPUT_TYPE           :: 0x8918;
+MAX_GEOMETRY_UNIFORM_COMPONENTS :: 0x8DDF;
+MAX_GEOMETRY_OUTPUT_VERTICES   :: 0x8DE0;
+MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS :: 0x8DE1;
+MAX_VERTEX_OUTPUT_COMPONENTS   :: 0x9122;
+MAX_GEOMETRY_INPUT_COMPONENTS  :: 0x9123;
+MAX_GEOMETRY_OUTPUT_COMPONENTS :: 0x9124;
+MAX_FRAGMENT_INPUT_COMPONENTS  :: 0x9125;
+CONTEXT_PROFILE_MASK           :: 0x9126;
+DEPTH_CLAMP                    :: 0x864F;
+QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION :: 0x8E4C;
+FIRST_VERTEX_CONVENTION        :: 0x8E4D;
+LAST_VERTEX_CONVENTION         :: 0x8E4E;
+PROVOKING_VERTEX               :: 0x8E4F;
+TEXTURE_CUBE_MAP_SEAMLESS      :: 0x884F;
+MAX_SERVER_WAIT_TIMEOUT        :: 0x9111;
+OBJECT_TYPE                    :: 0x9112;
+SYNC_CONDITION                 :: 0x9113;
+SYNC_STATUS                    :: 0x9114;
+SYNC_FLAGS                     :: 0x9115;
+SYNC_FENCE                     :: 0x9116;
+SYNC_GPU_COMMANDS_COMPLETE     :: 0x9117;
+UNSIGNALED                     :: 0x9118;
+SIGNALED                       :: 0x9119;
+ALREADY_SIGNALED               :: 0x911A;
+TIMEOUT_EXPIRED                :: 0x911B;
+CONDITION_SATISFIED            :: 0x911C;
+WAIT_FAILED                    :: 0x911D;
+TIMEOUT_IGNORED                :: 0xFFFFFFFFFFFFFFFF;
+SYNC_FLUSH_COMMANDS_BIT        :: 0x00000001;
+SAMPLE_POSITION                :: 0x8E50;
+SAMPLE_MASK                    :: 0x8E51;
+SAMPLE_MASK_VALUE              :: 0x8E52;
+MAX_SAMPLE_MASK_WORDS          :: 0x8E59;
+TEXTURE_2D_MULTISAMPLE         :: 0x9100;
+PROXY_TEXTURE_2D_MULTISAMPLE   :: 0x9101;
+TEXTURE_2D_MULTISAMPLE_ARRAY   :: 0x9102;
+PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY :: 0x9103;
+TEXTURE_BINDING_2D_MULTISAMPLE :: 0x9104;
+TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY :: 0x9105;
+TEXTURE_SAMPLES                :: 0x9106;
+TEXTURE_FIXED_SAMPLE_LOCATIONS :: 0x9107;
+SAMPLER_2D_MULTISAMPLE         :: 0x9108;
+INT_SAMPLER_2D_MULTISAMPLE     :: 0x9109;
+UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE :: 0x910A;
+SAMPLER_2D_MULTISAMPLE_ARRAY   :: 0x910B;
+INT_SAMPLER_2D_MULTISAMPLE_ARRAY :: 0x910C;
+UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY :: 0x910D;
+MAX_COLOR_TEXTURE_SAMPLES      :: 0x910E;
+MAX_DEPTH_TEXTURE_SAMPLES      :: 0x910F;
+MAX_INTEGER_SAMPLES            :: 0x9110;
 
-VERTEX_ATTRIB_ARRAY_DIVISOR    :: 0x88FE
-SRC1_COLOR                     :: 0x88F9
-ONE_MINUS_SRC1_COLOR           :: 0x88FA
-ONE_MINUS_SRC1_ALPHA           :: 0x88FB
-MAX_DUAL_SOURCE_DRAW_BUFFERS   :: 0x88FC
-ANY_SAMPLES_PASSED             :: 0x8C2F
-SAMPLER_BINDING                :: 0x8919
-RGB10_A2UI                     :: 0x906F
-TEXTURE_SWIZZLE_R              :: 0x8E42
-TEXTURE_SWIZZLE_G              :: 0x8E43
-TEXTURE_SWIZZLE_B              :: 0x8E44
-TEXTURE_SWIZZLE_A              :: 0x8E45
-TEXTURE_SWIZZLE_RGBA           :: 0x8E46
-TIME_ELAPSED                   :: 0x88BF
-TIMESTAMP                      :: 0x8E28
-INT_2_10_10_10_REV             :: 0x8D9F
+VERTEX_ATTRIB_ARRAY_DIVISOR    :: 0x88FE;
+SRC1_COLOR                     :: 0x88F9;
+ONE_MINUS_SRC1_COLOR           :: 0x88FA;
+ONE_MINUS_SRC1_ALPHA           :: 0x88FB;
+MAX_DUAL_SOURCE_DRAW_BUFFERS   :: 0x88FC;
+ANY_SAMPLES_PASSED             :: 0x8C2F;
+SAMPLER_BINDING                :: 0x8919;
+RGB10_A2UI                     :: 0x906F;
+TEXTURE_SWIZZLE_R              :: 0x8E42;
+TEXTURE_SWIZZLE_G              :: 0x8E43;
+TEXTURE_SWIZZLE_B              :: 0x8E44;
+TEXTURE_SWIZZLE_A              :: 0x8E45;
+TEXTURE_SWIZZLE_RGBA           :: 0x8E46;
+TIME_ELAPSED                   :: 0x88BF;
+TIMESTAMP                      :: 0x8E28;
+INT_2_10_10_10_REV             :: 0x8D9F;
 
-SAMPLE_SHADING                 :: 0x8C36
-MIN_SAMPLE_SHADING_VALUE       :: 0x8C37
-MIN_PROGRAM_TEXTURE_GATHER_OFFSET :: 0x8E5E
-MAX_PROGRAM_TEXTURE_GATHER_OFFSET :: 0x8E5F
-TEXTURE_CUBE_MAP_ARRAY         :: 0x9009
-TEXTURE_BINDING_CUBE_MAP_ARRAY :: 0x900A
-PROXY_TEXTURE_CUBE_MAP_ARRAY   :: 0x900B
-SAMPLER_CUBE_MAP_ARRAY         :: 0x900C
-SAMPLER_CUBE_MAP_ARRAY_SHADOW  :: 0x900D
-INT_SAMPLER_CUBE_MAP_ARRAY     :: 0x900E
-UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY :: 0x900F
-DRAW_INDIRECT_BUFFER           :: 0x8F3F
-DRAW_INDIRECT_BUFFER_BINDING   :: 0x8F43
-GEOMETRY_SHADER_INVOCATIONS    :: 0x887F
-MAX_GEOMETRY_SHADER_INVOCATIONS :: 0x8E5A
-MIN_FRAGMENT_INTERPOLATION_OFFSET :: 0x8E5B
-MAX_FRAGMENT_INTERPOLATION_OFFSET :: 0x8E5C
-FRAGMENT_INTERPOLATION_OFFSET_BITS :: 0x8E5D
-MAX_VERTEX_STREAMS             :: 0x8E71
-DOUBLE_VEC2                    :: 0x8FFC
-DOUBLE_VEC3                    :: 0x8FFD
-DOUBLE_VEC4                    :: 0x8FFE
-DOUBLE_MAT2                    :: 0x8F46
-DOUBLE_MAT3                    :: 0x8F47
-DOUBLE_MAT4                    :: 0x8F48
-DOUBLE_MAT2x3                  :: 0x8F49
-DOUBLE_MAT2x4                  :: 0x8F4A
-DOUBLE_MAT3x2                  :: 0x8F4B
-DOUBLE_MAT3x4                  :: 0x8F4C
-DOUBLE_MAT4x2                  :: 0x8F4D
-DOUBLE_MAT4x3                  :: 0x8F4E
-ACTIVE_SUBROUTINES             :: 0x8DE5
-ACTIVE_SUBROUTINE_UNIFORMS     :: 0x8DE6
-ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS :: 0x8E47
-ACTIVE_SUBROUTINE_MAX_LENGTH   :: 0x8E48
-ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH :: 0x8E49
-MAX_SUBROUTINES                :: 0x8DE7
-MAX_SUBROUTINE_UNIFORM_LOCATIONS :: 0x8DE8
-NUM_COMPATIBLE_SUBROUTINES     :: 0x8E4A
-COMPATIBLE_SUBROUTINES         :: 0x8E4B
-PATCHES                        :: 0x000E
-PATCH_VERTICES                 :: 0x8E72
-PATCH_DEFAULT_INNER_LEVEL      :: 0x8E73
-PATCH_DEFAULT_OUTER_LEVEL      :: 0x8E74
-TESS_CONTROL_OUTPUT_VERTICES   :: 0x8E75
-TESS_GEN_MODE                  :: 0x8E76
-TESS_GEN_SPACING               :: 0x8E77
-TESS_GEN_VERTEX_ORDER          :: 0x8E78
-TESS_GEN_POINT_MODE            :: 0x8E79
-ISOLINES                       :: 0x8E7A
-FRACTIONAL_ODD                 :: 0x8E7B
-FRACTIONAL_EVEN                :: 0x8E7C
-MAX_PATCH_VERTICES             :: 0x8E7D
-MAX_TESS_GEN_LEVEL             :: 0x8E7E
-MAX_TESS_CONTROL_UNIFORM_COMPONENTS :: 0x8E7F
-MAX_TESS_EVALUATION_UNIFORM_COMPONENTS :: 0x8E80
-MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS :: 0x8E81
-MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS :: 0x8E82
-MAX_TESS_CONTROL_OUTPUT_COMPONENTS :: 0x8E83
-MAX_TESS_PATCH_COMPONENTS      :: 0x8E84
-MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS :: 0x8E85
-MAX_TESS_EVALUATION_OUTPUT_COMPONENTS :: 0x8E86
-MAX_TESS_CONTROL_UNIFORM_BLOCKS :: 0x8E89
-MAX_TESS_EVALUATION_UNIFORM_BLOCKS :: 0x8E8A
-MAX_TESS_CONTROL_INPUT_COMPONENTS :: 0x886C
-MAX_TESS_EVALUATION_INPUT_COMPONENTS :: 0x886D
-MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS :: 0x8E1E
-MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS :: 0x8E1F
-UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER :: 0x84F0
-UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER :: 0x84F1
-TESS_EVALUATION_SHADER         :: 0x8E87
-TESS_CONTROL_SHADER            :: 0x8E88
-TRANSFORM_FEEDBACK             :: 0x8E22
-TRANSFORM_FEEDBACK_BUFFER_PAUSED :: 0x8E23
-TRANSFORM_FEEDBACK_BUFFER_ACTIVE :: 0x8E24
-TRANSFORM_FEEDBACK_BINDING     :: 0x8E25
-MAX_TRANSFORM_FEEDBACK_BUFFERS :: 0x8E70
+SAMPLE_SHADING                 :: 0x8C36;
+MIN_SAMPLE_SHADING_VALUE       :: 0x8C37;
+MIN_PROGRAM_TEXTURE_GATHER_OFFSET :: 0x8E5E;
+MAX_PROGRAM_TEXTURE_GATHER_OFFSET :: 0x8E5F;
+TEXTURE_CUBE_MAP_ARRAY         :: 0x9009;
+TEXTURE_BINDING_CUBE_MAP_ARRAY :: 0x900A;
+PROXY_TEXTURE_CUBE_MAP_ARRAY   :: 0x900B;
+SAMPLER_CUBE_MAP_ARRAY         :: 0x900C;
+SAMPLER_CUBE_MAP_ARRAY_SHADOW  :: 0x900D;
+INT_SAMPLER_CUBE_MAP_ARRAY     :: 0x900E;
+UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY :: 0x900F;
+DRAW_INDIRECT_BUFFER           :: 0x8F3F;
+DRAW_INDIRECT_BUFFER_BINDING   :: 0x8F43;
+GEOMETRY_SHADER_INVOCATIONS    :: 0x887F;
+MAX_GEOMETRY_SHADER_INVOCATIONS :: 0x8E5A;
+MIN_FRAGMENT_INTERPOLATION_OFFSET :: 0x8E5B;
+MAX_FRAGMENT_INTERPOLATION_OFFSET :: 0x8E5C;
+FRAGMENT_INTERPOLATION_OFFSET_BITS :: 0x8E5D;
+MAX_VERTEX_STREAMS             :: 0x8E71;
+DOUBLE_VEC2                    :: 0x8FFC;
+DOUBLE_VEC3                    :: 0x8FFD;
+DOUBLE_VEC4                    :: 0x8FFE;
+DOUBLE_MAT2                    :: 0x8F46;
+DOUBLE_MAT3                    :: 0x8F47;
+DOUBLE_MAT4                    :: 0x8F48;
+DOUBLE_MAT2x3                  :: 0x8F49;
+DOUBLE_MAT2x4                  :: 0x8F4A;
+DOUBLE_MAT3x2                  :: 0x8F4B;
+DOUBLE_MAT3x4                  :: 0x8F4C;
+DOUBLE_MAT4x2                  :: 0x8F4D;
+DOUBLE_MAT4x3                  :: 0x8F4E;
+ACTIVE_SUBROUTINES             :: 0x8DE5;
+ACTIVE_SUBROUTINE_UNIFORMS     :: 0x8DE6;
+ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS :: 0x8E47;
+ACTIVE_SUBROUTINE_MAX_LENGTH   :: 0x8E48;
+ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH :: 0x8E49;
+MAX_SUBROUTINES                :: 0x8DE7;
+MAX_SUBROUTINE_UNIFORM_LOCATIONS :: 0x8DE8;
+NUM_COMPATIBLE_SUBROUTINES     :: 0x8E4A;
+COMPATIBLE_SUBROUTINES         :: 0x8E4B;
+PATCHES                        :: 0x000E;
+PATCH_VERTICES                 :: 0x8E72;
+PATCH_DEFAULT_INNER_LEVEL      :: 0x8E73;
+PATCH_DEFAULT_OUTER_LEVEL      :: 0x8E74;
+TESS_CONTROL_OUTPUT_VERTICES   :: 0x8E75;
+TESS_GEN_MODE                  :: 0x8E76;
+TESS_GEN_SPACING               :: 0x8E77;
+TESS_GEN_VERTEX_ORDER          :: 0x8E78;
+TESS_GEN_POINT_MODE            :: 0x8E79;
+ISOLINES                       :: 0x8E7A;
+FRACTIONAL_ODD                 :: 0x8E7B;
+FRACTIONAL_EVEN                :: 0x8E7C;
+MAX_PATCH_VERTICES             :: 0x8E7D;
+MAX_TESS_GEN_LEVEL             :: 0x8E7E;
+MAX_TESS_CONTROL_UNIFORM_COMPONENTS :: 0x8E7F;
+MAX_TESS_EVALUATION_UNIFORM_COMPONENTS :: 0x8E80;
+MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS :: 0x8E81;
+MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS :: 0x8E82;
+MAX_TESS_CONTROL_OUTPUT_COMPONENTS :: 0x8E83;
+MAX_TESS_PATCH_COMPONENTS      :: 0x8E84;
+MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS :: 0x8E85;
+MAX_TESS_EVALUATION_OUTPUT_COMPONENTS :: 0x8E86;
+MAX_TESS_CONTROL_UNIFORM_BLOCKS :: 0x8E89;
+MAX_TESS_EVALUATION_UNIFORM_BLOCKS :: 0x8E8A;
+MAX_TESS_CONTROL_INPUT_COMPONENTS :: 0x886C;
+MAX_TESS_EVALUATION_INPUT_COMPONENTS :: 0x886D;
+MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS :: 0x8E1E;
+MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS :: 0x8E1F;
+UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER :: 0x84F0;
+UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER :: 0x84F1;
+TESS_EVALUATION_SHADER         :: 0x8E87;
+TESS_CONTROL_SHADER            :: 0x8E88;
+TRANSFORM_FEEDBACK             :: 0x8E22;
+TRANSFORM_FEEDBACK_BUFFER_PAUSED :: 0x8E23;
+TRANSFORM_FEEDBACK_BUFFER_ACTIVE :: 0x8E24;
+TRANSFORM_FEEDBACK_BINDING     :: 0x8E25;
+MAX_TRANSFORM_FEEDBACK_BUFFERS :: 0x8E70;
 
-FIXED                          :: 0x140C
-IMPLEMENTATION_COLOR_READ_TYPE :: 0x8B9A
-IMPLEMENTATION_COLOR_READ_FORMAT :: 0x8B9B
-LOW_FLOAT                      :: 0x8DF0
-MEDIUM_FLOAT                   :: 0x8DF1
-HIGH_FLOAT                     :: 0x8DF2
-LOW_INT                        :: 0x8DF3
-MEDIUM_INT                     :: 0x8DF4
-HIGH_INT                       :: 0x8DF5
-SHADER_COMPILER                :: 0x8DFA
-SHADER_BINARY_FORMATS          :: 0x8DF8
-NUM_SHADER_BINARY_FORMATS      :: 0x8DF9
-MAX_VERTEX_UNIFORM_VECTORS     :: 0x8DFB
-MAX_VARYING_VECTORS            :: 0x8DFC
-MAX_FRAGMENT_UNIFORM_VECTORS   :: 0x8DFD
-RGB565                         :: 0x8D62
-PROGRAM_BINARY_RETRIEVABLE_HINT :: 0x8257
-PROGRAM_BINARY_LENGTH          :: 0x8741
-NUM_PROGRAM_BINARY_FORMATS     :: 0x87FE
-PROGRAM_BINARY_FORMATS         :: 0x87FF
-VERTEX_SHADER_BIT              :: 0x00000001
-FRAGMENT_SHADER_BIT            :: 0x00000002
-GEOMETRY_SHADER_BIT            :: 0x00000004
-TESS_CONTROL_SHADER_BIT        :: 0x00000008
-TESS_EVALUATION_SHADER_BIT     :: 0x00000010
-ALL_SHADER_BITS                :: 0xFFFFFFFF
-PROGRAM_SEPARABLE              :: 0x8258
-ACTIVE_PROGRAM                 :: 0x8259
-PROGRAM_PIPELINE_BINDING       :: 0x825A
-MAX_VIEWPORTS                  :: 0x825B
-VIEWPORT_SUBPIXEL_BITS         :: 0x825C
-VIEWPORT_BOUNDS_RANGE          :: 0x825D
-LAYER_PROVOKING_VERTEX         :: 0x825E
-VIEWPORT_INDEX_PROVOKING_VERTEX :: 0x825F
-UNDEFINED_VERTEX               :: 0x8260
+FIXED                          :: 0x140C;
+IMPLEMENTATION_COLOR_READ_TYPE :: 0x8B9A;
+IMPLEMENTATION_COLOR_READ_FORMAT :: 0x8B9B;
+LOW_FLOAT                      :: 0x8DF0;
+MEDIUM_FLOAT                   :: 0x8DF1;
+HIGH_FLOAT                     :: 0x8DF2;
+LOW_INT                        :: 0x8DF3;
+MEDIUM_INT                     :: 0x8DF4;
+HIGH_INT                       :: 0x8DF5;
+SHADER_COMPILER                :: 0x8DFA;
+SHADER_BINARY_FORMATS          :: 0x8DF8;
+NUM_SHADER_BINARY_FORMATS      :: 0x8DF9;
+MAX_VERTEX_UNIFORM_VECTORS     :: 0x8DFB;
+MAX_VARYING_VECTORS            :: 0x8DFC;
+MAX_FRAGMENT_UNIFORM_VECTORS   :: 0x8DFD;
+RGB565                         :: 0x8D62;
+PROGRAM_BINARY_RETRIEVABLE_HINT :: 0x8257;
+PROGRAM_BINARY_LENGTH          :: 0x8741;
+NUM_PROGRAM_BINARY_FORMATS     :: 0x87FE;
+PROGRAM_BINARY_FORMATS         :: 0x87FF;
+VERTEX_SHADER_BIT              :: 0x00000001;
+FRAGMENT_SHADER_BIT            :: 0x00000002;
+GEOMETRY_SHADER_BIT            :: 0x00000004;
+TESS_CONTROL_SHADER_BIT        :: 0x00000008;
+TESS_EVALUATION_SHADER_BIT     :: 0x00000010;
+ALL_SHADER_BITS                :: 0xFFFFFFFF;
+PROGRAM_SEPARABLE              :: 0x8258;
+ACTIVE_PROGRAM                 :: 0x8259;
+PROGRAM_PIPELINE_BINDING       :: 0x825A;
+MAX_VIEWPORTS                  :: 0x825B;
+VIEWPORT_SUBPIXEL_BITS         :: 0x825C;
+VIEWPORT_BOUNDS_RANGE          :: 0x825D;
+LAYER_PROVOKING_VERTEX         :: 0x825E;
+VIEWPORT_INDEX_PROVOKING_VERTEX :: 0x825F;
+UNDEFINED_VERTEX               :: 0x8260;
 
-COPY_READ_BUFFER_BINDING       :: 0x8F36
-COPY_WRITE_BUFFER_BINDING      :: 0x8F37
-TRANSFORM_FEEDBACK_ACTIVE      :: 0x8E24
-TRANSFORM_FEEDBACK_PAUSED      :: 0x8E23
-UNPACK_COMPRESSED_BLOCK_WIDTH  :: 0x9127
-UNPACK_COMPRESSED_BLOCK_HEIGHT :: 0x9128
-UNPACK_COMPRESSED_BLOCK_DEPTH  :: 0x9129
-UNPACK_COMPRESSED_BLOCK_SIZE   :: 0x912A
-PACK_COMPRESSED_BLOCK_WIDTH    :: 0x912B
-PACK_COMPRESSED_BLOCK_HEIGHT   :: 0x912C
-PACK_COMPRESSED_BLOCK_DEPTH    :: 0x912D
-PACK_COMPRESSED_BLOCK_SIZE     :: 0x912E
-NUM_SAMPLE_COUNTS              :: 0x9380
-MIN_MAP_BUFFER_ALIGNMENT       :: 0x90BC
-ATOMIC_COUNTER_BUFFER          :: 0x92C0
-ATOMIC_COUNTER_BUFFER_BINDING  :: 0x92C1
-ATOMIC_COUNTER_BUFFER_START    :: 0x92C2
-ATOMIC_COUNTER_BUFFER_SIZE     :: 0x92C3
-ATOMIC_COUNTER_BUFFER_DATA_SIZE :: 0x92C4
-ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS :: 0x92C5
-ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES :: 0x92C6
-ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER :: 0x92C7
-ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER :: 0x92C8
-ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER :: 0x92C9
-ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER :: 0x92CA
-ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER :: 0x92CB
-MAX_VERTEX_ATOMIC_COUNTER_BUFFERS :: 0x92CC
-MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS :: 0x92CD
-MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS :: 0x92CE
-MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS :: 0x92CF
-MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS :: 0x92D0
-MAX_COMBINED_ATOMIC_COUNTER_BUFFERS :: 0x92D1
-MAX_VERTEX_ATOMIC_COUNTERS     :: 0x92D2
-MAX_TESS_CONTROL_ATOMIC_COUNTERS :: 0x92D3
-MAX_TESS_EVALUATION_ATOMIC_COUNTERS :: 0x92D4
-MAX_GEOMETRY_ATOMIC_COUNTERS   :: 0x92D5
-MAX_FRAGMENT_ATOMIC_COUNTERS   :: 0x92D6
-MAX_COMBINED_ATOMIC_COUNTERS   :: 0x92D7
-MAX_ATOMIC_COUNTER_BUFFER_SIZE :: 0x92D8
-MAX_ATOMIC_COUNTER_BUFFER_BINDINGS :: 0x92DC
-ACTIVE_ATOMIC_COUNTER_BUFFERS  :: 0x92D9
-UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX :: 0x92DA
-UNSIGNED_INT_ATOMIC_COUNTER    :: 0x92DB
-VERTEX_ATTRIB_ARRAY_BARRIER_BIT :: 0x00000001
-ELEMENT_ARRAY_BARRIER_BIT      :: 0x00000002
-UNIFORM_BARRIER_BIT            :: 0x00000004
-TEXTURE_FETCH_BARRIER_BIT      :: 0x00000008
-SHADER_IMAGE_ACCESS_BARRIER_BIT :: 0x00000020
-COMMAND_BARRIER_BIT            :: 0x00000040
-PIXEL_BUFFER_BARRIER_BIT       :: 0x00000080
-TEXTURE_UPDATE_BARRIER_BIT     :: 0x00000100
-BUFFER_UPDATE_BARRIER_BIT      :: 0x00000200
-FRAMEBUFFER_BARRIER_BIT        :: 0x00000400
-TRANSFORM_FEEDBACK_BARRIER_BIT :: 0x00000800
-ATOMIC_COUNTER_BARRIER_BIT     :: 0x00001000
-ALL_BARRIER_BITS               :: 0xFFFFFFFF
-MAX_IMAGE_UNITS                :: 0x8F38
-MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS :: 0x8F39
-IMAGE_BINDING_NAME             :: 0x8F3A
-IMAGE_BINDING_LEVEL            :: 0x8F3B
-IMAGE_BINDING_LAYERED          :: 0x8F3C
-IMAGE_BINDING_LAYER            :: 0x8F3D
-IMAGE_BINDING_ACCESS           :: 0x8F3E
-IMAGE_1D                       :: 0x904C
-IMAGE_2D                       :: 0x904D
-IMAGE_3D                       :: 0x904E
-IMAGE_2D_RECT                  :: 0x904F
-IMAGE_CUBE                     :: 0x9050
-IMAGE_BUFFER                   :: 0x9051
-IMAGE_1D_ARRAY                 :: 0x9052
-IMAGE_2D_ARRAY                 :: 0x9053
-IMAGE_CUBE_MAP_ARRAY           :: 0x9054
-IMAGE_2D_MULTISAMPLE           :: 0x9055
-IMAGE_2D_MULTISAMPLE_ARRAY     :: 0x9056
-INT_IMAGE_1D                   :: 0x9057
-INT_IMAGE_2D                   :: 0x9058
-INT_IMAGE_3D                   :: 0x9059
-INT_IMAGE_2D_RECT              :: 0x905A
-INT_IMAGE_CUBE                 :: 0x905B
-INT_IMAGE_BUFFER               :: 0x905C
-INT_IMAGE_1D_ARRAY             :: 0x905D
-INT_IMAGE_2D_ARRAY             :: 0x905E
-INT_IMAGE_CUBE_MAP_ARRAY       :: 0x905F
-INT_IMAGE_2D_MULTISAMPLE       :: 0x9060
-INT_IMAGE_2D_MULTISAMPLE_ARRAY :: 0x9061
-UNSIGNED_INT_IMAGE_1D          :: 0x9062
-UNSIGNED_INT_IMAGE_2D          :: 0x9063
-UNSIGNED_INT_IMAGE_3D          :: 0x9064
-UNSIGNED_INT_IMAGE_2D_RECT     :: 0x9065
-UNSIGNED_INT_IMAGE_CUBE        :: 0x9066
-UNSIGNED_INT_IMAGE_BUFFER      :: 0x9067
-UNSIGNED_INT_IMAGE_1D_ARRAY    :: 0x9068
-UNSIGNED_INT_IMAGE_2D_ARRAY    :: 0x9069
-UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY :: 0x906A
-UNSIGNED_INT_IMAGE_2D_MULTISAMPLE :: 0x906B
-UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY :: 0x906C
-MAX_IMAGE_SAMPLES              :: 0x906D
-IMAGE_BINDING_FORMAT           :: 0x906E
-IMAGE_FORMAT_COMPATIBILITY_TYPE :: 0x90C7
-IMAGE_FORMAT_COMPATIBILITY_BY_SIZE :: 0x90C8
-IMAGE_FORMAT_COMPATIBILITY_BY_CLASS :: 0x90C9
-MAX_VERTEX_IMAGE_UNIFORMS      :: 0x90CA
-MAX_TESS_CONTROL_IMAGE_UNIFORMS :: 0x90CB
-MAX_TESS_EVALUATION_IMAGE_UNIFORMS :: 0x90CC
-MAX_GEOMETRY_IMAGE_UNIFORMS    :: 0x90CD
-MAX_FRAGMENT_IMAGE_UNIFORMS    :: 0x90CE
-MAX_COMBINED_IMAGE_UNIFORMS    :: 0x90CF
-COMPRESSED_RGBA_BPTC_UNORM     :: 0x8E8C
-COMPRESSED_SRGB_ALPHA_BPTC_UNORM :: 0x8E8D
-COMPRESSED_RGB_BPTC_SIGNED_FLOAT :: 0x8E8E
-COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT :: 0x8E8F
-TEXTURE_IMMUTABLE_FORMAT       :: 0x912F
+COPY_READ_BUFFER_BINDING       :: 0x8F36;
+COPY_WRITE_BUFFER_BINDING      :: 0x8F37;
+TRANSFORM_FEEDBACK_ACTIVE      :: 0x8E24;
+TRANSFORM_FEEDBACK_PAUSED      :: 0x8E23;
+UNPACK_COMPRESSED_BLOCK_WIDTH  :: 0x9127;
+UNPACK_COMPRESSED_BLOCK_HEIGHT :: 0x9128;
+UNPACK_COMPRESSED_BLOCK_DEPTH  :: 0x9129;
+UNPACK_COMPRESSED_BLOCK_SIZE   :: 0x912A;
+PACK_COMPRESSED_BLOCK_WIDTH    :: 0x912B;
+PACK_COMPRESSED_BLOCK_HEIGHT   :: 0x912C;
+PACK_COMPRESSED_BLOCK_DEPTH    :: 0x912D;
+PACK_COMPRESSED_BLOCK_SIZE     :: 0x912E;
+NUM_SAMPLE_COUNTS              :: 0x9380;
+MIN_MAP_BUFFER_ALIGNMENT       :: 0x90BC;
+ATOMIC_COUNTER_BUFFER          :: 0x92C0;
+ATOMIC_COUNTER_BUFFER_BINDING  :: 0x92C1;
+ATOMIC_COUNTER_BUFFER_START    :: 0x92C2;
+ATOMIC_COUNTER_BUFFER_SIZE     :: 0x92C3;
+ATOMIC_COUNTER_BUFFER_DATA_SIZE :: 0x92C4;
+ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS :: 0x92C5;
+ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES :: 0x92C6;
+ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER :: 0x92C7;
+ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER :: 0x92C8;
+ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER :: 0x92C9;
+ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER :: 0x92CA;
+ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER :: 0x92CB;
+MAX_VERTEX_ATOMIC_COUNTER_BUFFERS :: 0x92CC;
+MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS :: 0x92CD;
+MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS :: 0x92CE;
+MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS :: 0x92CF;
+MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS :: 0x92D0;
+MAX_COMBINED_ATOMIC_COUNTER_BUFFERS :: 0x92D1;
+MAX_VERTEX_ATOMIC_COUNTERS     :: 0x92D2;
+MAX_TESS_CONTROL_ATOMIC_COUNTERS :: 0x92D3;
+MAX_TESS_EVALUATION_ATOMIC_COUNTERS :: 0x92D4;
+MAX_GEOMETRY_ATOMIC_COUNTERS   :: 0x92D5;
+MAX_FRAGMENT_ATOMIC_COUNTERS   :: 0x92D6;
+MAX_COMBINED_ATOMIC_COUNTERS   :: 0x92D7;
+MAX_ATOMIC_COUNTER_BUFFER_SIZE :: 0x92D8;
+MAX_ATOMIC_COUNTER_BUFFER_BINDINGS :: 0x92DC;
+ACTIVE_ATOMIC_COUNTER_BUFFERS  :: 0x92D9;
+UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX :: 0x92DA;
+UNSIGNED_INT_ATOMIC_COUNTER    :: 0x92DB;
+VERTEX_ATTRIB_ARRAY_BARRIER_BIT :: 0x00000001;
+ELEMENT_ARRAY_BARRIER_BIT      :: 0x00000002;
+UNIFORM_BARRIER_BIT            :: 0x00000004;
+TEXTURE_FETCH_BARRIER_BIT      :: 0x00000008;
+SHADER_IMAGE_ACCESS_BARRIER_BIT :: 0x00000020;
+COMMAND_BARRIER_BIT            :: 0x00000040;
+PIXEL_BUFFER_BARRIER_BIT       :: 0x00000080;
+TEXTURE_UPDATE_BARRIER_BIT     :: 0x00000100;
+BUFFER_UPDATE_BARRIER_BIT      :: 0x00000200;
+FRAMEBUFFER_BARRIER_BIT        :: 0x00000400;
+TRANSFORM_FEEDBACK_BARRIER_BIT :: 0x00000800;
+ATOMIC_COUNTER_BARRIER_BIT     :: 0x00001000;
+ALL_BARRIER_BITS               :: 0xFFFFFFFF;
+MAX_IMAGE_UNITS                :: 0x8F38;
+MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS :: 0x8F39;
+IMAGE_BINDING_NAME             :: 0x8F3A;
+IMAGE_BINDING_LEVEL            :: 0x8F3B;
+IMAGE_BINDING_LAYERED          :: 0x8F3C;
+IMAGE_BINDING_LAYER            :: 0x8F3D;
+IMAGE_BINDING_ACCESS           :: 0x8F3E;
+IMAGE_1D                       :: 0x904C;
+IMAGE_2D                       :: 0x904D;
+IMAGE_3D                       :: 0x904E;
+IMAGE_2D_RECT                  :: 0x904F;
+IMAGE_CUBE                     :: 0x9050;
+IMAGE_BUFFER                   :: 0x9051;
+IMAGE_1D_ARRAY                 :: 0x9052;
+IMAGE_2D_ARRAY                 :: 0x9053;
+IMAGE_CUBE_MAP_ARRAY           :: 0x9054;
+IMAGE_2D_MULTISAMPLE           :: 0x9055;
+IMAGE_2D_MULTISAMPLE_ARRAY     :: 0x9056;
+INT_IMAGE_1D                   :: 0x9057;
+INT_IMAGE_2D                   :: 0x9058;
+INT_IMAGE_3D                   :: 0x9059;
+INT_IMAGE_2D_RECT              :: 0x905A;
+INT_IMAGE_CUBE                 :: 0x905B;
+INT_IMAGE_BUFFER               :: 0x905C;
+INT_IMAGE_1D_ARRAY             :: 0x905D;
+INT_IMAGE_2D_ARRAY             :: 0x905E;
+INT_IMAGE_CUBE_MAP_ARRAY       :: 0x905F;
+INT_IMAGE_2D_MULTISAMPLE       :: 0x9060;
+INT_IMAGE_2D_MULTISAMPLE_ARRAY :: 0x9061;
+UNSIGNED_INT_IMAGE_1D          :: 0x9062;
+UNSIGNED_INT_IMAGE_2D          :: 0x9063;
+UNSIGNED_INT_IMAGE_3D          :: 0x9064;
+UNSIGNED_INT_IMAGE_2D_RECT     :: 0x9065;
+UNSIGNED_INT_IMAGE_CUBE        :: 0x9066;
+UNSIGNED_INT_IMAGE_BUFFER      :: 0x9067;
+UNSIGNED_INT_IMAGE_1D_ARRAY    :: 0x9068;
+UNSIGNED_INT_IMAGE_2D_ARRAY    :: 0x9069;
+UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY :: 0x906A;
+UNSIGNED_INT_IMAGE_2D_MULTISAMPLE :: 0x906B;
+UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY :: 0x906C;
+MAX_IMAGE_SAMPLES              :: 0x906D;
+IMAGE_BINDING_FORMAT           :: 0x906E;
+IMAGE_FORMAT_COMPATIBILITY_TYPE :: 0x90C7;
+IMAGE_FORMAT_COMPATIBILITY_BY_SIZE :: 0x90C8;
+IMAGE_FORMAT_COMPATIBILITY_BY_CLASS :: 0x90C9;
+MAX_VERTEX_IMAGE_UNIFORMS      :: 0x90CA;
+MAX_TESS_CONTROL_IMAGE_UNIFORMS :: 0x90CB;
+MAX_TESS_EVALUATION_IMAGE_UNIFORMS :: 0x90CC;
+MAX_GEOMETRY_IMAGE_UNIFORMS    :: 0x90CD;
+MAX_FRAGMENT_IMAGE_UNIFORMS    :: 0x90CE;
+MAX_COMBINED_IMAGE_UNIFORMS    :: 0x90CF;
+COMPRESSED_RGBA_BPTC_UNORM     :: 0x8E8C;
+COMPRESSED_SRGB_ALPHA_BPTC_UNORM :: 0x8E8D;
+COMPRESSED_RGB_BPTC_SIGNED_FLOAT :: 0x8E8E;
+COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT :: 0x8E8F;
+TEXTURE_IMMUTABLE_FORMAT       :: 0x912F;
 
-NUM_SHADING_LANGUAGE_VERSIONS  :: 0x82E9
-VERTEX_ATTRIB_ARRAY_LONG       :: 0x874E
-COMPRESSED_RGB8_ETC2           :: 0x9274
-COMPRESSED_SRGB8_ETC2          :: 0x9275
-COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 :: 0x9276
-COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 :: 0x9277
-COMPRESSED_RGBA8_ETC2_EAC      :: 0x9278
-COMPRESSED_SRGB8_ALPHA8_ETC2_EAC :: 0x9279
-COMPRESSED_R11_EAC             :: 0x9270
-COMPRESSED_SIGNED_R11_EAC      :: 0x9271
-COMPRESSED_RG11_EAC            :: 0x9272
-COMPRESSED_SIGNED_RG11_EAC     :: 0x9273
-PRIMITIVE_RESTART_FIXED_INDEX  :: 0x8D69
-ANY_SAMPLES_PASSED_CONSERVATIVE :: 0x8D6A
-MAX_ELEMENT_INDEX              :: 0x8D6B
-COMPUTE_SHADER                 :: 0x91B9
-MAX_COMPUTE_UNIFORM_BLOCKS     :: 0x91BB
-MAX_COMPUTE_TEXTURE_IMAGE_UNITS :: 0x91BC
-MAX_COMPUTE_IMAGE_UNIFORMS     :: 0x91BD
-MAX_COMPUTE_SHARED_MEMORY_SIZE :: 0x8262
-MAX_COMPUTE_UNIFORM_COMPONENTS :: 0x8263
-MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS :: 0x8264
-MAX_COMPUTE_ATOMIC_COUNTERS    :: 0x8265
-MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS :: 0x8266
-MAX_COMPUTE_WORK_GROUP_INVOCATIONS :: 0x90EB
-MAX_COMPUTE_WORK_GROUP_COUNT   :: 0x91BE
-MAX_COMPUTE_WORK_GROUP_SIZE    :: 0x91BF
-COMPUTE_WORK_GROUP_SIZE        :: 0x8267
-UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER :: 0x90EC
-ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER :: 0x90ED
-DISPATCH_INDIRECT_BUFFER       :: 0x90EE
-DISPATCH_INDIRECT_BUFFER_BINDING :: 0x90EF
-COMPUTE_SHADER_BIT             :: 0x00000020
-DEBUG_OUTPUT_SYNCHRONOUS       :: 0x8242
-DEBUG_NEXT_LOGGED_MESSAGE_LENGTH :: 0x8243
-DEBUG_CALLBACK_FUNCTION        :: 0x8244
-DEBUG_CALLBACK_USER_PARAM      :: 0x8245
-DEBUG_SOURCE_API               :: 0x8246
-DEBUG_SOURCE_WINDOW_SYSTEM     :: 0x8247
-DEBUG_SOURCE_SHADER_COMPILER   :: 0x8248
-DEBUG_SOURCE_THIRD_PARTY       :: 0x8249
-DEBUG_SOURCE_APPLICATION       :: 0x824A
-DEBUG_SOURCE_OTHER             :: 0x824B
-DEBUG_TYPE_ERROR               :: 0x824C
-DEBUG_TYPE_DEPRECATED_BEHAVIOR :: 0x824D
-DEBUG_TYPE_UNDEFINED_BEHAVIOR  :: 0x824E
-DEBUG_TYPE_PORTABILITY         :: 0x824F
-DEBUG_TYPE_PERFORMANCE         :: 0x8250
-DEBUG_TYPE_OTHER               :: 0x8251
-MAX_DEBUG_MESSAGE_LENGTH       :: 0x9143
-MAX_DEBUG_LOGGED_MESSAGES      :: 0x9144
-DEBUG_LOGGED_MESSAGES          :: 0x9145
-DEBUG_SEVERITY_HIGH            :: 0x9146
-DEBUG_SEVERITY_MEDIUM          :: 0x9147
-DEBUG_SEVERITY_LOW             :: 0x9148
-DEBUG_TYPE_MARKER              :: 0x8268
-DEBUG_TYPE_PUSH_GROUP          :: 0x8269
-DEBUG_TYPE_POP_GROUP           :: 0x826A
-DEBUG_SEVERITY_NOTIFICATION    :: 0x826B
-MAX_DEBUG_GROUP_STACK_DEPTH    :: 0x826C
-DEBUG_GROUP_STACK_DEPTH        :: 0x826D
-BUFFER                         :: 0x82E0
-SHADER                         :: 0x82E1
-PROGRAM                        :: 0x82E2
-QUERY                          :: 0x82E3
-PROGRAM_PIPELINE               :: 0x82E4
-SAMPLER                        :: 0x82E6
-MAX_LABEL_LENGTH               :: 0x82E8
-DEBUG_OUTPUT                   :: 0x92E0
-CONTEXT_FLAG_DEBUG_BIT         :: 0x00000002
-MAX_UNIFORM_LOCATIONS          :: 0x826E
-FRAMEBUFFER_DEFAULT_WIDTH      :: 0x9310
-FRAMEBUFFER_DEFAULT_HEIGHT     :: 0x9311
-FRAMEBUFFER_DEFAULT_LAYERS     :: 0x9312
-FRAMEBUFFER_DEFAULT_SAMPLES    :: 0x9313
-FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS :: 0x9314
-MAX_FRAMEBUFFER_WIDTH          :: 0x9315
-MAX_FRAMEBUFFER_HEIGHT         :: 0x9316
-MAX_FRAMEBUFFER_LAYERS         :: 0x9317
-MAX_FRAMEBUFFER_SAMPLES        :: 0x9318
-INTERNALFORMAT_SUPPORTED       :: 0x826F
-INTERNALFORMAT_PREFERRED       :: 0x8270
-INTERNALFORMAT_RED_SIZE        :: 0x8271
-INTERNALFORMAT_GREEN_SIZE      :: 0x8272
-INTERNALFORMAT_BLUE_SIZE       :: 0x8273
-INTERNALFORMAT_ALPHA_SIZE      :: 0x8274
-INTERNALFORMAT_DEPTH_SIZE      :: 0x8275
-INTERNALFORMAT_STENCIL_SIZE    :: 0x8276
-INTERNALFORMAT_SHARED_SIZE     :: 0x8277
-INTERNALFORMAT_RED_TYPE        :: 0x8278
-INTERNALFORMAT_GREEN_TYPE      :: 0x8279
-INTERNALFORMAT_BLUE_TYPE       :: 0x827A
-INTERNALFORMAT_ALPHA_TYPE      :: 0x827B
-INTERNALFORMAT_DEPTH_TYPE      :: 0x827C
-INTERNALFORMAT_STENCIL_TYPE    :: 0x827D
-MAX_WIDTH                      :: 0x827E
-MAX_HEIGHT                     :: 0x827F
-MAX_DEPTH                      :: 0x8280
-MAX_LAYERS                     :: 0x8281
-MAX_COMBINED_DIMENSIONS        :: 0x8282
-COLOR_COMPONENTS               :: 0x8283
-DEPTH_COMPONENTS               :: 0x8284
-STENCIL_COMPONENTS             :: 0x8285
-COLOR_RENDERABLE               :: 0x8286
-DEPTH_RENDERABLE               :: 0x8287
-STENCIL_RENDERABLE             :: 0x8288
-FRAMEBUFFER_RENDERABLE         :: 0x8289
-FRAMEBUFFER_RENDERABLE_LAYERED :: 0x828A
-FRAMEBUFFER_BLEND              :: 0x828B
-READ_PIXELS                    :: 0x828C
-READ_PIXELS_FORMAT             :: 0x828D
-READ_PIXELS_TYPE               :: 0x828E
-TEXTURE_IMAGE_FORMAT           :: 0x828F
-TEXTURE_IMAGE_TYPE             :: 0x8290
-GET_TEXTURE_IMAGE_FORMAT       :: 0x8291
-GET_TEXTURE_IMAGE_TYPE         :: 0x8292
-MIPMAP                         :: 0x8293
-MANUAL_GENERATE_MIPMAP         :: 0x8294
-AUTO_GENERATE_MIPMAP           :: 0x8295
-COLOR_ENCODING                 :: 0x8296
-SRGB_READ                      :: 0x8297
-SRGB_WRITE                     :: 0x8298
-FILTER                         :: 0x829A
-VERTEX_TEXTURE                 :: 0x829B
-TESS_CONTROL_TEXTURE           :: 0x829C
-TESS_EVALUATION_TEXTURE        :: 0x829D
-GEOMETRY_TEXTURE               :: 0x829E
-FRAGMENT_TEXTURE               :: 0x829F
-COMPUTE_TEXTURE                :: 0x82A0
-TEXTURE_SHADOW                 :: 0x82A1
-TEXTURE_GATHER                 :: 0x82A2
-TEXTURE_GATHER_SHADOW          :: 0x82A3
-SHADER_IMAGE_LOAD              :: 0x82A4
-SHADER_IMAGE_STORE             :: 0x82A5
-SHADER_IMAGE_ATOMIC            :: 0x82A6
-IMAGE_TEXEL_SIZE               :: 0x82A7
-IMAGE_COMPATIBILITY_CLASS      :: 0x82A8
-IMAGE_PIXEL_FORMAT             :: 0x82A9
-IMAGE_PIXEL_TYPE               :: 0x82AA
-SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST :: 0x82AC
-SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST :: 0x82AD
-SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE :: 0x82AE
-SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE :: 0x82AF
-TEXTURE_COMPRESSED_BLOCK_WIDTH :: 0x82B1
-TEXTURE_COMPRESSED_BLOCK_HEIGHT :: 0x82B2
-TEXTURE_COMPRESSED_BLOCK_SIZE  :: 0x82B3
-CLEAR_BUFFER                   :: 0x82B4
-TEXTURE_VIEW                   :: 0x82B5
-VIEW_COMPATIBILITY_CLASS       :: 0x82B6
-FULL_SUPPORT                   :: 0x82B7
-CAVEAT_SUPPORT                 :: 0x82B8
-IMAGE_CLASS_4_X_32             :: 0x82B9
-IMAGE_CLASS_2_X_32             :: 0x82BA
-IMAGE_CLASS_1_X_32             :: 0x82BB
-IMAGE_CLASS_4_X_16             :: 0x82BC
-IMAGE_CLASS_2_X_16             :: 0x82BD
-IMAGE_CLASS_1_X_16             :: 0x82BE
-IMAGE_CLASS_4_X_8              :: 0x82BF
-IMAGE_CLASS_2_X_8              :: 0x82C0
-IMAGE_CLASS_1_X_8              :: 0x82C1
-IMAGE_CLASS_11_11_10           :: 0x82C2
-IMAGE_CLASS_10_10_10_2         :: 0x82C3
-VIEW_CLASS_128_BITS            :: 0x82C4
-VIEW_CLASS_96_BITS             :: 0x82C5
-VIEW_CLASS_64_BITS             :: 0x82C6
-VIEW_CLASS_48_BITS             :: 0x82C7
-VIEW_CLASS_32_BITS             :: 0x82C8
-VIEW_CLASS_24_BITS             :: 0x82C9
-VIEW_CLASS_16_BITS             :: 0x82CA
-VIEW_CLASS_8_BITS              :: 0x82CB
-VIEW_CLASS_S3TC_DXT1_RGB       :: 0x82CC
-VIEW_CLASS_S3TC_DXT1_RGBA      :: 0x82CD
-VIEW_CLASS_S3TC_DXT3_RGBA      :: 0x82CE
-VIEW_CLASS_S3TC_DXT5_RGBA      :: 0x82CF
-VIEW_CLASS_RGTC1_RED           :: 0x82D0
-VIEW_CLASS_RGTC2_RG            :: 0x82D1
-VIEW_CLASS_BPTC_UNORM          :: 0x82D2
-VIEW_CLASS_BPTC_FLOAT          :: 0x82D3
-UNIFORM                        :: 0x92E1
-UNIFORM_BLOCK                  :: 0x92E2
-PROGRAM_INPUT                  :: 0x92E3
-PROGRAM_OUTPUT                 :: 0x92E4
-BUFFER_VARIABLE                :: 0x92E5
-SHADER_STORAGE_BLOCK           :: 0x92E6
-VERTEX_SUBROUTINE              :: 0x92E8
-TESS_CONTROL_SUBROUTINE        :: 0x92E9
-TESS_EVALUATION_SUBROUTINE     :: 0x92EA
-GEOMETRY_SUBROUTINE            :: 0x92EB
-FRAGMENT_SUBROUTINE            :: 0x92EC
-COMPUTE_SUBROUTINE             :: 0x92ED
-VERTEX_SUBROUTINE_UNIFORM      :: 0x92EE
-TESS_CONTROL_SUBROUTINE_UNIFORM :: 0x92EF
-TESS_EVALUATION_SUBROUTINE_UNIFORM :: 0x92F0
-GEOMETRY_SUBROUTINE_UNIFORM    :: 0x92F1
-FRAGMENT_SUBROUTINE_UNIFORM    :: 0x92F2
-COMPUTE_SUBROUTINE_UNIFORM     :: 0x92F3
-TRANSFORM_FEEDBACK_VARYING     :: 0x92F4
-ACTIVE_RESOURCES               :: 0x92F5
-MAX_NAME_LENGTH                :: 0x92F6
-MAX_NUM_ACTIVE_VARIABLES       :: 0x92F7
-MAX_NUM_COMPATIBLE_SUBROUTINES :: 0x92F8
-NAME_LENGTH                    :: 0x92F9
-TYPE                           :: 0x92FA
-ARRAY_SIZE                     :: 0x92FB
-OFFSET                         :: 0x92FC
-BLOCK_INDEX                    :: 0x92FD
-ARRAY_STRIDE                   :: 0x92FE
-MATRIX_STRIDE                  :: 0x92FF
-IS_ROW_MAJOR                   :: 0x9300
-ATOMIC_COUNTER_BUFFER_INDEX    :: 0x9301
-BUFFER_BINDING                 :: 0x9302
-BUFFER_DATA_SIZE               :: 0x9303
-NUM_ACTIVE_VARIABLES           :: 0x9304
-ACTIVE_VARIABLES               :: 0x9305
-REFERENCED_BY_VERTEX_SHADER    :: 0x9306
-REFERENCED_BY_TESS_CONTROL_SHADER :: 0x9307
-REFERENCED_BY_TESS_EVALUATION_SHADER :: 0x9308
-REFERENCED_BY_GEOMETRY_SHADER  :: 0x9309
-REFERENCED_BY_FRAGMENT_SHADER  :: 0x930A
-REFERENCED_BY_COMPUTE_SHADER   :: 0x930B
-TOP_LEVEL_ARRAY_SIZE           :: 0x930C
-TOP_LEVEL_ARRAY_STRIDE         :: 0x930D
-LOCATION                       :: 0x930E
-LOCATION_INDEX                 :: 0x930F
-IS_PER_PATCH                   :: 0x92E7
-SHADER_STORAGE_BUFFER          :: 0x90D2
-SHADER_STORAGE_BUFFER_BINDING  :: 0x90D3
-SHADER_STORAGE_BUFFER_START    :: 0x90D4
-SHADER_STORAGE_BUFFER_SIZE     :: 0x90D5
-MAX_VERTEX_SHADER_STORAGE_BLOCKS :: 0x90D6
-MAX_GEOMETRY_SHADER_STORAGE_BLOCKS :: 0x90D7
-MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS :: 0x90D8
-MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS :: 0x90D9
-MAX_FRAGMENT_SHADER_STORAGE_BLOCKS :: 0x90DA
-MAX_COMPUTE_SHADER_STORAGE_BLOCKS :: 0x90DB
-MAX_COMBINED_SHADER_STORAGE_BLOCKS :: 0x90DC
-MAX_SHADER_STORAGE_BUFFER_BINDINGS :: 0x90DD
-MAX_SHADER_STORAGE_BLOCK_SIZE  :: 0x90DE
-SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT :: 0x90DF
-SHADER_STORAGE_BARRIER_BIT     :: 0x00002000
-MAX_COMBINED_SHADER_OUTPUT_RESOURCES :: 0x8F39
-DEPTH_STENCIL_TEXTURE_MODE     :: 0x90EA
-TEXTURE_BUFFER_OFFSET          :: 0x919D
-TEXTURE_BUFFER_SIZE            :: 0x919E
-TEXTURE_BUFFER_OFFSET_ALIGNMENT :: 0x919F
-TEXTURE_VIEW_MIN_LEVEL         :: 0x82DB
-TEXTURE_VIEW_NUM_LEVELS        :: 0x82DC
-TEXTURE_VIEW_MIN_LAYER         :: 0x82DD
-TEXTURE_VIEW_NUM_LAYERS        :: 0x82DE
-TEXTURE_IMMUTABLE_LEVELS       :: 0x82DF
-VERTEX_ATTRIB_BINDING          :: 0x82D4
-VERTEX_ATTRIB_RELATIVE_OFFSET  :: 0x82D5
-VERTEX_BINDING_DIVISOR         :: 0x82D6
-VERTEX_BINDING_OFFSET          :: 0x82D7
-VERTEX_BINDING_STRIDE          :: 0x82D8
-MAX_VERTEX_ATTRIB_RELATIVE_OFFSET :: 0x82D9
-MAX_VERTEX_ATTRIB_BINDINGS     :: 0x82DA
-VERTEX_BINDING_BUFFER          :: 0x8F4F
+NUM_SHADING_LANGUAGE_VERSIONS  :: 0x82E9;
+VERTEX_ATTRIB_ARRAY_LONG       :: 0x874E;
+COMPRESSED_RGB8_ETC2           :: 0x9274;
+COMPRESSED_SRGB8_ETC2          :: 0x9275;
+COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 :: 0x9276;
+COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 :: 0x9277;
+COMPRESSED_RGBA8_ETC2_EAC      :: 0x9278;
+COMPRESSED_SRGB8_ALPHA8_ETC2_EAC :: 0x9279;
+COMPRESSED_R11_EAC             :: 0x9270;
+COMPRESSED_SIGNED_R11_EAC      :: 0x9271;
+COMPRESSED_RG11_EAC            :: 0x9272;
+COMPRESSED_SIGNED_RG11_EAC     :: 0x9273;
+PRIMITIVE_RESTART_FIXED_INDEX  :: 0x8D69;
+ANY_SAMPLES_PASSED_CONSERVATIVE :: 0x8D6A;
+MAX_ELEMENT_INDEX              :: 0x8D6B;
+COMPUTE_SHADER                 :: 0x91B9;
+MAX_COMPUTE_UNIFORM_BLOCKS     :: 0x91BB;
+MAX_COMPUTE_TEXTURE_IMAGE_UNITS :: 0x91BC;
+MAX_COMPUTE_IMAGE_UNIFORMS     :: 0x91BD;
+MAX_COMPUTE_SHARED_MEMORY_SIZE :: 0x8262;
+MAX_COMPUTE_UNIFORM_COMPONENTS :: 0x8263;
+MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS :: 0x8264;
+MAX_COMPUTE_ATOMIC_COUNTERS    :: 0x8265;
+MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS :: 0x8266;
+MAX_COMPUTE_WORK_GROUP_INVOCATIONS :: 0x90EB;
+MAX_COMPUTE_WORK_GROUP_COUNT   :: 0x91BE;
+MAX_COMPUTE_WORK_GROUP_SIZE    :: 0x91BF;
+COMPUTE_WORK_GROUP_SIZE        :: 0x8267;
+UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER :: 0x90EC;
+ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER :: 0x90ED;
+DISPATCH_INDIRECT_BUFFER       :: 0x90EE;
+DISPATCH_INDIRECT_BUFFER_BINDING :: 0x90EF;
+COMPUTE_SHADER_BIT             :: 0x00000020;
+DEBUG_OUTPUT_SYNCHRONOUS       :: 0x8242;
+DEBUG_NEXT_LOGGED_MESSAGE_LENGTH :: 0x8243;
+DEBUG_CALLBACK_FUNCTION        :: 0x8244;
+DEBUG_CALLBACK_USER_PARAM      :: 0x8245;
+DEBUG_SOURCE_API               :: 0x8246;
+DEBUG_SOURCE_WINDOW_SYSTEM     :: 0x8247;
+DEBUG_SOURCE_SHADER_COMPILER   :: 0x8248;
+DEBUG_SOURCE_THIRD_PARTY       :: 0x8249;
+DEBUG_SOURCE_APPLICATION       :: 0x824A;
+DEBUG_SOURCE_OTHER             :: 0x824B;
+DEBUG_TYPE_ERROR               :: 0x824C;
+DEBUG_TYPE_DEPRECATED_BEHAVIOR :: 0x824D;
+DEBUG_TYPE_UNDEFINED_BEHAVIOR  :: 0x824E;
+DEBUG_TYPE_PORTABILITY         :: 0x824F;
+DEBUG_TYPE_PERFORMANCE         :: 0x8250;
+DEBUG_TYPE_OTHER               :: 0x8251;
+MAX_DEBUG_MESSAGE_LENGTH       :: 0x9143;
+MAX_DEBUG_LOGGED_MESSAGES      :: 0x9144;
+DEBUG_LOGGED_MESSAGES          :: 0x9145;
+DEBUG_SEVERITY_HIGH            :: 0x9146;
+DEBUG_SEVERITY_MEDIUM          :: 0x9147;
+DEBUG_SEVERITY_LOW             :: 0x9148;
+DEBUG_TYPE_MARKER              :: 0x8268;
+DEBUG_TYPE_PUSH_GROUP          :: 0x8269;
+DEBUG_TYPE_POP_GROUP           :: 0x826A;
+DEBUG_SEVERITY_NOTIFICATION    :: 0x826B;
+MAX_DEBUG_GROUP_STACK_DEPTH    :: 0x826C;
+DEBUG_GROUP_STACK_DEPTH        :: 0x826D;
+BUFFER                         :: 0x82E0;
+SHADER                         :: 0x82E1;
+PROGRAM                        :: 0x82E2;
+QUERY                          :: 0x82E3;
+PROGRAM_PIPELINE               :: 0x82E4;
+SAMPLER                        :: 0x82E6;
+MAX_LABEL_LENGTH               :: 0x82E8;
+DEBUG_OUTPUT                   :: 0x92E0;
+CONTEXT_FLAG_DEBUG_BIT         :: 0x00000002;
+MAX_UNIFORM_LOCATIONS          :: 0x826E;
+FRAMEBUFFER_DEFAULT_WIDTH      :: 0x9310;
+FRAMEBUFFER_DEFAULT_HEIGHT     :: 0x9311;
+FRAMEBUFFER_DEFAULT_LAYERS     :: 0x9312;
+FRAMEBUFFER_DEFAULT_SAMPLES    :: 0x9313;
+FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS :: 0x9314;
+MAX_FRAMEBUFFER_WIDTH          :: 0x9315;
+MAX_FRAMEBUFFER_HEIGHT         :: 0x9316;
+MAX_FRAMEBUFFER_LAYERS         :: 0x9317;
+MAX_FRAMEBUFFER_SAMPLES        :: 0x9318;
+INTERNALFORMAT_SUPPORTED       :: 0x826F;
+INTERNALFORMAT_PREFERRED       :: 0x8270;
+INTERNALFORMAT_RED_SIZE        :: 0x8271;
+INTERNALFORMAT_GREEN_SIZE      :: 0x8272;
+INTERNALFORMAT_BLUE_SIZE       :: 0x8273;
+INTERNALFORMAT_ALPHA_SIZE      :: 0x8274;
+INTERNALFORMAT_DEPTH_SIZE      :: 0x8275;
+INTERNALFORMAT_STENCIL_SIZE    :: 0x8276;
+INTERNALFORMAT_SHARED_SIZE     :: 0x8277;
+INTERNALFORMAT_RED_TYPE        :: 0x8278;
+INTERNALFORMAT_GREEN_TYPE      :: 0x8279;
+INTERNALFORMAT_BLUE_TYPE       :: 0x827A;
+INTERNALFORMAT_ALPHA_TYPE      :: 0x827B;
+INTERNALFORMAT_DEPTH_TYPE      :: 0x827C;
+INTERNALFORMAT_STENCIL_TYPE    :: 0x827D;
+MAX_WIDTH                      :: 0x827E;
+MAX_HEIGHT                     :: 0x827F;
+MAX_DEPTH                      :: 0x8280;
+MAX_LAYERS                     :: 0x8281;
+MAX_COMBINED_DIMENSIONS        :: 0x8282;
+COLOR_COMPONENTS               :: 0x8283;
+DEPTH_COMPONENTS               :: 0x8284;
+STENCIL_COMPONENTS             :: 0x8285;
+COLOR_RENDERABLE               :: 0x8286;
+DEPTH_RENDERABLE               :: 0x8287;
+STENCIL_RENDERABLE             :: 0x8288;
+FRAMEBUFFER_RENDERABLE         :: 0x8289;
+FRAMEBUFFER_RENDERABLE_LAYERED :: 0x828A;
+FRAMEBUFFER_BLEND              :: 0x828B;
+READ_PIXELS                    :: 0x828C;
+READ_PIXELS_FORMAT             :: 0x828D;
+READ_PIXELS_TYPE               :: 0x828E;
+TEXTURE_IMAGE_FORMAT           :: 0x828F;
+TEXTURE_IMAGE_TYPE             :: 0x8290;
+GET_TEXTURE_IMAGE_FORMAT       :: 0x8291;
+GET_TEXTURE_IMAGE_TYPE         :: 0x8292;
+MIPMAP                         :: 0x8293;
+MANUAL_GENERATE_MIPMAP         :: 0x8294;
+AUTO_GENERATE_MIPMAP           :: 0x8295;
+COLOR_ENCODING                 :: 0x8296;
+SRGB_READ                      :: 0x8297;
+SRGB_WRITE                     :: 0x8298;
+FILTER                         :: 0x829A;
+VERTEX_TEXTURE                 :: 0x829B;
+TESS_CONTROL_TEXTURE           :: 0x829C;
+TESS_EVALUATION_TEXTURE        :: 0x829D;
+GEOMETRY_TEXTURE               :: 0x829E;
+FRAGMENT_TEXTURE               :: 0x829F;
+COMPUTE_TEXTURE                :: 0x82A0;
+TEXTURE_SHADOW                 :: 0x82A1;
+TEXTURE_GATHER                 :: 0x82A2;
+TEXTURE_GATHER_SHADOW          :: 0x82A3;
+SHADER_IMAGE_LOAD              :: 0x82A4;
+SHADER_IMAGE_STORE             :: 0x82A5;
+SHADER_IMAGE_ATOMIC            :: 0x82A6;
+IMAGE_TEXEL_SIZE               :: 0x82A7;
+IMAGE_COMPATIBILITY_CLASS      :: 0x82A8;
+IMAGE_PIXEL_FORMAT             :: 0x82A9;
+IMAGE_PIXEL_TYPE               :: 0x82AA;
+SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST :: 0x82AC;
+SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST :: 0x82AD;
+SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE :: 0x82AE;
+SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE :: 0x82AF;
+TEXTURE_COMPRESSED_BLOCK_WIDTH :: 0x82B1;
+TEXTURE_COMPRESSED_BLOCK_HEIGHT :: 0x82B2;
+TEXTURE_COMPRESSED_BLOCK_SIZE  :: 0x82B3;
+CLEAR_BUFFER                   :: 0x82B4;
+TEXTURE_VIEW                   :: 0x82B5;
+VIEW_COMPATIBILITY_CLASS       :: 0x82B6;
+FULL_SUPPORT                   :: 0x82B7;
+CAVEAT_SUPPORT                 :: 0x82B8;
+IMAGE_CLASS_4_X_32             :: 0x82B9;
+IMAGE_CLASS_2_X_32             :: 0x82BA;
+IMAGE_CLASS_1_X_32             :: 0x82BB;
+IMAGE_CLASS_4_X_16             :: 0x82BC;
+IMAGE_CLASS_2_X_16             :: 0x82BD;
+IMAGE_CLASS_1_X_16             :: 0x82BE;
+IMAGE_CLASS_4_X_8              :: 0x82BF;
+IMAGE_CLASS_2_X_8              :: 0x82C0;
+IMAGE_CLASS_1_X_8              :: 0x82C1;
+IMAGE_CLASS_11_11_10           :: 0x82C2;
+IMAGE_CLASS_10_10_10_2         :: 0x82C3;
+VIEW_CLASS_128_BITS            :: 0x82C4;
+VIEW_CLASS_96_BITS             :: 0x82C5;
+VIEW_CLASS_64_BITS             :: 0x82C6;
+VIEW_CLASS_48_BITS             :: 0x82C7;
+VIEW_CLASS_32_BITS             :: 0x82C8;
+VIEW_CLASS_24_BITS             :: 0x82C9;
+VIEW_CLASS_16_BITS             :: 0x82CA;
+VIEW_CLASS_8_BITS              :: 0x82CB;
+VIEW_CLASS_S3TC_DXT1_RGB       :: 0x82CC;
+VIEW_CLASS_S3TC_DXT1_RGBA      :: 0x82CD;
+VIEW_CLASS_S3TC_DXT3_RGBA      :: 0x82CE;
+VIEW_CLASS_S3TC_DXT5_RGBA      :: 0x82CF;
+VIEW_CLASS_RGTC1_RED           :: 0x82D0;
+VIEW_CLASS_RGTC2_RG            :: 0x82D1;
+VIEW_CLASS_BPTC_UNORM          :: 0x82D2;
+VIEW_CLASS_BPTC_FLOAT          :: 0x82D3;
+UNIFORM                        :: 0x92E1;
+UNIFORM_BLOCK                  :: 0x92E2;
+PROGRAM_INPUT                  :: 0x92E3;
+PROGRAM_OUTPUT                 :: 0x92E4;
+BUFFER_VARIABLE                :: 0x92E5;
+SHADER_STORAGE_BLOCK           :: 0x92E6;
+VERTEX_SUBROUTINE              :: 0x92E8;
+TESS_CONTROL_SUBROUTINE        :: 0x92E9;
+TESS_EVALUATION_SUBROUTINE     :: 0x92EA;
+GEOMETRY_SUBROUTINE            :: 0x92EB;
+FRAGMENT_SUBROUTINE            :: 0x92EC;
+COMPUTE_SUBROUTINE             :: 0x92ED;
+VERTEX_SUBROUTINE_UNIFORM      :: 0x92EE;
+TESS_CONTROL_SUBROUTINE_UNIFORM :: 0x92EF;
+TESS_EVALUATION_SUBROUTINE_UNIFORM :: 0x92F0;
+GEOMETRY_SUBROUTINE_UNIFORM    :: 0x92F1;
+FRAGMENT_SUBROUTINE_UNIFORM    :: 0x92F2;
+COMPUTE_SUBROUTINE_UNIFORM     :: 0x92F3;
+TRANSFORM_FEEDBACK_VARYING     :: 0x92F4;
+ACTIVE_RESOURCES               :: 0x92F5;
+MAX_NAME_LENGTH                :: 0x92F6;
+MAX_NUM_ACTIVE_VARIABLES       :: 0x92F7;
+MAX_NUM_COMPATIBLE_SUBROUTINES :: 0x92F8;
+NAME_LENGTH                    :: 0x92F9;
+TYPE                           :: 0x92FA;
+ARRAY_SIZE                     :: 0x92FB;
+OFFSET                         :: 0x92FC;
+BLOCK_INDEX                    :: 0x92FD;
+ARRAY_STRIDE                   :: 0x92FE;
+MATRIX_STRIDE                  :: 0x92FF;
+IS_ROW_MAJOR                   :: 0x9300;
+ATOMIC_COUNTER_BUFFER_INDEX    :: 0x9301;
+BUFFER_BINDING                 :: 0x9302;
+BUFFER_DATA_SIZE               :: 0x9303;
+NUM_ACTIVE_VARIABLES           :: 0x9304;
+ACTIVE_VARIABLES               :: 0x9305;
+REFERENCED_BY_VERTEX_SHADER    :: 0x9306;
+REFERENCED_BY_TESS_CONTROL_SHADER :: 0x9307;
+REFERENCED_BY_TESS_EVALUATION_SHADER :: 0x9308;
+REFERENCED_BY_GEOMETRY_SHADER  :: 0x9309;
+REFERENCED_BY_FRAGMENT_SHADER  :: 0x930A;
+REFERENCED_BY_COMPUTE_SHADER   :: 0x930B;
+TOP_LEVEL_ARRAY_SIZE           :: 0x930C;
+TOP_LEVEL_ARRAY_STRIDE         :: 0x930D;
+LOCATION                       :: 0x930E;
+LOCATION_INDEX                 :: 0x930F;
+IS_PER_PATCH                   :: 0x92E7;
+SHADER_STORAGE_BUFFER          :: 0x90D2;
+SHADER_STORAGE_BUFFER_BINDING  :: 0x90D3;
+SHADER_STORAGE_BUFFER_START    :: 0x90D4;
+SHADER_STORAGE_BUFFER_SIZE     :: 0x90D5;
+MAX_VERTEX_SHADER_STORAGE_BLOCKS :: 0x90D6;
+MAX_GEOMETRY_SHADER_STORAGE_BLOCKS :: 0x90D7;
+MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS :: 0x90D8;
+MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS :: 0x90D9;
+MAX_FRAGMENT_SHADER_STORAGE_BLOCKS :: 0x90DA;
+MAX_COMPUTE_SHADER_STORAGE_BLOCKS :: 0x90DB;
+MAX_COMBINED_SHADER_STORAGE_BLOCKS :: 0x90DC;
+MAX_SHADER_STORAGE_BUFFER_BINDINGS :: 0x90DD;
+MAX_SHADER_STORAGE_BLOCK_SIZE  :: 0x90DE;
+SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT :: 0x90DF;
+SHADER_STORAGE_BARRIER_BIT     :: 0x00002000;
+MAX_COMBINED_SHADER_OUTPUT_RESOURCES :: 0x8F39;
+DEPTH_STENCIL_TEXTURE_MODE     :: 0x90EA;
+TEXTURE_BUFFER_OFFSET          :: 0x919D;
+TEXTURE_BUFFER_SIZE            :: 0x919E;
+TEXTURE_BUFFER_OFFSET_ALIGNMENT :: 0x919F;
+TEXTURE_VIEW_MIN_LEVEL         :: 0x82DB;
+TEXTURE_VIEW_NUM_LEVELS        :: 0x82DC;
+TEXTURE_VIEW_MIN_LAYER         :: 0x82DD;
+TEXTURE_VIEW_NUM_LAYERS        :: 0x82DE;
+TEXTURE_IMMUTABLE_LEVELS       :: 0x82DF;
+VERTEX_ATTRIB_BINDING          :: 0x82D4;
+VERTEX_ATTRIB_RELATIVE_OFFSET  :: 0x82D5;
+VERTEX_BINDING_DIVISOR         :: 0x82D6;
+VERTEX_BINDING_OFFSET          :: 0x82D7;
+VERTEX_BINDING_STRIDE          :: 0x82D8;
+MAX_VERTEX_ATTRIB_RELATIVE_OFFSET :: 0x82D9;
+MAX_VERTEX_ATTRIB_BINDINGS     :: 0x82DA;
+VERTEX_BINDING_BUFFER          :: 0x8F4F;
 
-MAX_VERTEX_ATTRIB_STRIDE       :: 0x82E5
-PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED :: 0x8221
-TEXTURE_BUFFER_BINDING         :: 0x8C2A
-MAP_PERSISTENT_BIT             :: 0x0040
-MAP_COHERENT_BIT               :: 0x0080
-DYNAMIC_STORAGE_BIT            :: 0x0100
-CLIENT_STORAGE_BIT             :: 0x0200
-CLIENT_MAPPED_BUFFER_BARRIER_BIT :: 0x00004000
-BUFFER_IMMUTABLE_STORAGE       :: 0x821F
-BUFFER_STORAGE_FLAGS           :: 0x8220
-CLEAR_TEXTURE                  :: 0x9365
-LOCATION_COMPONENT             :: 0x934A
-TRANSFORM_FEEDBACK_BUFFER_INDEX :: 0x934B
-TRANSFORM_FEEDBACK_BUFFER_STRIDE :: 0x934C
-QUERY_BUFFER                   :: 0x9192
-QUERY_BUFFER_BARRIER_BIT       :: 0x00008000
-QUERY_BUFFER_BINDING           :: 0x9193
-QUERY_RESULT_NO_WAIT           :: 0x9194
-MIRROR_CLAMP_TO_EDGE           :: 0x8743
+MAX_VERTEX_ATTRIB_STRIDE       :: 0x82E5;
+PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED :: 0x8221;
+TEXTURE_BUFFER_BINDING         :: 0x8C2A;
+MAP_PERSISTENT_BIT             :: 0x0040;
+MAP_COHERENT_BIT               :: 0x0080;
+DYNAMIC_STORAGE_BIT            :: 0x0100;
+CLIENT_STORAGE_BIT             :: 0x0200;
+CLIENT_MAPPED_BUFFER_BARRIER_BIT :: 0x00004000;
+BUFFER_IMMUTABLE_STORAGE       :: 0x821F;
+BUFFER_STORAGE_FLAGS           :: 0x8220;
+CLEAR_TEXTURE                  :: 0x9365;
+LOCATION_COMPONENT             :: 0x934A;
+TRANSFORM_FEEDBACK_BUFFER_INDEX :: 0x934B;
+TRANSFORM_FEEDBACK_BUFFER_STRIDE :: 0x934C;
+QUERY_BUFFER                   :: 0x9192;
+QUERY_BUFFER_BARRIER_BIT       :: 0x00008000;
+QUERY_BUFFER_BINDING           :: 0x9193;
+QUERY_RESULT_NO_WAIT           :: 0x9194;
+MIRROR_CLAMP_TO_EDGE           :: 0x8743;
 
-CONTEXT_LOST                   :: 0x0507
-NEGATIVE_ONE_TO_ONE            :: 0x935E
-ZERO_TO_ONE                    :: 0x935F
-CLIP_ORIGIN                    :: 0x935C
-CLIP_DEPTH_MODE                :: 0x935D
-QUERY_WAIT_INVERTED            :: 0x8E17
-QUERY_NO_WAIT_INVERTED         :: 0x8E18
-QUERY_BY_REGION_WAIT_INVERTED  :: 0x8E19
-QUERY_BY_REGION_NO_WAIT_INVERTED :: 0x8E1A
-MAX_CULL_DISTANCES             :: 0x82F9
-MAX_COMBINED_CLIP_AND_CULL_DISTANCES :: 0x82FA
-TEXTURE_TARGET                 :: 0x1006
-QUERY_TARGET                   :: 0x82EA
-GUILTY_CONTEXT_RESET           :: 0x8253
-INNOCENT_CONTEXT_RESET         :: 0x8254
-UNKNOWN_CONTEXT_RESET          :: 0x8255
-RESET_NOTIFICATION_STRATEGY    :: 0x8256
-LOSE_CONTEXT_ON_RESET          :: 0x8252
-NO_RESET_NOTIFICATION          :: 0x8261
-CONTEXT_FLAG_ROBUST_ACCESS_BIT :: 0x00000004
-CONTEXT_RELEASE_BEHAVIOR       :: 0x82FB
-CONTEXT_RELEASE_BEHAVIOR_FLUSH :: 0x82FC
+CONTEXT_LOST                   :: 0x0507;
+NEGATIVE_ONE_TO_ONE            :: 0x935E;
+ZERO_TO_ONE                    :: 0x935F;
+CLIP_ORIGIN                    :: 0x935C;
+CLIP_DEPTH_MODE                :: 0x935D;
+QUERY_WAIT_INVERTED            :: 0x8E17;
+QUERY_NO_WAIT_INVERTED         :: 0x8E18;
+QUERY_BY_REGION_WAIT_INVERTED  :: 0x8E19;
+QUERY_BY_REGION_NO_WAIT_INVERTED :: 0x8E1A;
+MAX_CULL_DISTANCES             :: 0x82F9;
+MAX_COMBINED_CLIP_AND_CULL_DISTANCES :: 0x82FA;
+TEXTURE_TARGET                 :: 0x1006;
+QUERY_TARGET                   :: 0x82EA;
+GUILTY_CONTEXT_RESET           :: 0x8253;
+INNOCENT_CONTEXT_RESET         :: 0x8254;
+UNKNOWN_CONTEXT_RESET          :: 0x8255;
+RESET_NOTIFICATION_STRATEGY    :: 0x8256;
+LOSE_CONTEXT_ON_RESET          :: 0x8252;
+NO_RESET_NOTIFICATION          :: 0x8261;
+CONTEXT_FLAG_ROBUST_ACCESS_BIT :: 0x00000004;
+CONTEXT_RELEASE_BEHAVIOR       :: 0x82FB;
+CONTEXT_RELEASE_BEHAVIOR_FLUSH :: 0x82FC;
 
-DEBUG_OUTPUT_SYNCHRONOUS_ARB   :: 0x8242
-DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB :: 0x8243
-DEBUG_CALLBACK_FUNCTION_ARB    :: 0x8244
-DEBUG_CALLBACK_USER_PARAM_ARB  :: 0x8245
-DEBUG_SOURCE_API_ARB           :: 0x8246
-DEBUG_SOURCE_WINDOW_SYSTEM_ARB :: 0x8247
-DEBUG_SOURCE_SHADER_COMPILER_ARB :: 0x8248
-DEBUG_SOURCE_THIRD_PARTY_ARB   :: 0x8249
-DEBUG_SOURCE_APPLICATION_ARB   :: 0x824A
-DEBUG_SOURCE_OTHER_ARB         :: 0x824B
-DEBUG_TYPE_ERROR_ARB           :: 0x824C
-DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB :: 0x824D
-DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB :: 0x824E
-DEBUG_TYPE_PORTABILITY_ARB     :: 0x824F
-DEBUG_TYPE_PERFORMANCE_ARB     :: 0x8250
-DEBUG_TYPE_OTHER_ARB           :: 0x8251
-MAX_DEBUG_MESSAGE_LENGTH_ARB   :: 0x9143
-MAX_DEBUG_LOGGED_MESSAGES_ARB  :: 0x9144
-DEBUG_LOGGED_MESSAGES_ARB      :: 0x9145
-DEBUG_SEVERITY_HIGH_ARB        :: 0x9146
-DEBUG_SEVERITY_MEDIUM_ARB      :: 0x9147
-DEBUG_SEVERITY_LOW_ARB         :: 0x9148
+DEBUG_OUTPUT_SYNCHRONOUS_ARB   :: 0x8242;
+DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB :: 0x8243;
+DEBUG_CALLBACK_FUNCTION_ARB    :: 0x8244;
+DEBUG_CALLBACK_USER_PARAM_ARB  :: 0x8245;
+DEBUG_SOURCE_API_ARB           :: 0x8246;
+DEBUG_SOURCE_WINDOW_SYSTEM_ARB :: 0x8247;
+DEBUG_SOURCE_SHADER_COMPILER_ARB :: 0x8248;
+DEBUG_SOURCE_THIRD_PARTY_ARB   :: 0x8249;
+DEBUG_SOURCE_APPLICATION_ARB   :: 0x824A;
+DEBUG_SOURCE_OTHER_ARB         :: 0x824B;
+DEBUG_TYPE_ERROR_ARB           :: 0x824C;
+DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB :: 0x824D;
+DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB :: 0x824E;
+DEBUG_TYPE_PORTABILITY_ARB     :: 0x824F;
+DEBUG_TYPE_PERFORMANCE_ARB     :: 0x8250;
+DEBUG_TYPE_OTHER_ARB           :: 0x8251;
+MAX_DEBUG_MESSAGE_LENGTH_ARB   :: 0x9143;
+MAX_DEBUG_LOGGED_MESSAGES_ARB  :: 0x9144;
+DEBUG_LOGGED_MESSAGES_ARB      :: 0x9145;
+DEBUG_SEVERITY_HIGH_ARB        :: 0x9146;
+DEBUG_SEVERITY_MEDIUM_ARB      :: 0x9147;
+DEBUG_SEVERITY_LOW_ARB         :: 0x9148;

+ 2 - 3
core/os.odin

@@ -1,3 +1,2 @@
-when ODIN_OS == "windows" {
-	#load "os_windows.odin"
-}
+#include "os_windows.odin" when ODIN_OS == "windows";
+

+ 173 - 0
core/os_windows.odin

@@ -0,0 +1,173 @@
+#import "win32.odin";
+#import "fmt.odin";
+
+File_Time :: type u64
+
+File :: struct {
+	Handle :: raw_union {
+		p: rawptr;
+		i: int;
+	}
+	handle:          Handle;
+	last_write_time: File_Time;
+}
+
+open :: proc(name: string) -> (File, bool) {
+	using win32;
+	buf: [300]byte;
+	copy(buf[:], name as []byte);
+	f: File;
+	f.handle.p = CreateFileA(^buf[0], FILE_GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, nil) as rawptr;
+	success := f.handle.p != INVALID_HANDLE_VALUE;
+	f.last_write_time = last_write_time(^f);
+	return f, success;
+}
+
+create :: proc(name: string) -> (File, bool) {
+	using win32;
+	buf: [300]byte;
+	copy(buf[:], name as []byte);
+	f: File;
+	f.handle.p = CreateFileA(^buf[0], FILE_GENERIC_WRITE, FILE_SHARE_READ, nil, CREATE_ALWAYS, 0, nil) as rawptr;
+	success := f.handle.p != INVALID_HANDLE_VALUE;
+	f.last_write_time = last_write_time(^f);
+	return f, success;
+}
+
+close :: proc(using f: ^File) {
+	win32.CloseHandle(handle.p as win32.HANDLE);
+}
+
+write :: proc(using f: ^File, buf: []byte) -> bool {
+	bytes_written: i32;
+	return win32.WriteFile(handle.p as win32.HANDLE, buf.data, buf.count as i32, ^bytes_written, nil) != 0;
+}
+
+file_has_changed :: proc(f: ^File) -> bool {
+	last_write_time := last_write_time(f);
+	if f.last_write_time != last_write_time {
+		f.last_write_time = last_write_time;
+		return true;
+	}
+	return false;
+}
+
+
+
+last_write_time :: proc(f: ^File) -> File_Time {
+	file_info: win32.BY_HANDLE_FILE_INFORMATION;
+	win32.GetFileInformationByHandle(f.handle.p as win32.HANDLE, ^file_info);
+	l := file_info.last_write_time.low_date_time as File_Time;
+	h := file_info.last_write_time.high_date_time as File_Time;
+	return l | h << 32;
+}
+
+last_write_time_by_name :: proc(name: string) -> File_Time {
+	last_write_time: win32.FILETIME;
+	data: win32.WIN32_FILE_ATTRIBUTE_DATA;
+
+	buf: [1024]byte;
+	path := buf[:0];
+	fmt.bprint(^path, name, "\x00");
+
+	if win32.GetFileAttributesExA(path.data, win32.GetFileExInfoStandard, ^data) != 0 {
+		last_write_time = data.last_write_time;
+	}
+
+	l := last_write_time.low_date_time as File_Time;
+	h := last_write_time.high_date_time as File_Time;
+	return l | h << 32;
+}
+
+
+
+
+File_Standard :: enum {
+	INPUT,
+	OUTPUT,
+	ERROR,
+}
+
+// NOTE(bill): Uses startup to initialize it
+__std_files := [File_Standard.count]File{
+	{handle = win32.GetStdHandle(win32.STD_INPUT_HANDLE)  transmute File.Handle },
+	{handle = win32.GetStdHandle(win32.STD_OUTPUT_HANDLE) transmute File.Handle },
+	{handle = win32.GetStdHandle(win32.STD_ERROR_HANDLE)  transmute File.Handle },
+};
+
+stdin  := ^__std_files[File_Standard.INPUT];
+stdout := ^__std_files[File_Standard.OUTPUT];
+stderr := ^__std_files[File_Standard.ERROR];
+
+
+
+read_entire_file :: proc(name: string) -> ([]byte, bool) {
+	buf: [300]byte;
+	copy(buf[:], name as []byte);
+
+	f, file_ok := open(name);
+	if !file_ok {
+		return nil, false;
+	}
+	defer close(^f);
+
+	length: i64;
+	file_size_ok := win32.GetFileSizeEx(f.handle.p as win32.HANDLE, ^length) != 0;
+	if !file_size_ok {
+		return nil, false;
+	}
+
+	data := new_slice(u8, length);
+	if data.data == nil {
+		return nil, false;
+	}
+
+	single_read_length: i32;
+	total_read: i64;
+
+	for total_read < length {
+		remaining := length - total_read;
+		to_read: u32;
+		MAX :: 1<<32-1;
+		if remaining <= MAX {
+			to_read = remaining as u32;
+		} else {
+			to_read = MAX;
+		}
+
+		win32.ReadFile(f.handle.p as win32.HANDLE, ^data[total_read], to_read, ^single_read_length, nil);
+		if single_read_length <= 0 {
+			free(data.data);
+			return nil, false;
+		}
+
+		total_read += single_read_length as i64;
+	}
+
+	return data, true;
+}
+
+
+
+heap_alloc :: proc(size: int) -> rawptr {
+	return win32.HeapAlloc(win32.GetProcessHeap(), win32.HEAP_ZERO_MEMORY, size);
+}
+heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
+	return win32.HeapReAlloc(win32.GetProcessHeap(), win32.HEAP_ZERO_MEMORY, ptr, new_size);
+}
+heap_free :: proc(ptr: rawptr) {
+	win32.HeapFree(win32.GetProcessHeap(), 0, ptr);
+}
+
+
+exit :: proc(code: int) {
+	win32.ExitProcess(code as u32);
+}
+
+
+
+current_thread_id :: proc() -> int {
+	GetCurrentThreadId :: proc() -> u32 #foreign #dll_import
+	return GetCurrentThreadId() as int;
+}
+

+ 95 - 95
core/utf8.odin

@@ -1,17 +1,17 @@
-RUNE_ERROR :: '\ufffd'
-RUNE_SELF  :: 0x80
-RUNE_BOM   :: 0xfeff
-RUNE_EOF   :: ~(0 as rune)
-MAX_RUNE   :: '\U0010ffff'
-UTF_MAX    :: 4
+RUNE_ERROR :: '\ufffd';
+RUNE_SELF  :: 0x80;
+RUNE_BOM   :: 0xfeff;
+RUNE_EOF   :: ~(0 as rune);
+MAX_RUNE   :: '\U0010ffff';
+UTF_MAX    :: 4;
 
 
-SURROGATE_MIN :: 0xd800
-SURROGATE_MAX :: 0xdfff
+SURROGATE_MIN :: 0xd800;
+SURROGATE_MAX :: 0xdfff;
 
 
 Accept_Range :: struct {
-	lo, hi: u8
+	lo, hi: u8;
 }
 
 accept_ranges := [5]Accept_Range{
@@ -20,7 +20,7 @@ accept_ranges := [5]Accept_Range{
 	{0x80, 0x9f},
 	{0x90, 0xbf},
 	{0x80, 0x8f},
-}
+};
 
 accept_sizes := [256]byte{
 	0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x00-0x0f
@@ -40,177 +40,177 @@ accept_sizes := [256]byte{
 	0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xd0-0xdf
 	0x13, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x23, 0x03, 0x03, // 0xe0-0xef
 	0x34, 0x04, 0x04, 0x04, 0x44, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0xf0-0xff
-}
+};
 
 encode_rune :: proc(r_: rune) -> ([4]byte, int) {
-	r := r_
-	buf: [4]byte
-	i := r as u32
-	mask: byte : 0x3f
+	r := r_;
+	buf: [4]byte;
+	i := r as u32;
+	mask: byte : 0x3f;
 	if i <= 1<<7-1 {
-		buf[0] = r as byte
-		return buf, 1
+		buf[0] = r as byte;
+		return buf, 1;
 	}
 	if i <= 1<<11-1 {
-		buf[0] = 0xc0 | (r>>6) as byte
-		buf[1] = 0x80 | (r)    as byte & mask
-		return buf, 2
+		buf[0] = 0xc0 | (r>>6) as byte;
+		buf[1] = 0x80 | (r)    as byte & mask;
+		return buf, 2;
 	}
 
 	// Invalid or Surrogate range
 	if i > 0x0010ffff ||
 	   (0xd800 <= i && i <= 0xdfff) {
-		r = 0xfffd
+		r = 0xfffd;
 	}
 
 	if i <= 1<<16-1 {
-		buf[0] = 0xe0 | (r>>12) as byte
-		buf[1] = 0x80 | (r>>6)  as byte & mask
-		buf[2] = 0x80 | (r)     as byte & mask
-		return buf, 3
+		buf[0] = 0xe0 | (r>>12) as byte;
+		buf[1] = 0x80 | (r>>6)  as byte & mask;
+		buf[2] = 0x80 | (r)     as byte & mask;
+		return buf, 3;
 	}
 
-	buf[0] = 0xf0 | (r>>18) as byte
-	buf[1] = 0x80 | (r>>12) as byte & mask
-	buf[2] = 0x80 | (r>>6)  as byte & mask
-	buf[3] = 0x80 | (r)     as byte & mask
-	return buf, 4
+	buf[0] = 0xf0 | (r>>18) as byte;
+	buf[1] = 0x80 | (r>>12) as byte & mask;
+	buf[2] = 0x80 | (r>>6)  as byte & mask;
+	buf[3] = 0x80 | (r)     as byte & mask;
+	return buf, 4;
 }
 
 decode_rune :: proc(s: string) -> (rune, int) {
-	n := s.count
+	n := s.count;
 	if n < 1 {
-		return RUNE_ERROR, 0
+		return RUNE_ERROR, 0;
 	}
-	b0 := s[0]
-	x := accept_sizes[b0]
+	b0 := s[0];
+	x := accept_sizes[b0];
 	if x >= 0xf0 {
-		mask := (x as rune << 31) >> 31 // all zeros or all ones
-		return (b0 as rune) &~ mask | RUNE_ERROR&mask, 1
+		mask := (x as rune << 31) >> 31; // all zeros or all ones
+		return (b0 as rune) &~ mask | RUNE_ERROR&mask, 1;
 	}
-	size := x & 7
-	ar := accept_ranges[x>>4]
+	size := x & 7;
+	ar := accept_ranges[x>>4];
 	if n < size as int {
-		return RUNE_ERROR, 1
+		return RUNE_ERROR, 1;
 	}
-	b1 := s[1]
+	b1 := s[1];
 	if b1 < ar.lo || ar.hi < b1 {
-		return RUNE_ERROR, 1
+		return RUNE_ERROR, 1;
 	}
 
-	MASK_X :: 0b00111111
-	MASK_2 :: 0b00011111
-	MASK_3 :: 0b00001111
-	MASK_4 :: 0b00000111
+	MASK_X :: 0b00111111;
+	MASK_2 :: 0b00011111;
+	MASK_3 :: 0b00001111;
+	MASK_4 :: 0b00000111;
 
 	if size == 2 {
-		return (b0&MASK_2) as rune <<6 | (b1&MASK_X) as rune, 2
+		return (b0&MASK_2) as rune <<6 | (b1&MASK_X) as rune, 2;
 	}
-	b2 := s[2]
+	b2 := s[2];
 	if b2 < 0x80 || 0xbf < b2 {
-		return RUNE_ERROR, 1
+		return RUNE_ERROR, 1;
 	}
 	if size == 3 {
-		return (b0&MASK_3) as rune <<12 | (b1&MASK_X) as rune <<6 | (b2&MASK_X) as rune, 3
+		return (b0&MASK_3) as rune <<12 | (b1&MASK_X) as rune <<6 | (b2&MASK_X) as rune, 3;
 	}
-	b3 := s[3]
+	b3 := s[3];
 	if b3 < 0x80 || 0xbf < b3 {
-		return RUNE_ERROR, 1
+		return RUNE_ERROR, 1;
 	}
-	return (b0&MASK_4) as rune <<18 | (b1&MASK_X) as rune <<12 | (b3&MASK_X) as rune <<6 | (b3&MASK_X) as rune, 4
+	return (b0&MASK_4) as rune <<18 | (b1&MASK_X) as rune <<12 | (b3&MASK_X) as rune <<6 | (b3&MASK_X) as rune, 4;
 
 }
 
 
 valid_rune :: proc(r: rune) -> bool {
 	if r < 0 {
-		return false
+		return false;
 	} else if SURROGATE_MIN <= r && r <= SURROGATE_MAX {
-		return false
+		return false;
 	} else if r > MAX_RUNE {
-		return false
+		return false;
 	}
-	return true
+	return true;
 }
 
 valid_string :: proc(s: string) -> bool {
-	n := s.count
+	n := s.count;
 	for i := 0; i < n; {
-		si := s[i]
+		si := s[i];
 		if si < RUNE_SELF { // ascii
-			i++
-			continue
+			i++;
+			continue;
 		}
-		x := accept_sizes[si]
+		x := accept_sizes[si];
 		if x == 0xf1 {
-			return false
+			return false;
 		}
-		size := (x & 7) as int
+		size := (x & 7) as int;
 		if i+size > n {
-			return false
+			return false;
 		}
-		ar := accept_ranges[x>>4]
+		ar := accept_ranges[x>>4];
 		if b := s[i+1]; b < ar.lo || ar.hi < b {
-			return false
+			return false;
 		} else if size == 2 {
 			// Okay
 		} else if b := s[i+2]; b < 0x80 || 0xbf < b {
-			return false
+			return false;
 		} else if size == 3 {
 			// Okay
 		} else if b := s[i+3]; b < 0x80 || 0xbf < b {
-			return false
+			return false;
 		}
-		i += size
+		i += size;
 	}
-	return true
+	return true;
 }
 
 rune_count :: proc(s: string) -> int {
-	count := 0
-	n := s.count
+	count := 0;
+	n := s.count;
 	for i := 0; i < n; count++ {
-		si := s[i]
+		si := s[i];
 		if si < RUNE_SELF { // ascii
-			i++
-			continue
+			i++;
+			continue;
 		}
-		x := accept_sizes[si]
+		x := accept_sizes[si];
 		if x == 0xf1 {
-			i++
-			continue
+			i++;
+			continue;
 		}
-		size := (x & 7) as int
+		size := (x & 7) as int;
 		if i+size > n {
-			i++
-			continue
+			i++;
+			continue;
 		}
-		ar := accept_ranges[x>>4]
+		ar := accept_ranges[x>>4];
 		if b := s[i+1]; b < ar.lo || ar.hi < b {
-			size = 1
+			size = 1;
 		} else if size == 2 {
 			// Okay
 		} else if b := s[i+2]; b < 0x80 || 0xbf < b {
-			size = 1
+			size = 1;
 		} else if size == 3 {
 			// Okay
 		} else if b := s[i+3]; b < 0x80 || 0xbf < b {
-			size = 1
+			size = 1;
 		}
-		i += size
+		i += size;
 	}
-	return count
+	return count;
 }
 
 
 rune_size :: proc(r: rune) -> int {
 	match {
-	case r < 0:          return -1
-	case r <= 1<<7  - 1: return 1
-	case r <= 1<<11 - 1: return 2
-	case SURROGATE_MIN <= r && r <= SURROGATE_MAX: return -1
-	case r <= 1<<16 - 1: return 3
-	case r <= MAX_RUNE:  return 4
-	}
-	return -1
+	case r < 0:          return -1;
+	case r <= 1<<7  - 1: return 1;
+	case r <= 1<<11 - 1: return 2;
+	case SURROGATE_MIN <= r && r <= SURROGATE_MAX: return -1;
+	case r <= 1<<16 - 1: return 3;
+	case r <= MAX_RUNE:  return 4;
+	}
+	return -1;
 }

+ 123 - 125
core/win32.odin

@@ -1,7 +1,5 @@
-when ODIN_OS == "windows" {
-	#foreign_system_library "user32"
-	#foreign_system_library "gdi32"
-}
+#foreign_system_library "user32" when ODIN_OS == "windows";
+#foreign_system_library "gdi32"  when ODIN_OS == "windows";
 
 HANDLE    :: type rawptr
 HWND      :: type HANDLE
@@ -20,100 +18,100 @@ ATOM      :: type i16
 BOOL      :: type i32
 WNDPROC   :: type proc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT
 
-INVALID_HANDLE_VALUE :: (-1 as int) as HANDLE
+INVALID_HANDLE_VALUE :: (-1 as int) as HANDLE;
 
-CS_VREDRAW    :: 0x0001
-CS_HREDRAW    :: 0x0002
-CS_OWNDC      :: 0x0020
-CW_USEDEFAULT :: -0x80000000
+CS_VREDRAW    :: 0x0001;
+CS_HREDRAW    :: 0x0002;
+CS_OWNDC      :: 0x0020;
+CW_USEDEFAULT :: -0x80000000;
 
-WS_OVERLAPPED       :: 0
-WS_MAXIMIZEBOX      :: 0x00010000
-WS_MINIMIZEBOX      :: 0x00020000
-WS_THICKFRAME       :: 0x00040000
-WS_SYSMENU          :: 0x00080000
-WS_CAPTION          :: 0x00C00000
-WS_VISIBLE          :: 0x10000000
-WS_OVERLAPPEDWINDOW :: WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
+WS_OVERLAPPED       :: 0;
+WS_MAXIMIZEBOX      :: 0x00010000;
+WS_MINIMIZEBOX      :: 0x00020000;
+WS_THICKFRAME       :: 0x00040000;
+WS_SYSMENU          :: 0x00080000;
+WS_CAPTION          :: 0x00C00000;
+WS_VISIBLE          :: 0x10000000;
+WS_OVERLAPPEDWINDOW :: WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
 
-WM_DESTROY :: 0x0002
-WM_CLOSE   :: 0x0010
-WM_QUIT    :: 0x0012
-WM_KEYDOWN :: 0x0100
-WM_KEYUP   :: 0x0101
+WM_DESTROY :: 0x0002;
+WM_CLOSE   :: 0x0010;
+WM_QUIT    :: 0x0012;
+WM_KEYDOWN :: 0x0100;
+WM_KEYUP   :: 0x0101;
 
-PM_REMOVE :: 1
+PM_REMOVE :: 1;
 
-COLOR_BACKGROUND :: 1 as HBRUSH
-BLACK_BRUSH :: 4
+COLOR_BACKGROUND :: 1 as HBRUSH;
+BLACK_BRUSH :: 4;
 
-SM_CXSCREEN :: 0
-SM_CYSCREEN :: 1
+SM_CXSCREEN :: 0;
+SM_CYSCREEN :: 1;
 
-SW_SHOW :: 5
+SW_SHOW :: 5;
 
 POINT :: struct #ordered {
-	x, y: i32
+	x, y: i32;
 }
 
 
 WNDCLASSEXA :: struct #ordered {
-	size, style:           u32
-	wnd_proc:              WNDPROC
-	cls_extra, wnd_extra:  i32
-	instance:              HINSTANCE
-	icon:                  HICON
-	cursor:                HCURSOR
-	background:            HBRUSH
-	menu_name, class_name: ^u8
-	sm:                    HICON
+	size, style:           u32;
+	wnd_proc:              WNDPROC;
+	cls_extra, wnd_extra:  i32;
+	instance:              HINSTANCE;
+	icon:                  HICON;
+	cursor:                HCURSOR;
+	background:            HBRUSH;
+	menu_name, class_name: ^u8;
+	sm:                    HICON;
 }
 
 MSG :: struct #ordered {
-	hwnd:    HWND
-	message: u32
-	wparam:  WPARAM
-	lparam:  LPARAM
-	time:    u32
-	pt:      POINT
+	hwnd:    HWND;
+	message: u32;
+	wparam:  WPARAM;
+	lparam:  LPARAM;
+	time:    u32;
+	pt:      POINT;
 }
 
 RECT :: struct #ordered {
-	left:   i32
-	top:    i32
-	right:  i32
-	bottom: i32
+	left:   i32;
+	top:    i32;
+	right:  i32;
+	bottom: i32;
 }
 
 FILETIME :: struct #ordered {
-	low_date_time, high_date_time: u32
+	low_date_time, high_date_time: u32;
 }
 
 BY_HANDLE_FILE_INFORMATION :: struct #ordered {
-	file_attributes:      u32
+	file_attributes:      u32;
 	creation_time,
 	last_access_time,
-	last_write_time:      FILETIME
+	last_write_time:      FILETIME;
 	volume_serial_number,
 	file_size_high,
 	file_size_low,
 	number_of_links,
 	file_index_high,
-	file_index_low:       u32
+	file_index_low:       u32;
 }
 
 WIN32_FILE_ATTRIBUTE_DATA :: struct #ordered {
-	file_attributes:  u32
+	file_attributes:  u32;
 	creation_time,
 	last_access_time,
-	last_write_time:  FILETIME
+	last_write_time:  FILETIME;
 	file_size_high,
-	file_size_low:    u32
+	file_size_low:    u32;
 }
 
-GET_FILEEX_INFO_LEVELS :: type i32
-GetFileExInfoStandard : GET_FILEEX_INFO_LEVELS : 0
-GetFileExMaxInfoLevel : GET_FILEEX_INFO_LEVELS : 1
+GET_FILEEX_INFO_LEVELS :: type i32;
+GetFileExInfoStandard : GET_FILEEX_INFO_LEVELS : 0;
+GetFileExMaxInfoLevel : GET_FILEEX_INFO_LEVELS : 1;
 
 GetLastError     :: proc() -> i32                           #foreign #dll_import
 ExitProcess      :: proc(exit_code: u32)                    #foreign #dll_import
@@ -154,9 +152,9 @@ AdjustWindowRect :: proc(rect: ^RECT, style: u32, menu: BOOL) -> BOOL #foreign #
 
 
 GetQueryPerformanceFrequency :: proc() -> i64 {
-	r: i64
-	QueryPerformanceFrequency(^r)
-	return r
+	r: i64;
+	QueryPerformanceFrequency(^r);
+	return r;
 }
 
 GetCommandLineA :: proc() -> ^u8 #foreign #dll_import
@@ -177,35 +175,35 @@ GetFileSizeEx              :: proc(file_handle: HANDLE, file_size: ^i64) -> BOOL
 GetFileAttributesExA       :: proc(filename: ^u8, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> BOOL #foreign #dll_import
 GetFileInformationByHandle :: proc(file_handle: HANDLE, file_info: ^BY_HANDLE_FILE_INFORMATION) -> BOOL #foreign #dll_import
 
-FILE_SHARE_READ      :: 0x00000001
-FILE_SHARE_WRITE     :: 0x00000002
-FILE_SHARE_DELETE    :: 0x00000004
-FILE_GENERIC_ALL     :: 0x10000000
-FILE_GENERIC_EXECUTE :: 0x20000000
-FILE_GENERIC_WRITE   :: 0x40000000
-FILE_GENERIC_READ    :: 0x80000000
+FILE_SHARE_READ      :: 0x00000001;
+FILE_SHARE_WRITE     :: 0x00000002;
+FILE_SHARE_DELETE    :: 0x00000004;
+FILE_GENERIC_ALL     :: 0x10000000;
+FILE_GENERIC_EXECUTE :: 0x20000000;
+FILE_GENERIC_WRITE   :: 0x40000000;
+FILE_GENERIC_READ    :: 0x80000000;
 
-STD_INPUT_HANDLE  :: -10
-STD_OUTPUT_HANDLE :: -11
-STD_ERROR_HANDLE  :: -12
+STD_INPUT_HANDLE  :: -10;
+STD_OUTPUT_HANDLE :: -11;
+STD_ERROR_HANDLE  :: -12;
 
-CREATE_NEW        :: 1
-CREATE_ALWAYS     :: 2
-OPEN_EXISTING     :: 3
-OPEN_ALWAYS       :: 4
-TRUNCATE_EXISTING :: 5
+CREATE_NEW        :: 1;
+CREATE_ALWAYS     :: 2;
+OPEN_EXISTING     :: 3;
+OPEN_ALWAYS       :: 4;
+TRUNCATE_EXISTING :: 5;
 
 
 
 
 
-HeapAlloc   :: proc(h: HANDLE, flags: u32, bytes: int) -> rawptr                 #foreign #dll_import
-HeapReAlloc :: proc(h: HANDLE, flags: u32, memory: rawptr, bytes: int) -> rawptr #foreign #dll_import
-HeapFree    :: proc(h: HANDLE, flags: u32, memory: rawptr) -> BOOL               #foreign #dll_import
+HeapAlloc      :: proc(h: HANDLE, flags: u32, bytes: int) -> rawptr                 #foreign #dll_import
+HeapReAlloc    :: proc(h: HANDLE, flags: u32, memory: rawptr, bytes: int) -> rawptr #foreign #dll_import
+HeapFree       :: proc(h: HANDLE, flags: u32, memory: rawptr) -> BOOL               #foreign #dll_import
 GetProcessHeap :: proc() -> HANDLE #foreign #dll_import
 
 
-HEAP_ZERO_MEMORY :: 0x00000008
+HEAP_ZERO_MEMORY :: 0x00000008;
 
 
 
@@ -213,28 +211,28 @@ HEAP_ZERO_MEMORY :: 0x00000008
 
 BITMAPINFO :: struct #ordered {
 	HEADER :: struct #ordered {
-		size:              u32
-		width, height:     i32
-		planes, bit_count: i16
-		compression:       u32
-		size_image:        u32
-		x_pels_per_meter:  i32
-		y_pels_per_meter:  i32
-		clr_used:          u32
-		clr_important:     u32
+		size:              u32;
+		width, height:     i32;
+		planes, bit_count: i16;
+		compression:       u32;
+		size_image:        u32;
+		x_pels_per_meter:  i32;
+		y_pels_per_meter:  i32;
+		clr_used:          u32;
+		clr_important:     u32;
 	}
-	using header: HEADER
-	colors:       [1]RGBQUAD
+	using header: HEADER;
+	colors:       [1]RGBQUAD;
 }
 
 
 RGBQUAD :: struct #ordered {
-	blue, green, red, reserved: byte
+	blue, green, red, reserved: byte;
 }
 
-BI_RGB         :: 0
-DIB_RGB_COLORS :: 0x00
-SRCCOPY        : u32 : 0x00cc0020
+BI_RGB         :: 0;
+DIB_RGB_COLORS :: 0x00;
+SRCCOPY        : u32 : 0x00cc0020;
 
 StretchDIBits :: proc(hdc: HDC,
                       x_dst, y_dst, width_dst, height_dst: i32,
@@ -255,27 +253,27 @@ GetClientRect :: proc(hwnd: HWND, rect: ^RECT) -> BOOL #foreign
 
 // Windows OpenGL
 
-PFD_TYPE_RGBA             :: 0
-PFD_TYPE_COLORINDEX       :: 1
-PFD_MAIN_PLANE            :: 0
-PFD_OVERLAY_PLANE         :: 1
-PFD_UNDERLAY_PLANE        :: -1
-PFD_DOUBLEBUFFER          :: 1
-PFD_STEREO                :: 2
-PFD_DRAW_TO_WINDOW        :: 4
-PFD_DRAW_TO_BITMAP        :: 8
-PFD_SUPPORT_GDI           :: 16
-PFD_SUPPORT_OPENGL        :: 32
-PFD_GENERIC_FORMAT        :: 64
-PFD_NEED_PALETTE          :: 128
-PFD_NEED_SYSTEM_PALETTE   :: 0x00000100
-PFD_SWAP_EXCHANGE         :: 0x00000200
-PFD_SWAP_COPY             :: 0x00000400
-PFD_SWAP_LAYER_BUFFERS    :: 0x00000800
-PFD_GENERIC_ACCELERATED   :: 0x00001000
-PFD_DEPTH_DONTCARE        :: 0x20000000
-PFD_DOUBLEBUFFER_DONTCARE :: 0x40000000
-PFD_STEREO_DONTCARE       :: 0x80000000
+PFD_TYPE_RGBA             :: 0;
+PFD_TYPE_COLORINDEX       :: 1;
+PFD_MAIN_PLANE            :: 0;
+PFD_OVERLAY_PLANE         :: 1;
+PFD_UNDERLAY_PLANE        :: -1;
+PFD_DOUBLEBUFFER          :: 1;
+PFD_STEREO                :: 2;
+PFD_DRAW_TO_WINDOW        :: 4;
+PFD_DRAW_TO_BITMAP        :: 8;
+PFD_SUPPORT_GDI           :: 16;
+PFD_SUPPORT_OPENGL        :: 32;
+PFD_GENERIC_FORMAT        :: 64;
+PFD_NEED_PALETTE          :: 128;
+PFD_NEED_SYSTEM_PALETTE   :: 0x00000100;
+PFD_SWAP_EXCHANGE         :: 0x00000200;
+PFD_SWAP_COPY             :: 0x00000400;
+PFD_SWAP_LAYER_BUFFERS    :: 0x00000800;
+PFD_GENERIC_ACCELERATED   :: 0x00001000;
+PFD_DEPTH_DONTCARE        :: 0x20000000;
+PFD_DOUBLEBUFFER_DONTCARE :: 0x40000000;
+PFD_STEREO_DONTCARE       :: 0x80000000;
 
 HGLRC :: type HANDLE
 PROC  :: type proc()
@@ -285,7 +283,7 @@ wglCreateContextAttribsARBType :: type proc(hdc: HDC, hshareContext: rawptr, att
 PIXELFORMATDESCRIPTOR :: struct #ordered {
 	size,
 	version,
-	flags: u32
+	flags: u32;
 
 	pixel_type,
 	color_bits,
@@ -306,11 +304,11 @@ PIXELFORMATDESCRIPTOR :: struct #ordered {
 	stencil_bits,
 	aux_buffers,
 	layer_type,
-	reserved: byte
+	reserved: byte;
 
 	layer_mask,
 	visible_mask,
-	damage_mask: u32
+	damage_mask: u32;
 }
 
 GetDC             :: proc(h: HANDLE) -> HDC #foreign
@@ -319,11 +317,11 @@ ChoosePixelFormat :: proc(hdc: HDC, pfd: ^PIXELFORMATDESCRIPTOR) -> i32 #foreign
 SwapBuffers       :: proc(hdc: HDC) -> BOOL #foreign #dll_import
 ReleaseDC         :: proc(wnd: HWND, hdc: HDC) -> i32 #foreign #dll_import
 
-WGL_CONTEXT_MAJOR_VERSION_ARB             :: 0x2091
-WGL_CONTEXT_MINOR_VERSION_ARB             :: 0x2092
-WGL_CONTEXT_PROFILE_MASK_ARB              :: 0x9126
-WGL_CONTEXT_CORE_PROFILE_BIT_ARB          :: 0x0001
-WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x0002
+WGL_CONTEXT_MAJOR_VERSION_ARB             :: 0x2091;
+WGL_CONTEXT_MINOR_VERSION_ARB             :: 0x2092;
+WGL_CONTEXT_PROFILE_MASK_ARB              :: 0x9126;
+WGL_CONTEXT_CORE_PROFILE_BIT_ARB          :: 0x0001;
+WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x0002;
 
 wglCreateContext  :: proc(hdc: HDC) -> HGLRC #foreign #dll_import
 wglMakeCurrent    :: proc(hdc: HDC, hglrc: HGLRC) -> BOOL #foreign #dll_import
@@ -336,7 +334,7 @@ GetKeyState      :: proc(v_key: i32) -> i16 #foreign #dll_import
 GetAsyncKeyState :: proc(v_key: i32) -> i16 #foreign #dll_import
 
 is_key_down :: proc(key: Key_Code) -> bool {
-	return GetAsyncKeyState(key as i32) < 0
+	return GetAsyncKeyState(key as i32) < 0;
 }
 
 Key_Code :: enum i32 {

+ 52 - 73
src/checker/checker.c

@@ -223,10 +223,10 @@ typedef struct CheckerContext {
 #define MAP_NAME MapExprInfo
 #include "../map.c"
 
-typedef struct DelayedImport {
-	Scope *            parent;
-	AstNodeImportDecl *decl;
-} DelayedImport;
+typedef struct DelayedDecl {
+	Scope *  parent;
+	AstNode *decl;
+} DelayedDecl;
 
 
 // NOTE(bill): Symbol tables
@@ -253,7 +253,8 @@ typedef struct Checker {
 	BaseTypeSizes          sizes;
 	Scope *                global_scope;
 	Array(ProcedureInfo)   procs; // NOTE(bill): Procedures to check
-	Array(DelayedImport)   delayed_imports;
+	Array(DelayedDecl)   delayed_imports;
+	Array(DelayedDecl)   delayed_foreign_libraries;
 
 
 	gbArena                arena;
@@ -427,7 +428,7 @@ void scope_lookup_parent_entity(Scope *scope, String name, Scope **scope_, Entit
 					}
 
 					if (e->scope != shared) {
-						// Do not return imported entities even #load ones
+						// Do not return imported entities even #include ones
 						continue;
 					}
 
@@ -616,6 +617,7 @@ void init_checker(Checker *c, Parser *parser, BaseTypeSizes sizes) {
 	array_init(&c->proc_stack, a);
 	array_init(&c->procs, a);
 	array_init(&c->delayed_imports, a);
+	array_init(&c->delayed_foreign_libraries, a);
 
 	// NOTE(bill): Is this big enough or too small?
 	isize item_size = gb_max3(gb_size_of(Entity), gb_size_of(Type), gb_size_of(Scope));
@@ -642,6 +644,7 @@ void destroy_checker(Checker *c) {
 	array_free(&c->proc_stack);
 	array_free(&c->procs);
 	array_free(&c->delayed_imports);
+	array_free(&c->delayed_foreign_libraries);
 
 	gb_arena_free(&c->arena);
 }
@@ -1083,39 +1086,6 @@ void check_global_entities_by_kind(Checker *c, EntityKind kind) {
 	}
 }
 
-void check_global_collect_entities(Checker *c, Scope *parent_scope, AstNodeArray nodes, MapScope *file_scopes);
-
-void check_global_when_stmt(Checker *c, Scope *parent_scope, AstNodeWhenStmt *ws, MapScope *file_scopes) {
-	Operand operand = {Addressing_Invalid};
-	check_expr(c, &operand, ws->cond);
-	if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) {
-		error_node(ws->cond, "Non-boolean condition in `when` statement");
-	}
-	if (operand.mode != Addressing_Constant) {
-		error_node(ws->cond, "Non-constant condition in `when` statement");
-	}
-	if (ws->body == NULL || ws->body->kind != AstNode_BlockStmt) {
-		error_node(ws->cond, "Invalid body for `when` statement");
-	} else {
-		if (operand.value.kind == ExactValue_Bool &&
-		    operand.value.value_bool == true) {
-			ast_node(body, BlockStmt, ws->body);
-			check_global_collect_entities(c, parent_scope, body->stmts, file_scopes);
-		} else if (ws->else_stmt) {
-			switch (ws->else_stmt->kind) {
-			case AstNode_BlockStmt:
-				check_global_collect_entities(c, parent_scope, ws->else_stmt->BlockStmt.stmts, file_scopes);
-				break;
-			case AstNode_WhenStmt:
-				check_global_when_stmt(c, parent_scope, &ws->else_stmt->WhenStmt, file_scopes);
-				break;
-			default:
-				error_node(ws->else_stmt, "Invalid `else` statement in `when` statement");
-				break;
-			}
-		}
-	}
-}
 void check_global_collect_entities(Checker *c, Scope *parent_scope, AstNodeArray nodes, MapScope *file_scopes) {
 	for_array(decl_index, nodes) {
 		AstNode *decl = nodes.e[decl_index];
@@ -1126,16 +1096,13 @@ void check_global_collect_entities(Checker *c, Scope *parent_scope, AstNodeArray
 		switch (decl->kind) {
 		case_ast_node(bd, BadDecl, decl);
 		case_end;
-		case_ast_node(ws, WhenStmt, decl);
-			// Will be handled later
-		case_end;
 		case_ast_node(id, ImportDecl, decl);
 			if (!parent_scope->is_file) {
 				// NOTE(bill): _Should_ be caught by the parser
 				// TODO(bill): Better error handling if it isn't
 				continue;
 			}
-			DelayedImport di = {parent_scope, id};
+			DelayedDecl di = {parent_scope, decl};
 			array_add(&c->delayed_imports, di);
 		case_end;
 		case_ast_node(fl, ForeignLibrary, decl);
@@ -1145,24 +1112,8 @@ void check_global_collect_entities(Checker *c, Scope *parent_scope, AstNodeArray
 				continue;
 			}
 
-			String file_str = fl->filepath.string;
-			String base_dir = fl->base_dir;
-
-			if (!fl->is_system) {
-				gbAllocator a = heap_allocator(); // TODO(bill): Change this allocator
-
-				String rel_path = get_fullpath_relative(a, base_dir, file_str);
-				String import_file = rel_path;
-				if (!gb_file_exists(cast(char *)rel_path.text)) { // NOTE(bill): This should be null terminated
-					String abs_path = get_fullpath_core(a, file_str);
-					if (gb_file_exists(cast(char *)abs_path.text)) {
-						import_file = abs_path;
-					}
-				}
-				file_str = import_file;
-			}
-
-			try_add_foreign_library_path(c, file_str);
+			DelayedDecl di = {parent_scope, decl};
+			array_add(&c->delayed_foreign_libraries, di);
 		case_end;
 		case_ast_node(cd, ConstDecl, decl);
 			for_array(i, cd->values) {
@@ -1251,23 +1202,13 @@ void check_global_collect_entities(Checker *c, Scope *parent_scope, AstNodeArray
 			break;
 		}
 	}
-
-	// NOTE(bill): `when` stmts need to be handled after the other as the condition may refer to something
-	// declared after this stmt in source
-	for_array(decl_index, nodes) {
-		AstNode *decl = nodes.e[decl_index];
-		switch (decl->kind) {
-		case_ast_node(ws, WhenStmt, decl);
-			check_global_when_stmt(c, parent_scope, ws, file_scopes);
-		case_end;
-		}
-	}
 }
 
 void check_import_entities(Checker *c, MapScope *file_scopes) {
 	for_array(i, c->delayed_imports) {
-		AstNodeImportDecl *id = c->delayed_imports.e[i].decl;
 		Scope *parent_scope = c->delayed_imports.e[i].parent;
+		AstNode *decl = c->delayed_imports.e[i].decl;
+		ast_node(id, ImportDecl, decl);
 
 		HashKey key = hash_string(id->fullpath);
 		Scope **found = map_scope_get(file_scopes, key);
@@ -1286,6 +1227,19 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 			continue;
 		}
 
+		if (id->cond != NULL) {
+			Operand operand = {Addressing_Invalid};
+			check_expr(c, &operand, id->cond);
+			if (operand.mode != Addressing_Constant || !is_type_boolean(operand.type)) {
+				error_node(id->cond, "Non-constant boolean `when` condition");
+				continue;
+			}
+			if (operand.value.kind == ExactValue_Bool &&
+			    !operand.value.value_bool) {
+				continue;
+			}
+		}
+
 		bool previously_added = false;
 		for_array(import_index, parent_scope->imported) {
 			Scope *prev = parent_scope->imported.e[import_index];
@@ -1366,6 +1320,31 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 			}
 		}
 	}
+
+	for_array(i, c->delayed_foreign_libraries) {
+		Scope *parent_scope = c->delayed_foreign_libraries.e[i].parent;
+		AstNode *decl = c->delayed_foreign_libraries.e[i].decl;
+		ast_node(fl, ForeignLibrary, decl);
+
+		String file_str = fl->filepath.string;
+		String base_dir = fl->base_dir;
+
+		if (!fl->is_system) {
+			gbAllocator a = heap_allocator(); // TODO(bill): Change this allocator
+
+			String rel_path = get_fullpath_relative(a, base_dir, file_str);
+			String import_file = rel_path;
+			if (!gb_file_exists(cast(char *)rel_path.text)) { // NOTE(bill): This should be null terminated
+				String abs_path = get_fullpath_core(a, file_str);
+				if (gb_file_exists(cast(char *)abs_path.text)) {
+					import_file = abs_path;
+				}
+			}
+			file_str = import_file;
+		}
+
+		try_add_foreign_library_path(c, file_str);
+	}
 }
 
 

+ 23 - 26
src/checker/decl.c

@@ -1,10 +1,10 @@
 bool check_is_terminating(AstNode *node);
-void check_stmt         (Checker *c, AstNode *node, u32 flags);
-void check_stmt_list    (Checker *c, AstNodeArray stmts, u32 flags);
-void check_type_decl    (Checker *c, Entity *e, AstNode *type_expr, Type *def, CycleChecker *cycle_checker);
-void check_const_decl   (Checker *c, Entity *e, AstNode *type_expr, AstNode *init_expr);
-void check_proc_decl    (Checker *c, Entity *e, DeclInfo *d);
-void check_var_decl     (Checker *c, Entity *e, Entity **entities, isize entity_count, AstNode *type_expr, AstNode *init_expr);
+void check_stmt          (Checker *c, AstNode *node, u32 flags);
+void check_stmt_list     (Checker *c, AstNodeArray stmts, u32 flags);
+void check_type_decl     (Checker *c, Entity *e, AstNode *type_expr, Type *def, CycleChecker *cycle_checker);
+void check_const_decl    (Checker *c, Entity *e, AstNode *type_expr, AstNode *init_expr);
+void check_proc_decl     (Checker *c, Entity *e, DeclInfo *d);
+void check_var_decl      (Checker *c, Entity *e, Entity **entities, isize entity_count, AstNode *type_expr, AstNode *init_expr);
 
 // NOTE(bill): `content_name` is for debugging and error messages
 Type *check_init_variable(Checker *c, Entity *e, Operand *operand, String context_name) {
@@ -227,23 +227,21 @@ void check_init_constant(Checker *c, Entity *e, Operand *operand) {
 
 	if (operand->mode != Addressing_Constant) {
 		// TODO(bill): better error
-		error_node(operand->expr,
-		      "`%.*s` is not a constant", LIT(ast_node_token(operand->expr).string));
+		error_node(operand->expr, "`%.*s` is not a constant", LIT(ast_node_token(operand->expr).string));
+		if (e->type == NULL) {
+			e->type = t_invalid;
+		}
+		return;
+	}
+	if (!is_type_constant_type(operand->type)) {
+		gbString type_str = type_to_string(operand->type);
+		error_node(operand->expr, "Invalid constant type: `%s`", type_str);
+		gb_string_free(type_str);
 		if (e->type == NULL) {
 			e->type = t_invalid;
 		}
 		return;
 	}
-	// if (!is_type_constant_type(operand->type)) {
-	// 	gbString type_str = type_to_string(operand->type);
-	// 	defer (gb_string_free(type_str));
-	// 	error_node(operand->expr,
-	// 	      "Invalid constant type: `%s`", type_str);
-	// 	if (e->type == NULL) {
-	// 		e->type = t_invalid;
-	// 	}
-	// 	return;
-	// }
 
 	if (e->type == NULL) { // NOTE(bill): type inference
 		e->type = operand->type;
@@ -269,14 +267,13 @@ void check_const_decl(Checker *c, Entity *e, AstNode *type_expr, AstNode *init_e
 
 	if (type_expr) {
 		Type *t = check_type(c, type_expr);
-		// if (!is_type_constant_type(t)) {
-		// 	gbString str = type_to_string(t);
-		// 	defer (gb_string_free(str));
-		// 	error_node(type_expr),
-		// 	      "Invalid constant type `%s`", str);
-		// 	e->type = t_invalid;
-		// 	return;
-		// }
+		if (!is_type_constant_type(t)) {
+			gbString str = type_to_string(t);
+			error_node(type_expr, "Invalid constant type `%s`", str);
+			gb_string_free(str);
+			e->type = t_invalid;
+			return;
+		}
 		e->type = t;
 	}
 

+ 2 - 0
src/checker/expr.c

@@ -149,6 +149,7 @@ void check_local_collect_entities(Checker *c, AstNodeArray nodes, DelayedEntitie
 			gb_temp_arena_memory_end(tmp);
 		case_end;
 
+#if 0
 		case_ast_node(pd, ProcDecl, node);
 			if (!ast_node_expect(pd->name, AstNode_Ident)) {
 				break;
@@ -163,6 +164,7 @@ void check_local_collect_entities(Checker *c, AstNodeArray nodes, DelayedEntitie
 			add_entity_and_decl_info(c, pd->name, e, d);
 			check_entity_decl(c, e, d, NULL, NULL);
 		case_end;
+#endif
 
 		case_ast_node(td, TypeDecl, node);
 			if (!ast_node_expect(td->name, AstNode_Ident)) {

+ 29 - 22
src/checker/stmt.c

@@ -111,6 +111,15 @@ bool check_is_terminating(AstNode *node) {
 		}
 	case_end;
 
+	case_ast_node(ws, WhenStmt, node);
+		if (ws->else_stmt != NULL) {
+			if (check_is_terminating(ws->body) &&
+			    check_is_terminating(ws->else_stmt)) {
+			    return true;
+		    }
+		}
+	case_end;
+
 	case_ast_node(fs, ForStmt, node);
 		if (fs->cond == NULL && !check_has_break(fs->body, true)) {
 			return true;
@@ -283,30 +292,28 @@ typedef struct TypeAndToken {
 void check_when_stmt(Checker *c, AstNodeWhenStmt *ws, u32 flags) {
 	Operand operand = {Addressing_Invalid};
 	check_expr(c, &operand, ws->cond);
-	if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) {
-		error_node(ws->cond, "Non-boolean condition in `when` statement");
-	}
-	if (operand.mode != Addressing_Constant) {
-		error_node(ws->cond, "Non-constant condition in `when` statement");
+	if (operand.mode != Addressing_Constant || !is_type_boolean(operand.type)) {
+		error_node(ws->cond, "Non-constant boolean `when` condition");
+		return;
 	}
 	if (ws->body == NULL || ws->body->kind != AstNode_BlockStmt) {
 		error_node(ws->cond, "Invalid body for `when` statement");
-	} else {
-		if (operand.value.kind == ExactValue_Bool &&
-		    operand.value.value_bool) {
-			check_stmt_list(c, ws->body->BlockStmt.stmts, flags);
-		} else if (ws->else_stmt) {
-			switch (ws->else_stmt->kind) {
-			case AstNode_BlockStmt:
-				check_stmt_list(c, ws->else_stmt->BlockStmt.stmts, flags);
-				break;
-			case AstNode_WhenStmt:
-				check_when_stmt(c, &ws->else_stmt->WhenStmt, flags);
-				break;
-			default:
-				error_node(ws->else_stmt, "Invalid `else` statement in `when` statement");
-				break;
-			}
+		return;
+	}
+	if (operand.value.kind == ExactValue_Bool &&
+	    operand.value.value_bool) {
+		check_stmt_list(c, ws->body->BlockStmt.stmts, flags);
+	} else if (ws->else_stmt) {
+		switch (ws->else_stmt->kind) {
+		case AstNode_BlockStmt:
+			check_stmt_list(c, ws->else_stmt->BlockStmt.stmts, flags);
+			break;
+		case AstNode_WhenStmt:
+			check_when_stmt(c, &ws->else_stmt->WhenStmt, flags);
+			break;
+		default:
+			error_node(ws->else_stmt, "Invalid `else` statement in `when` statement");
+			break;
 		}
 	}
 }
@@ -1085,7 +1092,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 
 	case_ast_node(pd, ProcDecl, node);
 		// NOTE(bill): Handled elsewhere
-	#if 0
+	#if 1
 		// NOTE(bill): This must be handled here so it has access to the parent scope stuff
 		// e.g. using
 		Entity *e = make_entity_procedure(c->allocator, c->context.scope, pd->name->Ident, NULL);

+ 3 - 4
src/main.c

@@ -233,8 +233,8 @@ int main(int argc, char **argv) {
 	gbString lib_str = gb_string_make(heap_allocator(), "Kernel32.lib");
 	// defer (gb_string_free(lib_str));
 	char lib_str_buf[1024] = {0};
-	for_array(i, parser.foreign_libraries) {
-		String lib = parser.foreign_libraries.e[i];
+	for_array(i, checker.info.foreign_libraries) {
+		String lib = checker.info.foreign_libraries.e[i];
 		isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf),
 		                        " %.*s.lib", LIT(lib));
 		lib_str = gb_string_appendc(lib_str, lib_str_buf);
@@ -255,8 +255,7 @@ int main(int argc, char **argv) {
 	// timings_print_all(&timings);
 
 	if (run_output) {
-		win32_exec_command_line_app("odin run",
-			"%.*s.exe", cast(int)base_name_len, output_name);
+		win32_exec_command_line_app("odin run", "%.*s.exe", cast(int)base_name_len, output_name);
 	}
 	#endif
 #endif

+ 120 - 117
src/parser.c

@@ -56,7 +56,6 @@ typedef struct Parser {
 	Array(AstFile)      files;
 	Array(ImportedFile) imports;
 	gbAtomic32          import_index;
-	Array(String)       foreign_libraries;
 	isize               total_token_count;
 	gbMutex             mutex;
 } Parser;
@@ -88,7 +87,8 @@ typedef enum StmtStateFlag {
 
 AstNodeArray make_ast_node_array(AstFile *f) {
 	AstNodeArray a;
-	array_init(&a, gb_arena_allocator(&f->arena));
+	// array_init(&a, gb_arena_allocator(&f->arena));
+	array_init(&a, heap_allocator());
 	return a;
 }
 
@@ -254,16 +254,17 @@ AST_NODE_KIND(_DeclBegin,      "", i32) \
 	}) \
 	AST_NODE_KIND(ImportDecl, "import declaration", struct { \
 		Token token, relpath; \
-		String os, arch;      \
 		String fullpath;      \
 		Token import_name;    \
 		bool is_load;         \
+		AstNode *cond;        \
 		AstNode *note;        \
 	}) \
 	AST_NODE_KIND(ForeignLibrary, "foreign library", struct { \
 		Token token, filepath; \
-		String base_dir; \
-		bool is_system; \
+		String base_dir;       \
+		AstNode *cond;         \
+		bool is_system;        \
 	}) \
 AST_NODE_KIND(_DeclEnd,   "", i32) \
 AST_NODE_KIND(_TypeBegin, "", i32) \
@@ -1005,22 +1006,22 @@ AstNode *make_type_decl(AstFile *f, Token token, AstNode *name, AstNode *type) {
 }
 
 AstNode *make_import_decl(AstFile *f, Token token, Token relpath, Token import_name,
-                          String os, String arch,
+                          AstNode *cond,
                           bool is_load) {
 	AstNode *result = make_node(f, AstNode_ImportDecl);
 	result->ImportDecl.token = token;
 	result->ImportDecl.relpath = relpath;
 	result->ImportDecl.import_name = import_name;
-	result->ImportDecl.os = os;
-	result->ImportDecl.arch = arch;
+	result->ImportDecl.cond = cond;
 	result->ImportDecl.is_load = is_load;
 	return result;
 }
 
-AstNode *make_foreign_library(AstFile *f, Token token, Token filepath, bool is_system) {
+AstNode *make_foreign_library(AstFile *f, Token token, Token filepath, AstNode *cond, bool is_system) {
 	AstNode *result = make_node(f, AstNode_ForeignLibrary);
 	result->ForeignLibrary.token = token;
 	result->ForeignLibrary.filepath = filepath;
+	result->ForeignLibrary.cond = cond;
 	result->ForeignLibrary.is_system = is_system;
 	return result;
 }
@@ -1156,19 +1157,30 @@ bool expect_semicolon_after_stmt(AstFile *f, AstNode *s) {
 		return true;
 	}
 
-	if (f->curr_token.pos.line != f->prev_token.pos.line) {
-		return true;
+	if (s != NULL) {
+		switch (s->kind) {
+		case AstNode_ProcDecl:
+		case AstNode_TypeDecl:
+			return true;
+		}
 	}
 
-	switch (f->curr_token.kind) {
-	case Token_EOF:
-	case Token_CloseBrace:
-		return true;
-	}
+	// if (f->curr_token.pos.line != f->prev_token.pos.line) {
+		// return true;
+	// }
 
-	syntax_error(f->curr_token,
-	             "Expected `;` after %.*s, got `%.*s`",
-	             LIT(ast_node_strings[s->kind]), LIT(token_strings[f->curr_token.kind]));
+	// switch (f->curr_token.kind) {
+	// case Token_EOF:
+	// case Token_CloseBrace:
+		// return true;
+	// }
+
+	if (s != NULL) {
+		syntax_error(f->prev_token, "Expected `;` after %.*s, got `%.*s`",
+		             LIT(ast_node_strings[s->kind]), LIT(token_strings[f->prev_token.kind]));
+	} else {
+		syntax_error(f->prev_token, "Expected `;`");
+	}
 	fix_advance_to_next_stmt(f);
 	return false;
 }
@@ -1197,12 +1209,6 @@ AstNode *parse_tag_expr(AstFile *f, AstNode *expression) {
 	return make_tag_expr(f, token, name, expression);
 }
 
-AstNode *parse_tag_stmt(AstFile *f, AstNode *statement) {
-	Token token = expect_token(f, Token_Hash);
-	Token name  = expect_token(f, Token_Identifier);
-	return make_tag_stmt(f, token, name, statement);
-}
-
 AstNode *unparen_expr(AstNode *node) {
 	for (;;) {
 		if (node->kind != AstNode_ParenExpr)
@@ -2518,10 +2524,8 @@ AstNode *parse_return_stmt(AstFile *f) {
 	    f->curr_token.pos.line == token.pos.line) {
 		results = parse_rhs_expr_list(f);
 	}
-	if (f->curr_token.kind != Token_CloseBrace) {
-		expect_semicolon_after_stmt(f, results.e[0]);
-	}
 
+	expect_semicolon_after_stmt(f, results.e[0]);
 	return make_return_stmt(f, token, results);
 }
 
@@ -2751,11 +2755,11 @@ AstNode *parse_stmt(AstFile *f) {
 	// TODO(bill): other keywords
 	case Token_if:     return parse_if_stmt(f);
 	case Token_when:   return parse_when_stmt(f);
-	case Token_return: return parse_return_stmt(f);
 	case Token_for:    return parse_for_stmt(f);
 	case Token_match:  return parse_match_stmt(f);
 	case Token_defer:  return parse_defer_stmt(f);
 	case Token_asm:    return parse_asm_stmt(f);
+	case Token_return: return parse_return_stmt(f);
 
 	case Token_break:
 	case Token_continue:
@@ -2821,29 +2825,103 @@ AstNode *parse_stmt(AstFile *f) {
 	} break;
 
 	case Token_Hash: {
-		s = parse_tag_stmt(f, NULL);
-		String tag = s->TagStmt.name.string;
+		AstNode *s = NULL;
+		Token hash_token = expect_token(f, Token_Hash);
+		Token name = expect_token(f, Token_Identifier);
+		String tag = name.string;
 		if (str_eq(tag, str_lit("shared_global_scope"))) {
 			if (f->curr_proc == NULL) {
 				f->is_global_scope = true;
-				return make_empty_stmt(f, f->curr_token);
+				s = make_empty_stmt(f, f->curr_token);
+			} else {
+				syntax_error(token, "You cannot use #shared_global_scope within a procedure. This must be done at the file scope");
+				s = make_bad_decl(f, token, f->curr_token);
 			}
-			syntax_error(token, "You cannot use #shared_global_scope within a procedure. This must be done at the file scope");
-			return make_bad_decl(f, token, f->curr_token);
+			expect_semicolon_after_stmt(f, s);
+			return s;
 		} else if (str_eq(tag, str_lit("foreign_system_library"))) {
+			AstNode *cond = NULL;
 			Token file_path = expect_token(f, Token_String);
+
+			if (allow_token(f, Token_when)) {
+				cond = parse_expr(f, false);
+			}
+
 			if (f->curr_proc == NULL) {
-				return make_foreign_library(f, s->TagStmt.token, file_path, true);
+				s = make_foreign_library(f, hash_token, file_path, cond, true);
+			} else {
+				syntax_error(token, "You cannot use #foreign_system_library within a procedure. This must be done at the file scope");
+				s = make_bad_decl(f, token, file_path);
 			}
-			syntax_error(token, "You cannot use #foreign_system_library within a procedure. This must be done at the file scope");
-			return make_bad_decl(f, token, file_path);
+			expect_semicolon_after_stmt(f, s);
+			return s;
 		} else if (str_eq(tag, str_lit("foreign_library"))) {
+			AstNode *cond = NULL;
+			Token file_path = expect_token(f, Token_String);
+
+			if (allow_token(f, Token_when)) {
+				cond = parse_expr(f, false);
+			}
+
+			if (f->curr_proc == NULL) {
+				s = make_foreign_library(f, hash_token, file_path, cond, false);
+			} else {
+				syntax_error(token, "You cannot use #foreign_library within a procedure. This must be done at the file scope");
+				s = make_bad_decl(f, token, file_path);
+			}
+			expect_semicolon_after_stmt(f, s);
+			return s;
+		}  else if (str_eq(tag, str_lit("import"))) {
+			AstNode *cond = NULL;
+			Token import_name = {0};
+
+			switch (f->curr_token.kind) {
+			case Token_Period:
+				import_name = f->curr_token;
+				import_name.kind = Token_Identifier;
+				next_token(f);
+				break;
+			case Token_Identifier:
+				import_name = f->curr_token;
+				next_token(f);
+				break;
+			}
+
+			if (str_eq(import_name.string, str_lit("_"))) {
+				syntax_error(token, "Illegal import name: `_`");
+			}
+
+			Token file_path = expect_token_after(f, Token_String, "#import");
+			if (allow_token(f, Token_when)) {
+				cond = parse_expr(f, false);
+			}
+
+			if (f->curr_proc != NULL) {
+				syntax_error(token, "You cannot use #import within a procedure. This must be done at the file scope");
+				s = make_bad_decl(f, token, file_path);
+			} else {
+				s = make_import_decl(f, hash_token, file_path, import_name, cond, false);
+				expect_semicolon_after_stmt(f, s);
+			}
+			return s;
+		} else if (str_eq(tag, str_lit("include"))) {
+			AstNode *cond = NULL;
 			Token file_path = expect_token(f, Token_String);
+			Token import_name = file_path;
+			import_name.string = str_lit(".");
+
+			if (allow_token(f, Token_when)) {
+				cond = parse_expr(f, false);
+			}
+
 			if (f->curr_proc == NULL) {
-				return make_foreign_library(f, s->TagStmt.token, file_path, false);
+				s = make_import_decl(f, hash_token, file_path, import_name, cond, true);
+			} else {
+				syntax_error(token, "You cannot use #include within a procedure. This must be done at the file scope");
+				s = make_bad_decl(f, token, file_path);
 			}
-			syntax_error(token, "You cannot use #foreign_library within a procedure. This must be done at the file scope");
-			return make_bad_decl(f, token, file_path);
+			expect_semicolon_after_stmt(f, s);
+			return s;
 		} else if (str_eq(tag, str_lit("thread_local"))) {
 			AstNode *var_decl = parse_simple_stmt(f);
 			if (var_decl->kind != AstNode_VarDecl) {
@@ -2870,60 +2948,9 @@ AstNode *parse_stmt(AstFile *f) {
 				syntax_error(token, "#bounds_check and #no_bounds_check cannot be applied together");
 			}
 			return s;
-		} else if (str_eq(tag, str_lit("import"))) {
-			String os = {0};
-			String arch = {0};
-
-			// if (tag.len > 6) {
-			// 	String sub = make_string(tag.text+6, tag.len-6);
-			// }
-
-			// TODO(bill): better error messages
-			Token import_name = {0};
-			Token file_path = expect_token_after(f, Token_String, "#import");
-			if (allow_token(f, Token_as)) {
-				// NOTE(bill): Custom import name
-				if (f->curr_token.kind == Token_Period) {
-					import_name = f->curr_token;
-					import_name.kind = Token_Identifier;
-					next_token(f);
-				} else {
-					import_name = expect_token_after(f, Token_Identifier, "`as` for import declaration");
-				}
-
-				if (str_eq(import_name.string, str_lit("_"))) {
-					syntax_error(token, "Illegal import name: `_`");
-					return make_bad_decl(f, token, f->curr_token);
-				}
-			}
-
-			if (f->curr_proc != NULL) {
-				syntax_error(token, "You cannot use #import within a procedure. This must be done at the file scope");
-				return make_bad_decl(f, token, file_path);
-			}
-
-			return make_import_decl(f, s->TagStmt.token, file_path, import_name, os, arch, false);
-		} else if (str_eq(tag, str_lit("load"))) {
-			String os = {0};
-			String arch = {0};
-			// TODO(bill): better error messages
-			Token file_path = expect_token(f, Token_String);
-			Token import_name = file_path;
-			import_name.string = str_lit(".");
-
-
-
-			if (f->curr_proc == NULL) {
-				return make_import_decl(f, s->TagStmt.token, file_path, import_name, os, arch, true);
-			}
-			syntax_error(token, "You cannot use #load within a procedure. This must be done at the file scope");
-			return make_bad_decl(f, token, file_path);
-		} else {
-
 		}
 
-		s->TagStmt.stmt = parse_stmt(f); // TODO(bill): Find out why this doesn't work as an argument
-		return s;
+		return make_tag_stmt(f, hash_token, name, parse_stmt(f));
 	} break;
 
 	case Token_OpenBrace:
@@ -3016,7 +3043,6 @@ void destroy_ast_file(AstFile *f) {
 bool init_parser(Parser *p) {
 	array_init(&p->files, heap_allocator());
 	array_init(&p->imports, heap_allocator());
-	array_init(&p->foreign_libraries, heap_allocator());
 	gb_mutex_init(&p->mutex);
 	return true;
 }
@@ -3033,7 +3059,6 @@ void destroy_parser(Parser *p) {
 #endif
 	array_free(&p->files);
 	array_free(&p->imports);
-	array_free(&p->foreign_libraries);
 	gb_mutex_destroy(&p->mutex);
 }
 
@@ -3169,43 +3194,21 @@ String get_filepath_extension(String path) {
 	return make_string(path.text, dot);
 }
 
-void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray decls);
-
-void parse_setup_file_when_stmt(Parser *p, AstFile *f, String base_dir, AstNodeWhenStmt *ws) {
-	if (ws->body != NULL && ws->body->kind == AstNode_BlockStmt) {
-		parse_setup_file_decls(p, f, base_dir, ws->body->BlockStmt.stmts);
-	}
-	if (ws->else_stmt) {
-		switch (ws->else_stmt->kind) {
-		case AstNode_BlockStmt:
-			parse_setup_file_decls(p, f, base_dir, ws->else_stmt->BlockStmt.stmts);
-			break;
-		case AstNode_WhenStmt:
-			parse_setup_file_when_stmt(p, f, base_dir, &ws->else_stmt->WhenStmt);
-			break;
-		}
-	}
-}
-
 void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray decls) {
 	for_array(i, decls) {
 		AstNode *node = decls.e[i];
-
 		if (!is_ast_node_decl(node) &&
-		    !is_ast_node_when_stmt(node) &&
 		    node->kind != AstNode_BadStmt &&
 		    node->kind != AstNode_EmptyStmt) {
 			// NOTE(bill): Sanity check
 			syntax_error_node(node, "Only declarations are allowed at file scope %.*s", LIT(ast_node_strings[node->kind]));
-		} else if (node->kind == AstNode_WhenStmt) {
-			parse_setup_file_when_stmt(p, f, base_dir, &node->WhenStmt);
 		} else if (node->kind == AstNode_ImportDecl) {
 			AstNodeImportDecl *id = &node->ImportDecl;
 			String file_str = id->relpath.string;
 
 			if (!is_import_path_valid(file_str)) {
 				if (id->is_load) {
-					syntax_error_node(node, "Invalid #load path: `%.*s`", LIT(file_str));
+					syntax_error_node(node, "Invalid #include path: `%.*s`", LIT(file_str));
 				} else {
 					syntax_error_node(node, "Invalid #import path: `%.*s`", LIT(file_str));
 				}

+ 20 - 13
src/ssa.c

@@ -30,7 +30,6 @@ typedef struct ssaModule {
 	String layout;
 	// String triple;
 
-
 	MapEntity       min_dep_map; // Key: Entity *
 	MapSsaValue     values;      // Key: Entity *
 	MapSsaValue     members;     // Key: String
@@ -192,6 +191,11 @@ struct ssaProcedure {
 	}) \
 	SSA_INSTR_KIND(Phi, struct { ssaValueArray edges; Type *type; }) \
 	SSA_INSTR_KIND(Unreachable, i32) \
+	SSA_INSTR_KIND(UnaryOp, struct { \
+		Type *    type; \
+		TokenKind op; \
+		ssaValue *expr; \
+	}) \
 	SSA_INSTR_KIND(BinaryOp, struct { \
 		Type *    type; \
 		TokenKind op; \
@@ -560,6 +564,8 @@ Type *ssa_instr_type(ssaInstr *instr) {
 		return instr->UnionTagPtr.type;
 	case ssaInstr_UnionTagValue:
 		return instr->UnionTagValue.type;
+	case ssaInstr_UnaryOp:
+		return instr->UnaryOp.type;
 	case ssaInstr_BinaryOp:
 		return instr->BinaryOp.type;
 	case ssaInstr_Conv:
@@ -887,6 +893,15 @@ ssaValue *ssa_make_instr_union_tag_value(ssaProcedure *p, ssaValue *address) {
 	return v;
 }
 
+ssaValue *ssa_make_instr_unary_op(ssaProcedure *p, TokenKind op, ssaValue *expr, Type *type) {
+	ssaValue *v = ssa_alloc_instr(p, ssaInstr_UnaryOp);
+	ssaInstr *i = &v->Instr;
+	i->UnaryOp.op = op;
+	i->UnaryOp.expr = expr;
+	i->UnaryOp.type = type;
+	return v;
+}
+
 
 ssaValue *ssa_make_instr_binary_op(ssaProcedure *p, TokenKind op, ssaValue *left, ssaValue *right, Type *type) {
 	ssaValue *v = ssa_alloc_instr(p, ssaInstr_BinaryOp);
@@ -2619,18 +2634,10 @@ ssaValue *ssa_build_single_expr(ssaProcedure *proc, AstNode *expr, TypeAndValue
 		case Token_Add:
 			return ssa_build_expr(proc, ue->expr);
 
-		case Token_Sub: // NOTE(bill): -`x` == 0 - `x`
-			return ssa_emit_arith(proc, ue->op.kind, v_zero, ssa_build_expr(proc, ue->expr), tv->type);
-
-		case Token_Not:   // Boolean not
-		case Token_Xor: { // Bitwise not
-			// NOTE(bill): "not" `x` == `x` "xor" `-1`
-			ssaValue *left = ssa_build_expr(proc, ue->expr);
-			ssaValue *right = ssa_add_module_constant(proc->module, tv->type, make_exact_value_integer(-1));
-			return ssa_emit_arith(proc, ue->op.kind,
-			                      left, right,
-			                      tv->type);
-		} break;
+		case Token_Not: // Boolean not
+		case Token_Xor: // Bitwise not
+		case Token_Sub: // Bitwise not
+			return ssa_emit(proc, ssa_make_instr_unary_op(proc, ue->op.kind, ssa_build_expr(proc, ue->expr), tv->type));
 		}
 	case_end;
 

+ 49 - 1
src/ssa_print.c

@@ -866,6 +866,55 @@ void ssa_print_instr(ssaFileBuffer *f, ssaModule *m, ssaValue *value) {
 		ssa_fprintf(f, "unreachable\n");
 	} break;
 
+	case ssaInstr_UnaryOp: {
+		ssaInstrUnaryOp *uo = &value->Instr.UnaryOp;
+		Type *type = base_type(ssa_type(uo->expr));
+		Type *elem_type = type;
+		while (elem_type->kind == Type_Vector) {
+			elem_type = base_type(elem_type->Vector.elem);
+		}
+
+		ssa_fprintf(f, "%%%d = ", value->index);
+		switch (uo->op) {
+		case Token_Sub:
+			if (is_type_float(elem_type)) {
+				ssa_fprintf(f, "fsub");
+			} else {
+				ssa_fprintf(f, "sub");
+			}
+			break;
+		case Token_Xor:
+		case Token_Not:
+			GB_ASSERT(is_type_integer(type) || is_type_boolean(type));
+			ssa_fprintf(f, "xor");
+			break;
+		default:
+			GB_PANIC("Unknown unary operator");
+			break;
+		}
+
+		ssa_fprintf(f, " ");
+		ssa_print_type(f, m, type);
+		ssa_fprintf(f, " ");
+		switch (uo->op) {
+		case Token_Sub:
+			if (is_type_float(elem_type)) {
+				ssa_print_exact_value(f, m, make_exact_value_float(0), type);
+			} else {
+				ssa_fprintf(f, "0");
+			}
+			break;
+		case Token_Xor:
+		case Token_Not:
+			GB_ASSERT(is_type_integer(type) || is_type_boolean(type));
+			ssa_fprintf(f, "-1");
+			break;
+		}
+		ssa_fprintf(f, ", ");
+		ssa_print_value(f, m, uo->expr, type);
+		ssa_fprintf(f, "\n");
+	} break;
+
 	case ssaInstr_BinaryOp: {
 		ssaInstrBinaryOp *bo = &value->Instr.BinaryOp;
 		Type *type = base_type(ssa_type(bo->left));
@@ -971,7 +1020,6 @@ void ssa_print_instr(ssaFileBuffer *f, ssaModule *m, ssaValue *value) {
 		ssa_fprintf(f, ", ");
 		ssa_print_value(f, m, bo->right, type);
 		ssa_fprintf(f, "\n");
-
 	} break;
 
 	case ssaInstr_Call: {

+ 2 - 2
src/tokenizer.c

@@ -83,8 +83,8 @@ TOKEN_KIND(Token__OperatorEnd, "_OperatorEnd"), \
 \
 TOKEN_KIND(Token__KeywordBegin, "_KeywordBegin"), \
 	TOKEN_KIND(Token_type,           "type"), \
-	/* TOKEN_KIND(Token_import,         "import"), */ \
-	/* TOKEN_KIND(Token_include,         "include"), */ \
+	/* TOKEN_KIND(Token_import,         "import"),  */\
+	/* TOKEN_KIND(Token_include,        "include"),  */\
 	TOKEN_KIND(Token_proc,           "proc"), \
 	TOKEN_KIND(Token_match,          "match"), \
 	TOKEN_KIND(Token_break,          "break"), \