switching branches
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 18 Feb 2023 17:03:45 +0000 (11:03 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 24 Mar 2023 01:50:10 +0000 (20:50 -0500)
compiler/src/doc.c
core/container/map.onyx

index b02d28f15de467f783fbbd80c7573eeb0266f8e4..cf10c8454fc118efb2786d43b68f849222ca4c59 100644 (file)
@@ -203,6 +203,15 @@ struct Doc {
     struct Doc_Array files;
 };
 
+
+typedef struct DocGenerator {
+
+} DocGenerator;
+
+u32 doc_gen_add_string(DocGenerator *gen, char *data, u32 len) {
+
+}
+
 void onyx_docs_emit_odoc(const char *dest) {
     bh_file doc_file;
     if (bh_file_create(&doc_file, dest) != BH_FILE_ERROR_NONE) {
@@ -210,13 +219,17 @@ void onyx_docs_emit_odoc(const char *dest) {
         return;
     }
 
+    DocGenerator gen;
+
     struct Doc final_doc;
 
     memcpy(final_doc.header.magic_bytes, Doc_Magic_Bytes, 4);
     final_doc.header.version = 1;
 
-    final_doc.header.program_name.offset = 0;
-    final_doc.header.program_name.length = 0;
+    char *program_name = context.options->target_file;
+    u32 program_name_len = strlen(program_name);
+    final_doc.header.program_name.offset = doc_gen_add_string(&gen, program_name, program_name_len);
+    final_doc.header.program_name.length = program_name_len;
 
     final_doc.header.build_time = bh_time_curr() / 1000;
 
index 5722b304cac9e1fde22c642b8b6a9acfc9389dee..f3a927d059ce2b1552620039f5bcfa473051b199 100644 (file)
@@ -3,11 +3,11 @@ package core.map
 use core {array, hash, memory, math, conv, Optional}
 use core.intrinsics.onyx { __initialize }
 
-//
-// Map is a generic hash-map implementation that uses chaining.
-// Values can be of any type. Keys must of a type that supports
-// the core.hash.hash, and the '==' operator.
-//
+#doc """
+   Map is a generic hash-map implementation that uses chaining.
+   Values can be of any type. Keys must of a type that supports
+   the core.hash.hash, and the '==' operator.
+"""
 @conv.Custom_Format.{ #solidify format_map {K=Key_Type, V=Value_Type} }
 Map :: struct (Key_Type: type_expr, Value_Type: type_expr) where ValidKey(Key_Type) {
     allocator : Allocator;
@@ -52,17 +52,18 @@ Map :: struct (Key_Type: type_expr, Value_Type: type_expr) where ValidKey(Key_Ty
 }
 
 
-//
-// Allows for creation of a Map using make().
-//
-//     m := make(Map(str, i32));
-//
+#doc """
+   Allows for creation of a Map using make().
+  
+       m := make(Map(str, i32));
+"""
 #overload
 __make_overload :: macro (x: &Map($K, $V), allocator := context.allocator) =>
     #this_package.make(K, V);
 
-//
-// Creates and initializes a new map using the types provided.
+#doc """
+   Creates and initializes a new map using the types provided.
+"""
 make :: macro ($Key: type_expr, $Value: type_expr, default := Value.{}) -> Map(Key, Value) {
     map : Map(Key, Value);
     #this_package.init(&map, default = default);
@@ -188,19 +189,19 @@ delete :: (use map: &Map, key: map.Key_Type) {
     else                       do hashes[last.hash_index] = lr.entry_index;
 }
 
-//
-// Helper macro that finds a value by the key, and if it exists,
-// runs the code, providing an `it` variable that is a pointer
-// to the value.
-//
-//     m: Map(str, i32);
-//     m->update("test") {
-//         *it += 10;
-//     }
-// or:
-//     m->update("test", #(*it += 10));
-//
-update :: macro (map: &Map, key: map.Key_Type, body: Code) {
+#doc """
+   Helper macro that finds a value by the key, and if it exists,
+   runs the code, providing an `it` variable that is a pointer
+   to the value.
+  
+       m: Map(str, i32);
+       m->update("test") {
+           *it += 10;
+       }
+   or:
+       m->update("test", #(*it += 10));
+"""  
+update :: macro (map: ^Map, key: map.Key_Type, body: Code) {
     lookup_ :: lookup
     lr := lookup_(map, key);