finalized bugfix with recursive structures
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 5 Feb 2023 20:14:00 +0000 (14:14 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 5 Feb 2023 20:14:00 +0000 (14:14 -0600)
compiler/include/types.h
compiler/src/checker.c
compiler/src/types.c
docs/ideas/high_level_goals.md
shared/lib/linux_x86_64/lib/libovmwasm.so [deleted file]

index 6b164d2e59074a1be887c2784a8cf700cd3503c0..d4321cd6be2edb129ba857163cdc67a4186344b8 100644 (file)
@@ -217,6 +217,7 @@ const char* type_get_name(Type* type);
 u32 type_get_alignment_log2(Type* type);
 Type* type_get_contained_type(Type* type);
 
+b32 type_is_ready_for_lookup(Type* type);
 b32 type_lookup_member(Type* type, char* member, StructMember* smem);
 b32 type_lookup_member_by_idx(Type* type, i32 idx, StructMember* smem);
 
index 2d35aa34de017e3f38223d1d35cf6180af0e8208..87f1bd14b0b66d21c5f8fc4bd58bbd7f0dded4a9 100644 (file)
@@ -1834,16 +1834,14 @@ CheckStatus check_field_access(AstFieldAccess** pfield) {
         token_toggle_end(field->token);
     }
 
-    if (field->expr->type->kind == Type_Kind_Struct) {
-        if (field->expr->type->Struct.status != SPS_Uses_Done) {
-            YIELD(field->token->pos, "Waiting for struct type to be completed before looking up members.");
-        }
-    }
-
     if (!type_is_structlike(field->expr->type)) {
         goto try_resolve_from_type;
     }
 
+    if (!type_is_ready_for_lookup(field->expr->type)) {
+        YIELD(field->token->pos, "Waiting for struct type to be completed before looking up members.");
+    }
+
     StructMember smem;
     if (!type_lookup_member(field->expr->type, field->field, &smem)) {
         if (field->expr->type->kind == Type_Kind_Array) {
index 2e816dc75a467d3d4cbd71c6d1a5e707bcf0dc77..e0db986b6d7eba4ddfd22c0868ce633e5b1c202b 100644 (file)
@@ -256,9 +256,7 @@ u32 type_alignment_of(Type* type) {
     }
 }
 
-// If this function returns NULL, then the caller MUST yield because the type may still be constructed in the future.
-// If there was an error constructing the type, then this function will report that directly.
-Type* type_build_from_ast_inner(bh_allocator alloc, AstType* type_node, b32 accept_partial_types) {
+static Type* type_build_from_ast_inner(bh_allocator alloc, AstType* type_node, b32 accept_partial_types) {
     if (type_node == NULL) return NULL;
 
     switch (type_node->kind) {
@@ -392,8 +390,7 @@ Type* type_build_from_ast_inner(bh_allocator alloc, AstType* type_node, b32 acce
                     return accept_partial_types ? s_node->pending_type : NULL;
                 }
 
-                if ((*member)->type->kind == Type_Kind_Struct
-                    && (*member)->type->Struct.status == SPS_Start) {
+                if ((*member)->type->kind == Type_Kind_Struct && (*member)->type->Struct.status == SPS_Start) {
                     s_node->pending_type_is_valid = 0;
                     return accept_partial_types ? s_node->pending_type : NULL;
                 }
@@ -636,6 +633,8 @@ Type* type_build_from_ast_inner(bh_allocator alloc, AstType* type_node, b32 acce
     return NULL;
 }
 
+// If this function returns NULL, then the caller MUST yield because the type may still be constructed in the future.
+// If there was an error constructing the type, then this function will report that directly.
 Type *type_build_from_ast(bh_allocator alloc, AstType* type_node) {
     return type_build_from_ast_inner(alloc, type_node, 0);
 }
@@ -1146,6 +1145,16 @@ Type* type_get_contained_type(Type* type) {
     }
 }
 
+b32 type_is_ready_for_lookup(Type* type) {
+    if (type->kind == Type_Kind_Pointer) type = type->Pointer.elem;
+
+    if (type->kind == Type_Kind_Struct) {
+        return type->Struct.status == SPS_Uses_Done;
+    }
+
+    return 1;
+}
+
 static const StructMember slice_members[] = {
     { 0,            0, NULL,                         "data",   NULL, NULL, -1, 0, 0 },
     { POINTER_SIZE, 1, &basic_types[Basic_Kind_U32], "count",  NULL, NULL, -1, 0, 0 },
index 66c6bc4550b7fc58e3761f5a8f24d98ec38ff0bd..b4c3ffb96a27ef4f89cbfb3ba4d1802ce0d0928c 100644 (file)
@@ -1,4 +1,5 @@
 High-Level Goals
+================
 
 There are many ideas  that are wizzing around my head
 when I think about the future of Onyx, and I'm having
@@ -8,5 +9,39 @@ timeline will  be beneficial to me  and the future of
 the language.
 
 
+Optimizing OVM instructions
+---------------------------
+As OVM becomes used more and more because of its improved
+debugging experience when compared to runtimes like Wasmer,
+it would be nice if the runtime was a little faster. As
+I look through the generated instructions, I see a lot of
+potential for some relatively easy improvements that can
+be made. This would still be a larger-endeavour, as
+optimizing is not a simple task. Debug information, basic
+blocks and other tricky things have to be dealt with. I
+think this task would take around 2-3 weeks of focused time
+to get something good. 
 
+[Onyx Website](./website.md)
+--------------
+The domains for the website (https://onyxlang.io) is already
+registered, I just need a good-enough website. It does not
+need to be anything super-fancy, yet. Just links and basic-
+documentation.
+
+
+[Generated Documentation](./doc_format.md)
+-----------------------
+
+
+[Core Library Cleanup](./core_libraries.md)
+--------------------
+
+
+[Project Templates](./templated_projects.md)
+------------------
+
+
+[Bundling Onyx for Distribution](./shipping.md)
+-------------------------------
 
diff --git a/shared/lib/linux_x86_64/lib/libovmwasm.so b/shared/lib/linux_x86_64/lib/libovmwasm.so
deleted file mode 100755 (executable)
index 28469a4..0000000
Binary files a/shared/lib/linux_x86_64/lib/libovmwasm.so and /dev/null differ