From: Brendan Hansen Date: Fri, 27 Aug 2021 03:53:16 +0000 (-0500) Subject: scary changes X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=9860d7441ae692f1baf99c65dc400d4d207e7e98;p=onyx.git scary changes --- diff --git a/bin/onyx b/bin/onyx index 293031ee..de8640a7 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/core/conv.onyx b/core/conv.onyx index acf53c87..00fbe9ae 100644 --- a/core/conv.onyx +++ b/core/conv.onyx @@ -104,7 +104,6 @@ i64_to_str :: (n: i64, base: u64, buf: [] u8, min_length := 0, prefix := false) c := ^buf[buf.count - 1]; len := 0; - @Bug // Make this work with '::'; BASE64_MAP := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; while n > 0 { diff --git a/modules/ui/components/workspace.onyx b/modules/ui/components/workspace.onyx index 84b2a6b5..eba50d64 100644 --- a/modules/ui/components/workspace.onyx +++ b/modules/ui/components/workspace.onyx @@ -41,15 +41,13 @@ workspace_start :: (use r: Rectangle, site := #callsite, state: ^Workspace_State if state.transform_transition > 0.0f { move_towards(^state.transform_transition, 0, 0.08f); - use state; - - if transform_transition == 0.0f { - transform.translation.x = target_transform.translation.x; - transform.translation.y = target_transform.translation.y; + if state.transform_transition == 0.0f { + state.transform.translation.x = state.target_transform.translation.x; + state.transform.translation.y = state.target_transform.translation.y; } else { - transform.translation.x = (transform.translation.x + target_transform.translation.x) / 2; - transform.translation.y = (transform.translation.y + target_transform.translation.y) / 2; + state.transform.translation.x = (state.transform.translation.x + state.target_transform.translation.x) / 2; + state.transform.translation.y = (state.transform.translation.y + state.target_transform.translation.y) / 2; } } diff --git a/src/onyx.c b/src/onyx.c index 46c410a6..0f6d6722 100644 --- a/src/onyx.c +++ b/src/onyx.c @@ -459,16 +459,21 @@ static i32 onyx_compile() { // cycle detection algorithm must be used. // static Entity* watermarked_node = NULL; + static u32 highest_watermark = 0; if (!changed) { if (!watermarked_node) { watermarked_node = ent; + highest_watermark = bh_max(highest_watermark, ent->macro_attempts); } else if (watermarked_node == ent) { - entity_heap_insert_existing(&context.entities, ent); - dump_cycles(); + if (ent->macro_attempts > highest_watermark) { + entity_heap_insert_existing(&context.entities, ent); + dump_cycles(); + } } else if (watermarked_node->macro_attempts < ent->macro_attempts) { watermarked_node = ent; + highest_watermark = bh_max(highest_watermark, ent->macro_attempts); } } else { watermarked_node = NULL; diff --git a/src/onyxastnodes.c b/src/onyxastnodes.c index 97a03128..1f6fb991 100644 --- a/src/onyxastnodes.c +++ b/src/onyxastnodes.c @@ -511,6 +511,7 @@ b32 type_check_or_auto_cast(AstTyped** pnode, Type* type) { // if (node_is_type((AstNode *) node)) return 0; if (node->kind == Ast_Kind_Struct_Literal && node->type_node == NULL) { + if (node->entity != NULL) return 1; if (type->kind == Type_Kind_VarArgs) type = type->VarArgs.ptr_to_data->Pointer.elem; if (!type_is_sl_constructable(type)) return 0; @@ -521,6 +522,7 @@ b32 type_check_or_auto_cast(AstTyped** pnode, Type* type) { } if (node->kind == Ast_Kind_Array_Literal && node->type_node == NULL) { + if (node->entity != NULL) return 1; node->type = type; node->flags |= Ast_Flag_Array_Literal_Typed; diff --git a/src/onyxchecker.c b/src/onyxchecker.c index e4c99dd3..7e2b1a44 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -1019,6 +1019,8 @@ static AstCall* binaryop_try_operator_overload(AstBinaryOp* binop) { CheckStatus check_binaryop(AstBinaryOp** pbinop) { AstBinaryOp* binop = *pbinop; + if (binop->flags & Ast_Flag_Has_Been_Checked) return Check_Success; + u32 current_checking_level_store = current_checking_level; CHECK(expression, &binop->left); CHECK(expression, &binop->right); @@ -1129,6 +1131,8 @@ CheckStatus check_binaryop(AstBinaryOp** pbinop) { binop->type = &basic_types[Basic_Kind_Bool]; } + binop->flags |= Ast_Flag_Has_Been_Checked; + if (binop->flags & Ast_Flag_Comptime) { // NOTE: Not a binary op *pbinop = (AstBinaryOp *) ast_reduce(context.ast_alloc, (AstTyped *) binop); @@ -2018,7 +2022,7 @@ CheckStatus check_overloaded_function(AstOverloadedFunction* func) { CheckStatus check_struct(AstStructType* s_node) { if (s_node->entity_defaults && s_node->entity_defaults->state < Entity_State_Check_Types) - YIELD(s_node->token->pos, "Waiting for struct member definitions to pass symbol resolution."); + YIELD(s_node->token->pos, "Waiting for struct member defaults to pass symbol resolution."); bh_arr_each(AstStructMember *, smem, s_node->members) { if ((*smem)->type_node != NULL) { @@ -2081,8 +2085,8 @@ CheckStatus check_struct_defaults(AstStructType* s_node) { } CheckStatus check_function_header(AstFunction* func) { - if (func->entity_body && func->entity_body->state < Entity_State_Check_Types) - YIELD(func->token->pos, "Waiting for function header to complete symbol resolution"); + //if (func->entity_body && func->entity_body->state < Entity_State_Check_Types) + // YIELD(func->token->pos, "Waiting for function body to complete symbol resolution to check header."); b32 expect_default_param = 0; b32 has_had_varargs = 0; diff --git a/src/onyxparser.c b/src/onyxparser.c index 391ac9c8..5bffc962 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -570,6 +570,7 @@ static AstTyped* parse_factor(OnyxParser* parser) { } else if (parse_possible_directive(parser, "type")) { AstTypeAlias* alias = make_node(AstTypeAlias, Ast_Kind_Type_Alias); + alias->token = parser->curr - 2; alias->to = parse_type(parser); retval = (AstTyped *) alias; break; diff --git a/src/onyxsymres.c b/src/onyxsymres.c index d58cd4fc..d0599222 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -748,11 +748,12 @@ static SymresStatus symres_directive_solidify(AstDirectiveSolidify** psolid) { static SymresStatus symres_directive_defined(AstDirectiveDefined** pdefined) { AstDirectiveDefined* defined = *pdefined; + b32 use_package_count = (context.entities.type_count[Entity_Type_Use_Package] == 0); b32 old_report_unresolved_symbols = report_unresolved_symbols; report_unresolved_symbols = 0; SymresStatus ss = symres_expression(&defined->expr); - if (old_report_unresolved_symbols && ss != Symres_Success) { + if ((use_package_count || old_report_unresolved_symbols) && ss != Symres_Success) { // The symbol definitely was not found and there is no chance that it could be found. defined->is_defined = 0; @@ -1061,9 +1062,9 @@ static SymresStatus symres_struct_defaults(AstType* t) { // CLEANUP: I hate that this is here. The type inference for a struct member should happen once the actual type is known. // There seems to be a problem with setting it in the checker however, because whenever I disable this code, somehow // the compiler gets to the code generation without all the types figured out??? - if ((*smem)->type_node == NULL && (*smem)->initial_value->type_node != NULL) { - (*smem)->type_node = (*smem)->initial_value->type_node; - } + // if ((*smem)->type_node == NULL && (*smem)->initial_value->type_node != NULL) { + // (*smem)->type_node = (*smem)->initial_value->type_node; + // } } } @@ -1194,9 +1195,10 @@ void symres_entity(Entity* ent) { scope_enter(ent->scope); } - report_unresolved_symbols = (context.entities.type_count[Entity_Type_Static_If] == 0 && - context.entities.type_count[Entity_Type_Use_Package] == 0) - || context.cycle_detected; + report_unresolved_symbols = context.cycle_detected; + //(context.entities.type_count[Entity_Type_Static_If] == 0 && + // context.entities.type_count[Entity_Type_Use_Package] == 0) + //|| context.cycle_detected; SymresStatus ss = Symres_Success; EntityState next_state = Entity_State_Check_Types;