bug fix with solidify directives
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 19 Jan 2021 02:58:35 +0000 (20:58 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 19 Jan 2021 02:58:35 +0000 (20:58 -0600)
bin/onyx
core/memory.onyx
onyx.exe
progs/poly_solidify.onyx
src/onyxparser.c
src/onyxsymres.c

index 29b9c4413aa156a76f3886aa368ebf75eb988394..2aa21033c93ca2c7d0ca828183d314962cb6e074 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index fd7f0805233f3f1d8ba09a9908920e855b519984..6502d264b9fbbefd5aac59dc64ddf7800434748c 100644 (file)
@@ -14,4 +14,11 @@ set :: proc (start: rawptr, length: u32, value: u8) {
 alloc_slice :: proc (sl: ^[] $T, count: i32) {
     sl.data  = calloc(sizeof T * count);
     sl.count = count;
+}
+
+make_slice :: proc ($T: type_expr, count: i32) -> [] T {
+    return <[] T>.{
+        data = calloc(sizeof T * count),
+        count = count
+    };
 }
\ No newline at end of file
index f188c723d4724f39f4fcbe9ebf23f962c4224f6a..06ab89e108cb35e367dbba5c28333add041e1dc4 100644 (file)
Binary files a/onyx.exe and b/onyx.exe differ
index ca4db5c6c320159fde8987e9cb102035c71c65fa..686f20df977fb55ebb9b260bb35840324ec16ece 100644 (file)
@@ -22,10 +22,8 @@ main :: proc (args: [] cstr) {
         proc (b: f32) -> f64 { return ~~(b + 6); }));
 
 
-    arr1 : [..] f32;
-    arr2 : [..] i32;
-    array.init(^arr1);
-    array.init(^arr2);
+    arr1 := array.make(f32);
+    arr2 := array.make(i32);
     defer array.free(^arr1);
     defer array.free(^arr2);
 
@@ -71,7 +69,7 @@ array_map :: proc (arr: [..] $T, f: proc (T) -> T) {
         }
     }
 
-    InternalStruct :: struct ($SOMETHING) {
+    InternalStruct :: struct (SOMETHING: type_expr) {
         foo : SOMETHING;
     }
 }
index 7cf8789a9eca46e2bf500d459dccc3aba0135022..a896c54df50839eac98baede9c6bd659f53bf160 100644 (file)
@@ -548,11 +548,8 @@ static AstTyped* parse_factor(OnyxParser* parser) {
                     expect_token(parser, '=');
                     AstType* poly_type = parse_type(parser);
 
-                    PolySolutionKind sln_kind = PSK_Type;
-                    if (!node_is_type((AstNode *) poly_type)) sln_kind = PSK_Value;
-
                     bh_arr_push(solid->known_polyvars, ((AstPolySolution) {
-                        .kind     = sln_kind,
+                        .kind     = PSK_Undefined,
                         .poly_sym = poly_var,
                         .ast_type = poly_type,
                         .type     = NULL
index c61fc523c85c44d05a700af9334bb0552b95f456..fbf1f0923a17660003453641c833645853610553 100644 (file)
@@ -565,8 +565,17 @@ static void symres_directive_solidify(AstDirectiveSolidify** psolid) {
     }
 
     bh_arr_each(AstPolySolution, sln, solid->known_polyvars) {
-        sln->ast_type = symres_type(sln->ast_type);
-        sln->type = type_build_from_ast(semstate.node_allocator, sln->ast_type);
+        // HACK: This assumes that 'ast_type' and 'value' are at the same offset.
+        symres_expression(&sln->value);
+        if (onyx_has_errors()) return;
+
+        if (node_is_type(sln->value)) {
+            sln->type = type_build_from_ast(semstate.node_allocator, sln->ast_type);
+            sln->kind = PSK_Type;
+        } else {
+            sln->kind = PSK_Value;
+        }
+
         if (onyx_has_errors()) return;
     }