working on build_opts variables
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 9 Feb 2021 04:24:51 +0000 (22:24 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 9 Feb 2021 04:24:51 +0000 (22:24 -0600)
bin/onyx
core/build_opts.onyx
include/onyxastnodes.h
progs/poly_solidify.onyx
src/onyx.c
src/onyxbuiltins.c

index 4433438845d5a123128d0b2596910b9dfdfdc8be..86d696fd0f8e7971b8d91e93f52cdab107ebe790 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index ddebe1a56cad8a22a1652d71c777dd199705ce4e..11f1cf9551e6d1622c7ebe9e4b9128c241096af3 100644 (file)
@@ -1,9 +1,13 @@
-// This following sybmols are  not meant to be included in any compilation.
+// This following sybmols are not meant to be included in any compilation.
 // Instead, all of the commented out symbols are defined automatically by the compiler
 // and can be used in compile time #if statements.
 
 // Runtime :: Runtime_Wasi   OR   Runtime_Js   OR   Runtime_Custom
 
+
+
+
+
 package build_opts
 
 
index 0df44681bb58405f1ef891da9252374fd099710f..069fdbfb1b9e8e1d762b7d66c8fa58211e9e2418 100644 (file)
@@ -1101,6 +1101,7 @@ extern bh_table(OnyxIntrinsic) intrinsic_table;
 extern bh_arr(AstTyped *) operator_overloads[Binary_Op_Count];
 
 void initialize_builtins(bh_allocator a);
+void introduce_build_options(bh_allocator a);
 
 
 // NOTE: Useful not inlined functions
index 686f20df977fb55ebb9b260bb35840324ec16ece..d1ac05f42fbdcb3ece41eca954d1718f619cf533 100644 (file)
@@ -2,15 +2,19 @@
 
 use package core
 
-max_f32 :: #solidify math.max { T = f32 };
+max_f32 :: #solidify math.max_poly { T = f32 };
 
 compose :: proc (a: $A, f: proc (A) -> $B, g: proc (B) -> $C) -> C do return g(f(a));
 
-specific_compose_0 :: #solidify compose { B = f32 };
 specific_compose_1 :: #solidify specific_compose_0 { A = f32 };
+specific_compose_0 :: #solidify compose { B = f32 };
 specific_compose_2 :: #solidify specific_compose_1 { C = f64 };
 
 main :: proc (args: [] cstr) {
+    use package build_opts
+    println(Runtime);
+    println("==================================================");
+
     printf("max(1, 2) = %i\n", math.max(1, 2));
     printf("max_f32(1.0, 2.0) = %f\n", max_f32(1, 2));
 
@@ -47,7 +51,7 @@ main :: proc (args: [] cstr) {
 }
 
 array_map :: proc (arr: [..] $T, f: proc (T) -> T) {
-    foo := #solidify math.max { T = T };
+    foo := #solidify math.max_poly { T = T };
     is := (#type InternalStruct(T)).{ foo = foo(6, 2) };
     printf("%i\n", is.foo);
 
index 4fc4d438250223a7f6295f2b87187f8f706a4713..dfdbf4813748c12d19770100fae0c64e09ec058b 100644 (file)
@@ -129,7 +129,6 @@ typedef enum CompilerProgress {
 
 static OnyxToken implicit_load_token = { '#', 1, 0, { 0, 0, 0, 0, 0 } };
 static AstInclude* create_load(bh_allocator alloc, char* filename) {
-
     AstInclude* include_node = onyx_ast_node_new(alloc, sizeof(AstInclude), Ast_Kind_Load_File);
     include_node->name = filename;
     include_node->token = &implicit_load_token;
@@ -321,6 +320,7 @@ static b32 process_entity(Entity* ent) {
             if (!builtins_initialized) {
                 builtins_initialized = 1;
                 initialize_builtins(context.ast_alloc);
+                introduce_build_options(context.ast_alloc);
             }
          
             process_load_entity(ent);
index d036182dcf094b2733e8b930ade7c3f8c931bbc4..ca4ddb019020c4475a075f28f6b6b9e9570d6d81 100644 (file)
@@ -379,3 +379,10 @@ void initialize_builtins(bh_allocator a) {
         intrinsic++;
     }
 }
+
+void introduce_build_options(bh_allocator a) {
+    Package* p = package_lookup_or_create("build_opts", context.global_scope, a);
+
+    AstNumLit* runtime_type = make_int_literal(a, 1);
+    symbol_builtin_introduce(p->scope, "Runtime", (AstNode *) runtime_type);
+}
\ No newline at end of file