made struct literals more package friendly and fixed scratch allocation
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 11 Dec 2020 21:11:46 +0000 (15:11 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 11 Dec 2020 21:11:46 +0000 (15:11 -0600)
bugs

.vimspector.json
CHANGELOG
docs/todo
onyx
progs/foo_test.onyx
progs/odin_example.onyx
src/onyx.c

index 661905272080046ad56a7fda233ddc718aee7d6e..051f91275bfb03125b6841803b193bf67fdb74bb 100644 (file)
@@ -6,7 +6,7 @@
                 "type": "cppdbg",
                 "request": "launch",
                 "program": "${workspaceFolder}/onyx",
-                "args": ["-verbose", "tests/i32map.onyx"],
+                "args": ["-verbose", "tests/hello_world.onyx"],
                 "stopAtEntry": true,
                 "cwd": "~/dev/c/onyx",
                 "environment": [],
index f9816a44d187839af46e7e40f29dce00294a09c3..5fb62ab704a18c24c33a982d69ac2793f8dc05f5 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,8 +5,11 @@ Additions:
 Removals:
 
 Changes:
+* struct literals can now have arbitrary package prefixes on them, i.e.
+    some.deeply.nested.packages.Struct.{ ... };
 
 Bug fixes:
+* globals that were #foreign caused several bugs, which have been squashed.
 
 
 
index 4f97f4924fbed96f0fc56eb9d143cc81302f2ec2..752156df7071ab99de11966146ec0886b3c05e16 100644 (file)
--- a/docs/todo
+++ b/docs/todo
@@ -44,7 +44,7 @@ Language Cohesion:
     of technical laziness. Cleaning up these areas will help the language feel
     more cohesive and put together.
 
-    [ ] Struct literals can only have 1 level of package before the struct
+    [X] Struct literals can only have 1 level of package before the struct
         name. This is because packages were not able to be nested, so having
         arbitrary package levels before a struct literal was not necessary.
         The following should work when this is patched:
diff --git a/onyx b/onyx
index 2248b973e3042199fa153786766d78384f7d5a81..e06f4f93635afe6515cae6b5fbcbb251f8087f2d 100755 (executable)
Binary files a/onyx and b/onyx differ
index e372dfa337c9d4188fded78aad3b805dfa13f65d..08e0f2a97646d3a4d36c69b15e5e4b4a2c862a29 100644 (file)
@@ -2,4 +2,6 @@ package test.foo
 
 use package core
 
+TestFoo :: struct { a: i32; }
+
 print_foo :: proc () do println("Foo!");
index 9a392dab54f5f83689f51d22bb045eb798a0b4ef..76fb770daed642cf34d407ca5663d912884b57c0 100644 (file)
@@ -3,6 +3,7 @@
 
 use package core
 use package test { foo as foo_pkg }
+use package test as test
 
 Foo :: struct {
     data1 : i32;
@@ -11,7 +12,7 @@ Foo :: struct {
 
 Bar :: struct {
     use foo : Foo;
-    bar_data : string;
+    bar_data : str;
     // bar_data2 : cstring;
 }
 
@@ -57,8 +58,10 @@ make_bar :: proc () -> Bar {
     return bar;
 }
 
-main :: proc (args: [] cstring) {
+main :: proc (args: [] cstr) {
     foo_pkg.print_foo();
+    foo := test.foo.TestFoo.{ a = 1234 };
+    printf("foo.a: %i\n", foo.a);
 
     bar := make_bar();
 
index a65e53a7559ecb9faeae8966102971b53739a6c5..a649da20f25f0147fd63a539d3712ecc8f54e85f 100644 (file)
@@ -522,7 +522,7 @@ static i32 onyx_compile(CompilerState* compiler_state) {
 
 int main(int argc, char *argv[]) {
 
-    bh_scratch_init(&global_scratch, bh_heap_allocator(), 16 * 1024); // NOTE: 16 KB
+    bh_scratch_init(&global_scratch, bh_heap_allocator(), 128 * 1024); // NOTE: 128 KB
     global_scratch_allocator = bh_scratch_allocator(&global_scratch);
 
     bh_managed_heap_init(&global_heap);