From: Brendan Hansen Date: Fri, 4 Jun 2021 04:11:35 +0000 (-0500) Subject: bugfixes and changed how compound types are parsed X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=0eabafaeba7067314c5af04fea51aa9796a1a793;p=onyx.git bugfixes and changed how compound types are parsed --- diff --git a/bin/onyx b/bin/onyx index 934d7e56..92494b97 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/modules/immediate_mode/immediate_renderer.onyx b/modules/immediate_mode/immediate_renderer.onyx index ba7d9259..3c565a36 100644 --- a/modules/immediate_mode/immediate_renderer.onyx +++ b/modules/immediate_mode/immediate_renderer.onyx @@ -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); } diff --git a/src/onyxchecker.c b/src/onyxchecker.c index 78efb99a..0a4a82fd 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -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; + } } } diff --git a/src/onyxparser.c b/src/onyxparser.c index f7014998..7643dc9c 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -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)); }