Ast_Flag_Extra_Field_Access = BH_BIT(23),
Ast_Flag_Symbol_Is_PolyVar = BH_BIT(24),
+ Ast_Flag_Poly_Call_From_Auto = BH_BIT(24),
Ast_Flag_Binding_Isnt_Captured = BH_BIT(25),
} AstFlags;
return;
case Ast_Kind_Poly_Call_Type:
+ if (((AstPolyCallType *) node)->callee == (AstNode *) builtin_optional_type) {
+ bh_buffer_write_string(buffer, "? ");
+ write_type_node(buffer, ((AstPolyCallType *) node)->params[0]);
+ return;
+ }
+
write_type_node(buffer, ((AstPolyCallType *) node)->callee);
+ if (node->flags & Ast_Flag_Poly_Call_From_Auto) return;
+
bh_buffer_write_byte(buffer, '(');
bh_arr_each(AstNode *, param, ((AstPolyCallType *) node)->params) {
AstPolyCallType* pcall = onyx_ast_node_new(context.ast_alloc, sizeof(AstPolyCallType), Ast_Kind_Poly_Call_Type);
pcall->callee = *apv->replace;
pcall->token = pcall->callee->token;
+ pcall->flags |= Ast_Flag_Poly_Call_From_Auto;
bh_arr_new(global_heap_allocator, pcall->params, apv->variable_count);
if (apv->base_type->kind == Ast_Kind_Poly_Struct_Type) {
}
#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));
+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
This overloaded procedure defines how to hash something.
It is used throughout the standard library to hash values.
There are many overloads to it in the standard library, and
- more can be added using #overload. Or, a hash method can be
- defined for a structure or distinct type.
+ more can be added using #overload.
+
+ Alternatively, a hash method can be defined for a structure or distinct type.
Person :: struct {
- hash :: (p: Person) {
+ hash :: (p: Person) -> u32 {
return // ...
}
}
package core.arg_parse
-//
-// This is currently a very basic argument parsing library.
-// The options are given through a structure like so:
-//
-// Options :: struct {
-// @"--option_1"
-// option_1: str;
-//
-// @"--option_2", "-o2"
-// option_2: bool;
-// }
-//
-// main :: (args) => {
-// o: Options;
-// arg_parse.arg_parse(args, &o);
-// }
-//
-// Options that are strings and integers expect an argument after
-// them to specify their value. Options that are bool default to
-// false and are true if one or more of the option values are present.
-//
-
use core
+#doc """
+ This is currently a very basic argument parsing library.
+ The options are given through a structure like so:
+
+ Options :: struct {
+ @"--option_1"
+ option_1: str;
+
+ @"--option_2", "-o2"
+ option_2: bool;
+ }
+
+ main :: (args) => {
+ o: Options;
+ arg_parse.arg_parse(args, &o);
+ }
+
+ Options that are strings and integers expect an argument after
+ them to specify their value. Options that are bool default to
+ false and are true if one or more of the option values are present.
+"""
arg_parse :: (c_args: [] cstr, output: any) -> bool {
arg_iter := iter.as_iter(c_args)
|> iter.map(string.from_cstr);