-// 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
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
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));
}
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);
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;
if (!builtins_initialized) {
builtins_initialized = 1;
initialize_builtins(context.ast_alloc);
+ introduce_build_options(context.ast_alloc);
}
process_load_entity(ent);
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