return lr.entry_index >= 0;
}
-i32map_get :: proc (imap: ^I32Map($T), key: i32) -> i32 {
+i32map_get :: proc (imap: ^I32Map($T), key: i32, default := cast(T) 0) -> T {
lr := i32map_lookup(imap, key);
if lr.entry_index >= 0 do return imap.entries[lr.entry_index].value;
- return null;
+ return default;
}
i32map_delete :: proc (imap: ^I32Map($T), key: i32) {
main :: proc (args: [] cstring) {
-
- imap : I32Map(string);
+ imap : I32Map(i32);
i32map_init(^imap);
- i32map_put(^imap, 50, "Hello ");
- i32map_put(^imap, 1234, "World!");
+ i32map_put(^imap, 50, 1234);
+ i32map_put(^imap, 1234, 5678);
print(i32map_get(^imap, 50));
print(i32map_get(^imap, 1234));
}
case Ast_Kind_Struct_Member:
+ ((AstStructMember *) nn)->type_node = (AstType *) ast_clone(a, ((AstStructMember *) node)->type_node);
((AstStructMember *) nn)->initial_value = (AstTyped *) ast_clone(a, ((AstStructMember *) node)->initial_value);
break;
+ case Ast_Kind_Poly_Call_Type: {
+ AstPolyCallType* pcd = (AstPolyCallType *) nn;
+ AstPolyCallType* pcs = (AstPolyCallType *) node;
+
+ pcd->callee = (AstType *) ast_clone(a, pcs->callee);
+ pcd->params = NULL;
+ bh_arr_new(global_heap_allocator, pcd->params, bh_arr_length(pcs->params));
+
+ bh_arr_each(AstType *, param, pcs->params) {
+ bh_arr_push(pcd->params, (AstType *) ast_clone(a, *param));
+ }
+
+ break;
+ }
+
case Ast_Kind_Function_Type:
((AstFunctionType *) nn)->return_type = (AstType *) ast_clone(a, ((AstFunctionType *) node)->return_type);
((AstFunctionType *) nn)->param_count = ((AstFunctionType *) node)->param_count;