mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Improve docs_writer.cpp
This commit is contained in:
@@ -2,27 +2,5 @@
|
|||||||
A BigInt implementation in Odin.
|
A BigInt implementation in Odin.
|
||||||
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
|
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
|
||||||
The code started out as an idiomatic source port of libTomMath, which is in the public domain, with thanks.
|
The code started out as an idiomatic source port of libTomMath, which is in the public domain, with thanks.
|
||||||
|
|
||||||
========================== Low-level routines ==========================
|
|
||||||
|
|
||||||
IMPORTANT: `internal_*` procedures make certain assumptions about their input.
|
|
||||||
|
|
||||||
The public functions that call them are expected to satisfy their sanity check requirements.
|
|
||||||
This allows `internal_*` call `internal_*` without paying this overhead multiple times.
|
|
||||||
|
|
||||||
Where errors can occur, they are of course still checked and returned as appropriate.
|
|
||||||
|
|
||||||
When importing `math:core/big` to implement an involved algorithm of your own, you are welcome
|
|
||||||
to use these procedures instead of their public counterparts.
|
|
||||||
|
|
||||||
Most inputs and outputs are expected to be passed an initialized `Int`, for example.
|
|
||||||
Exceptions include `quotient` and `remainder`, which are allowed to be `nil` when the calling code doesn't need them.
|
|
||||||
|
|
||||||
Check the comments above each `internal_*` implementation to see what constraints it expects to have met.
|
|
||||||
|
|
||||||
We pass the custom allocator to procedures by default using the pattern `context.allocator = allocator`.
|
|
||||||
This way we don't have to add `, allocator` at the end of each call.
|
|
||||||
|
|
||||||
TODO: Handle +/- Infinity and NaN.
|
|
||||||
*/
|
*/
|
||||||
package math_big
|
package math_big
|
||||||
|
|||||||
@@ -1,10 +1,32 @@
|
|||||||
//+ignore
|
|
||||||
/*
|
/*
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
Made available under Odin's BSD-3 license.
|
Made available under Odin's BSD-3 license.
|
||||||
|
|
||||||
|
========================== Low-level routines ==========================
|
||||||
|
|
||||||
|
IMPORTANT: `internal_*` procedures make certain assumptions about their input.
|
||||||
|
|
||||||
|
The public functions that call them are expected to satisfy their sanity check requirements.
|
||||||
|
This allows `internal_*` call `internal_*` without paying this overhead multiple times.
|
||||||
|
|
||||||
|
Where errors can occur, they are of course still checked and returned as appropriate.
|
||||||
|
|
||||||
|
When importing `math:core/big` to implement an involved algorithm of your own, you are welcome
|
||||||
|
to use these procedures instead of their public counterparts.
|
||||||
|
|
||||||
|
Most inputs and outputs are expected to be passed an initialized `Int`, for example.
|
||||||
|
Exceptions include `quotient` and `remainder`, which are allowed to be `nil` when the calling code doesn't need them.
|
||||||
|
|
||||||
|
Check the comments above each `internal_*` implementation to see what constraints it expects to have met.
|
||||||
|
|
||||||
|
We pass the custom allocator to procedures by default using the pattern `context.allocator = allocator`.
|
||||||
|
This way we don't have to add `, allocator` at the end of each call.
|
||||||
|
|
||||||
|
TODO: Handle +/- Infinity and NaN.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//+ignore
|
||||||
package math_big
|
package math_big
|
||||||
|
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
//+ignore
|
|
||||||
/*
|
/*
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
Made available under Odin's BSD-3 license.
|
Made available under Odin's BSD-3 license.
|
||||||
@@ -8,7 +7,7 @@
|
|||||||
The code started out as an idiomatic source port of libTomMath, which is in the public domain, with thanks.
|
The code started out as an idiomatic source port of libTomMath, which is in the public domain, with thanks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//+ignore
|
||||||
package math_big
|
package math_big
|
||||||
|
|
||||||
import "core:time"
|
import "core:time"
|
||||||
|
|||||||
+1
-1
@@ -513,7 +513,7 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
|||||||
break;
|
break;
|
||||||
case Type_Generic:
|
case Type_Generic:
|
||||||
doc_type.kind = OdinDocType_Generic;
|
doc_type.kind = OdinDocType_Generic;
|
||||||
doc_type.name = odin_doc_write_string(w, type->Generic.name);
|
doc_type.name = odin_doc_write_string(w, type->Generic.entity->token.string);
|
||||||
if (type->Generic.specialized) {
|
if (type->Generic.specialized) {
|
||||||
doc_type.types = odin_doc_type_as_slice(w, type->Generic.specialized);
|
doc_type.types = odin_doc_type_as_slice(w, type->Generic.specialized);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-9
@@ -3933,7 +3933,7 @@ gbString write_type_to_string(gbString str, Type *type) {
|
|||||||
str = gb_string_appendc(str, " = ");
|
str = gb_string_appendc(str, " = ");
|
||||||
str = write_exact_value_to_string(str, var->Constant.value);
|
str = write_exact_value_to_string(str, var->Constant.value);
|
||||||
} else {
|
} else {
|
||||||
str = gb_string_appendc(str, "=");
|
str = gb_string_appendc(str, " := ");
|
||||||
str = write_exact_value_to_string(str, var->Constant.value);
|
str = write_exact_value_to_string(str, var->Constant.value);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -3961,14 +3961,10 @@ gbString write_type_to_string(gbString str, Type *type) {
|
|||||||
str = gb_string_appendc(str, "typeid/");
|
str = gb_string_appendc(str, "typeid/");
|
||||||
str = write_type_to_string(str, var->type);
|
str = write_type_to_string(str, var->type);
|
||||||
} else {
|
} else {
|
||||||
if (var->kind == Entity_TypeName) {
|
str = gb_string_appendc(str, "$");
|
||||||
str = gb_string_appendc(str, "$");
|
str = gb_string_append_length(str, name.text, name.len);
|
||||||
str = gb_string_append_length(str, name.text, name.len);
|
str = gb_string_appendc(str, "=");
|
||||||
str = gb_string_appendc(str, "=");
|
str = write_type_to_string(str, var->type);
|
||||||
str = write_type_to_string(str, var->type);
|
|
||||||
} else {
|
|
||||||
str = gb_string_appendc(str, "typeid");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user