added: onyx version information to runtime
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 24 Nov 2023 19:32:41 +0000 (13:32 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 24 Nov 2023 19:32:41 +0000 (13:32 -0600)
compiler/include/astnodes.h
compiler/src/builtins.c
compiler/src/onyx.c

index 24b9bd9ba96d41cc632d6d0a67c6e14b58c8c6b4..e92f9707280d2167d2b97df4209172c72a09b749 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef ONYXASTNODES_H
 #define ONYXASTNODES_H
 
+#define VERSION_MAJOR 0
+#define VERSION_MINOR 1
+#define VERSION_PATCH 8
+
 #include "stb_ds.h"
 #include "lex.h"
 #include "types.h"
index 2ebcf64656159be7ab7f7d41cef7c37c8800ee9c..c78a7f589b76ce684c426adea6f4cafb6aa38f00 100644 (file)
@@ -611,6 +611,17 @@ void introduce_build_options(bh_allocator a) {
     stack_trace->type_node = (AstType *) &basic_type_bool;
     symbol_builtin_introduce(p->scope, "Stack_Trace_Enabled", (AstNode *) stack_trace);
 
+    AstNumLit* version_major = make_int_literal(a, VERSION_MAJOR);
+    version_major->type_node = (AstType *) &basic_type_i32;
+    AstNumLit* version_minor = make_int_literal(a, VERSION_MINOR);
+    version_minor->type_node = (AstType *) &basic_type_i32;
+    AstNumLit* version_patch = make_int_literal(a, VERSION_PATCH);
+    version_patch->type_node = (AstType *) &basic_type_i32;
+    symbol_builtin_introduce(p->scope, "onyx_version_major", (AstNode *) version_major);
+    symbol_builtin_introduce(p->scope, "onyx_version_minor", (AstNode *) version_minor);
+    symbol_builtin_introduce(p->scope, "onyx_version_patch", (AstNode *) version_patch);
+
+
     i32 os;
     #ifdef _BH_LINUX
         os = 1;
@@ -658,6 +669,5 @@ void introduce_build_options(bh_allocator a) {
         foreign_info->type_node = (AstType *) &basic_type_bool;
         symbol_builtin_introduce(p->scope, "Generated_Foreign_Info", (AstNode *) foreign_info);
     }
-
 }
 
index eb77f02fd60b8205b50d473a97564a179a9e47b3..a8ae029290962d1d732e1272d158e99d252328f6 100644 (file)
@@ -19,7 +19,10 @@ extern struct bh_allocator global_heap_allocator;
 #include "wasm_emit.h"
 #include "doc.h"
 
-#define VERSION "v0.1.8"
+
+#define VERSION__(m,i,p) "v" #m "." #i "." #p
+#define VERSION_(m,i,p) VERSION__(m,i,p)
+#define VERSION VERSION_(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
 
 #ifdef ONYX_RUNTIME_LIBRARY
     #define ONYX_RUNTIME_LIBRARY_MAPPED ONYX_RUNTIME_LIBRARY