aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2021-11-07 14:48:38 +0100
committerDaniel Gavin <danielgavin5@hotmail.com>2021-11-07 14:48:38 +0100
commit75c285df42289f366c3a44dc8e68c24cffc3d750 (patch)
tree9ee98d9c8e07b10b9ff207f1f1568ad02e5c4bf6
parent917290ea36927e59b13b72b9e0c53a5fce463098 (diff)
Add new matrix type
-rw-r--r--src/common/ast.odin2
-rw-r--r--src/index/clone.odin3
-rw-r--r--src/server/response.odin6
-rw-r--r--tests/completions_test.odin81
4 files changed, 87 insertions, 5 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin
index 742a477..21d6665 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -399,6 +399,8 @@ free_ast_node :: proc(node: ^ast.Node, allocator: mem.Allocator) {
free_ast(n.value, allocator);
case Multi_Pointer_Type:
free_ast(n.elem, allocator);
+ case Matrix_Type:
+ free_ast(n.elem, allocator);
case:
panic(fmt.aprintf("free Unhandled node kind: %T", n));
}
diff --git a/src/index/clone.odin b/src/index/clone.odin
index ece39d2..6fe3b63 100644
--- a/src/index/clone.odin
+++ b/src/index/clone.odin
@@ -248,6 +248,9 @@ clone_node :: proc(node: ^ast.Node, allocator: mem.Allocator, unique_strings: ^m
case Multi_Pointer_Type:
r := cast(^Multi_Pointer_Type)res;
r.elem = clone_type(r.elem, allocator, unique_strings);
+ case Matrix_Type:
+ r := cast(^Matrix_Type)res;
+ r.elem = clone_type(r.elem, allocator, unique_strings);
case:
panic(fmt.aprintf("Clone type Unhandled node kind: %T", node.derived));
}
diff --git a/src/server/response.odin b/src/server/response.odin
index 0d9cf2e..c132532 100644
--- a/src/server/response.odin
+++ b/src/server/response.odin
@@ -7,7 +7,7 @@ send_notification :: proc (notification: Notification, writer: ^Writer) -> bool
data, error := json.marshal(notification, context.temp_allocator);
- header := fmt.tprintf("Content-Length: {}\r\n\r\n", len(data));
+ header := fmt.tprintf("Content-Length: %v\r\n\r\n", len(data));
if error != .None {
return false;
@@ -28,7 +28,7 @@ send_response :: proc (response: ResponseMessage, writer: ^Writer) -> bool {
data, error := json.marshal(response, context.temp_allocator);
- header := fmt.tprintf("Content-Length: {}\r\n\r\n", len(data));
+ header := fmt.tprintf("Content-Length: %v\r\n\r\n", len(data));
if error != .None {
return false;
@@ -49,7 +49,7 @@ send_error :: proc (response: ResponseMessageError, writer: ^Writer) -> bool {
data, error := json.marshal(response, context.temp_allocator);
- header := fmt.tprintf("Content-Length: {}\r\n\r\n", len(data));
+ header := fmt.tprintf("Content-Length: %v\r\n\r\n", len(data));
if error != .None {
return false;
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 74c6dee..0baf401 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -529,9 +529,21 @@ ast_completion_poly_struct_proc :: proc(t: ^testing.T) {
test.expect_completion_details(t, &source, "", {"RenderPass.list: ^int"});
}
+@(test)
+ast_completion_context_temp :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ main :: proc() {
+ context.*
+ }
+ `,
+ packages = {},
+ };
+
+ test.expect_completion_details(t, &source, "", {""});
+}
-/*
- Figure out whether i want to introduce the runtime to the tests
@(test)
ast_generic_make_completion :: proc(t: ^testing.T) {
@@ -572,6 +584,71 @@ ast_generic_make_completion :: proc(t: ^testing.T) {
test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"});
}
+
+
+@(test)
+ast_struct_for_in_switch_stmt_completion :: proc(t: ^testing.T) {
+
+ source := test.Source {
+ main = `package test
+ PlatformContext :: struct {
+ windows: [dynamic]Window,
+ running: bool,
+ }
+
+ platform_context: PlatformContext;
+
+ Window :: struct {
+ width: int,
+ height: int,
+ }
+
+ switch (message) {
+ case win32.WM_SIZE:
+ for w in platform_context.windows {
+ w.*
+ }
+ }
+ `,
+ };
+
+ test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"});
+}
+
+/*
+ Looks like a bug in for each on w.*
+
+
+
+ window_proc :: proc "std" (window: win32.Hwnd, message: u32, w_param: win32.Wparam, l_param: win32.Lparam) -> win32.Lresult {
+
+ result: win32.Lresult;
+
+ context = runtime.default_context();
+
+ switch (message) {
+ case win32.WM_DESTROY:
+ win32.post_quit_message(0);
+ case win32.WM_SIZE:
+ width := bits.bitfield_extract_int(cast(int)l_param, 0, 16);
+ height := bits.bitfield_extract_int(cast(int)l_param, 16, 16);
+
+ for w in platform_context.windows {
+
+ }
+
+ case:
+ result = win32.def_window_proc_a(window, message, w_param, l_param);
+ }
+
+ return result;
+ }
+*/
+
+/*
+ Figure out whether i want to introduce the runtime to the tests
+
+
*/
/*