bugfixes and changed how compound types are parsed
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 4 Jun 2021 04:11:35 +0000 (23:11 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 4 Jun 2021 04:11:35 +0000 (23:11 -0500)
bin/onyx
modules/immediate_mode/immediate_renderer.onyx
src/onyxchecker.c
src/onyxparser.c

index 934d7e560aa0fbce51d72f68cae8e3e04a1f76a9..92494b97dca9749225e652172fefebe84d78179e 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index ba7d925913495d1c87e1883c0756cc95a8ee0dd4..3c565a36e04f401a9d5a0595886c46ff0c978b8a 100644 (file)
@@ -175,25 +175,29 @@ Immediate_Renderer :: struct {
     set_texture :: (use ir: ^Immediate_Renderer, texture_id: i32 = -1) {
         if vertex_count > 0 do flush(ir);
 
+        previous_active := active_shader;
         if texture_id >= 0 do active_shader = ^textured_shader;
         else               do active_shader = ^simple_shader;
 
+        // Skip the GL calls if the texture didn't change.
+        if previous_active == active_shader do return;
+
         gl.useProgram(active_shader.program);
         gl.uniform1i(active_shader.texture_uniform, math.max(texture_id, 0));
     }
 
     use_ortho_projection :: (use ir: ^Immediate_Renderer, left: f32, right: f32, top: f32, bottom: f32) {
         projection_matrix := f32.[
-            2 / (right - left), 0, 0, -(right + left) / (right - left),
-            0, 2 / (top - bottom), 0, -(top + bottom) / (top - bottom),
-            0, 0, -2, -1,
-            0, 0, 0, 1
+            2 / (right - left), 0, 0, 0,
+            0, 2 / (top - bottom), 0, 0,
+            0, 0, -2, 0,
+            -(right + left) / (right - left), -(top + bottom) / (top - bottom), -1, 1
         ];
 
         gl.useProgram(simple_shader.program);
-        gl.uniformMatrix4(simple_shader.view_uniform, true, projection_matrix);
+        gl.uniformMatrix4(simple_shader.view_uniform, false, projection_matrix);
         gl.useProgram(textured_shader.program);
-        gl.uniformMatrix4(textured_shader.view_uniform, true, projection_matrix);
+        gl.uniformMatrix4(textured_shader.view_uniform, false, projection_matrix);
 
         gl.useProgram(active_shader.program);
     }
index 78efb99a5cb2c4d043f0a375df1915ad734e6300..0a4a82fd4a9fb2a0aa748bcf3a769878701c5555 100644 (file)
@@ -1659,8 +1659,12 @@ CheckStatus check_overloaded_function(AstOverloadedFunction* func) {
             return Check_Error;
         }
 
-        if (node->entity && node->entity->state <= Entity_State_Check_Types) {
-            done = 0;
+        if (node->kind == Ast_Kind_Function) {
+            AstFunction* func = (AstFunction *) node;
+            
+            if (func->entity_header && func->entity_header->state <= Entity_State_Check_Types) {
+                done = 0;
+            }
         }
     }
 
index f70149986c448052b69c6876d6905d1a3fa0046b..7643dc9c309f70d8942c7da6023d626c4f764187 100644 (file)
@@ -1417,6 +1417,14 @@ static void parse_polymorphic_variable(OnyxParser* parser, AstType*** next_inser
 }
 
 static AstType* parse_compound_type(OnyxParser* parser) {
+    // CLEANUP this is little weird having this here because it means that this parses:
+    //
+    //      foo :: (x: (something_here: i32)) -> void ---
+    //
+    if (next_tokens_are(parser, 2, Token_Type_Symbol, ':')) {
+        consume_tokens(parser, 2);
+    }
+
     AstType* first = parse_type(parser);
 
     if (parser->curr->type == ',') {
@@ -1428,6 +1436,11 @@ static AstType* parse_compound_type(OnyxParser* parser) {
 
         while (consume_token_if_next(parser, ',')) {
             if (parser->hit_unexpected_token) return (AstType *) ctype;
+
+            if (next_tokens_are(parser, 2, Token_Type_Symbol, ':')) {
+                consume_tokens(parser, 2);
+            }
+
             bh_arr_push(ctype->types, parse_type(parser));
         }