testing with varargs
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 28 Sep 2020 02:22:16 +0000 (21:22 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 28 Sep 2020 02:22:16 +0000 (21:22 -0500)
core/stdio.onyx
docs/plan
onyx
progs/vararg_test.onyx
src/onyxchecker.c

index f37512fda5ab843cf6678e690c4cb05257742770..9f397d83def4edc7646b40c8283816a8b16d9c8a 100644 (file)
@@ -49,7 +49,6 @@ printf :: proc (format: string, va: ...) {
     len := 0;
 
     state := 0;
-
     for ch: format do switch (state) {
         case 0 {
             if ch == #char "%" do state = 1;
@@ -59,7 +58,7 @@ printf :: proc (format: string, va: ...) {
             }
         }
 
-        case 1 {
+        case #default {
             switch (ch) {
                 case #char "%" { buffer[len] = ch; len += 1; }
 
index bbf3a28d2bd9a36ef2a6ecd93af61142bfef0101..f4f9e532afbb7feeca506943fd41712e2a5f6172 100644 (file)
--- a/docs/plan
+++ b/docs/plan
@@ -274,7 +274,7 @@ HOW:
 
         [ ] explicit memory controls at top level
 
-        [ ] 'use' enums and packages at an arbitrary scope
+        [X] 'use' enums and packages at an arbitrary scope
 
         [ ] look into creating a source map
             - first-look looks really gross
@@ -295,7 +295,7 @@ HOW:
             - Compile time conditions
             - Only evalutate code blocks that evaluate to be true
 
-        [ ] Top level variable initialization
+        [X] Top level variable initialization
             - Works for numeric literals
 
         [ ] multiple lvals and compound assignment
diff --git a/onyx b/onyx
index d18afafd741cdbb3469a06597f3fbdb6422250e1..7d901db82bacb5bec2d66a15b90397174f0b91fc 100755 (executable)
Binary files a/onyx and b/onyx differ
index eddefa22f052d27f3d1a076b4c7ddae77f7bb24e..eeb515e99dca12bb347a644d94c3336ec2e2b305 100644 (file)
@@ -4,24 +4,29 @@ package main
 
 use package core;
 
-old_va_test :: proc (prefix: string, va: ..i32) {
-    println(prefix);
+old_va_test :: proc (fix: Fixes, va: ..i32) {
+    println(fix.prefix);
     for v: va do println(v);
+    println(fix.suffix);
 }
 
-new_va_test :: proc (prefix: string, va: ...) {
-    println(prefix);
+Fixes :: struct { prefix: string; suffix: string; }
+
+new_va_test :: proc (fix: Fixes, va: ...) {
+    println(fix.prefix);
 
     for i: 0 .. va.count {
         x : i32;
         vararg_get(va, ^x);
         println(x);
     }
+
+    println(fix.suffix);
 }
 
 main :: proc (args: [] cstring) {
-    new_va_test("foo", 1, 2, 3.0f, 5.0f);
-    old_va_test("bar", 1);
+    new_va_test(Fixes.{ "foo", "foozle" }, 1, 2, 3.0f, 5.0f);
+    old_va_test(Fixes.{ "bar", "barzle" }, 1);
 
-    printf("Hello, %i, %s!\n", 1234, "World");
+    printf("Hello, %%%i, %s!\n", 1234, "World");
 }
index ebe8cadd5fe117258ec87ed83bab1e14c28bcf08..4b1a32614af633643e53f92e05e20ff6b94ca46b 100644 (file)
@@ -1237,12 +1237,12 @@ b32 check_block(AstBlock* block) {
     bh_table_each_start(AstTyped *, block->scope->symbols);
         fill_in_type(value);
 
-        if (value->type == NULL) {
-            onyx_report_error(value->token->pos,
-                    "Unable to resolve type for local '%b'.",
-                    value->token->text, value->token->length);
-            return 1;
-        }
+        // if (value->type == NULL) {
+        //     onyx_report_error(value->token->pos,
+        //             "Unable to resolve type for local '%b'.",
+        //             value->token->text, value->token->length);
+        //     return 1;
+        // }
     bh_table_each_end;
 
     return 0;