2331b49805b9 — Leonard Ritter tip 3 days ago
* compiler.C: generate struct declarations before procs
3 files changed, 12 insertions(+), 2 deletions(-)

M include/noir.h
M lib/scopes/compiler/noir/target/C.sc
M testing/noir/hello.sc
M include/noir.h +3 -1
@@ 198,7 198,9 @@ static const char NOIR_ID_V(NOIR_empty)[
     NOIR_DEFINED_FROM(X, P) \
     NOIR_ID_V(X) = NOIR_CAST(P, NOIR_ID_T(X));
 
-#define NOIR_instance(X, PID, ...)
+#define NOIR_instance(X, PID, ...) \
+    NOIR_DEFINED(X) \
+    NOIR_RCAST(X, NOIR_ptr) = malloc(sizeof(NOIR_STRUCT_T(PID)));
 #define NOIR_msizeof(X, P) \
     NOIR_DEFINED(X) \
     NOIR_RCAST(X, size_t) = arcsize(NOIR_CAST(P, NOIR_ptr));

          
M lib/scopes/compiler/noir/target/C.sc +5 -0
@@ 326,6 326,11 @@ fn module-printer (self print module-ind
         print
             /pn
                 /C:call "NOIR_STRUCT_END"
+
+    for proc in self.proc
+        procid := proc.id
+        /procid := /id procid
+        PT := 'schemaof module-index procid
         proc-order := 'scheduleof module-index procid
 
         inline sizeofvalue (id)

          
M testing/noir/hello.sc +4 -1
@@ 17,11 17,14 @@ y := VA x x
 TRACE
     COUNTOF y
 
+macro testf :
+    pcall printf_s32_s32_s32 printf "hell(o) world! %i %i %i\n" x
+
 fn main : s32
     argc : s32
     argv : ptr
     do
-        pcall printf_s32_s32_s32 printf "hell(o) world! %i %i %i\n" x
+        testf;
         if (ieq argc 2)
             pcall printf_ printf "two arguments passed\n"
         else