From: Brendan Hansen Date: Sat, 18 Feb 2023 17:03:45 +0000 (-0600) Subject: switching branches X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=23a0339929358e3f4e68e75916ac5c0ca6c4bed3;p=onyx.git switching branches --- diff --git a/compiler/src/doc.c b/compiler/src/doc.c index b02d28f1..cf10c845 100644 --- a/compiler/src/doc.c +++ b/compiler/src/doc.c @@ -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; diff --git a/core/container/map.onyx b/core/container/map.onyx index 5722b304..f3a927d0 100644 --- a/core/container/map.onyx +++ b/core/container/map.onyx @@ -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);