Rename free to delete for non pointer types

This commit is contained in:
gingerBill
2018-07-08 11:03:56 +01:00
parent e515220694
commit 0e91298fd1
8 changed files with 130 additions and 102 deletions
+18 -25
View File
@@ -254,10 +254,10 @@ foreign {
assume :: proc(cond: bool) ---;
@(link_name="llvm.debugtrap")
__debug_trap :: proc() ---;
debug_trap :: proc() ---;
@(link_name="llvm.trap")
__trap :: proc() ---;
trap :: proc() ---;
@(link_name="llvm.readcyclecounter")
read_cycle_counter :: proc() -> u64 ---;
@@ -309,32 +309,25 @@ reserve :: proc[reserve_dynamic_array, reserve_map];
@(builtin)
new :: inline proc(T: type, loc := #caller_location) -> ^T {
ptr := (^T)(mem.alloc(size_of(T), align_of(T), loc));
ptr^ = T{};
return ptr;
}
new :: proc[mem.new];
@(builtin)
new_clone :: inline proc(data: $T, loc := #caller_location) -> ^T {
ptr := (^T)(mem.alloc(size_of(T), align_of(T), loc));
ptr^ = data;
return ptr;
}
new_clone :: proc[mem.new_clone];
@(builtin)
free :: proc[
mem.free_ptr,
mem.free_string,
mem.free_cstring,
mem.free_dynamic_array,
mem.free_slice,
mem.free_map,
free :: proc[mem.free];
@(builtin)
delete :: proc[
mem.delete_string,
mem.delete_cstring,
mem.delete_dynamic_array,
mem.delete_slice,
mem.delete_map,
];
@(builtin)
clear_map :: inline proc "contextless" (m: ^$T/map[$K]$V) {
if m == nil do return;
@@ -351,8 +344,8 @@ reserve_map :: proc(m: ^$T/map[$K]$V, capacity: int) {
}
@(builtin)
delete :: proc(m: ^$T/map[$K]$V, key: K) {
if m != nil do __dynamic_map_delete(__get_map_header(m), __get_map_key(key));
delete_key :: proc(m: ^$T/map[$K]$V, key: K) {
if m != nil do __dynamic_map_delete_key(__get_map_header(m), __get_map_key(key));
}
@@ -436,7 +429,7 @@ assert :: proc "contextless" (condition: bool, message := "", using loc := #call
os.write_string(fd, message);
}
os.write_byte(fd, '\n');
__debug_trap();
debug_trap();
}
return condition;
}
@@ -451,7 +444,7 @@ panic :: proc "contextless" (message := "", using loc := #caller_location) {
os.write_string(fd, message);
}
os.write_byte(fd, '\n');
__debug_trap();
debug_trap();
}
@@ -742,7 +735,7 @@ __dynamic_map_add_entry :: proc(using h: Map_Header, key: Map_Key, loc := #calle
return prev;
}
__dynamic_map_delete :: proc(using h: Map_Header, key: Map_Key) {
__dynamic_map_delete_key :: proc(using h: Map_Header, key: Map_Key) {
fr := __dynamic_map_find(h, key);
if fr.entry_index >= 0 {
__dynamic_map_erase(h, fr);
+4 -4
View File
@@ -259,7 +259,7 @@ bounds_check_error :: proc "contextless" (file: string, line, column: int, index
os.write_string(fd, " is out of bounds range 0..");
__print_i64(fd, i64(count));
os.write_byte(fd, '\n');
__debug_trap();
debug_trap();
}
slice_expr_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
@@ -275,7 +275,7 @@ slice_expr_error :: proc "contextless" (file: string, line, column: int, lo, hi:
os.write_string(fd, "..");
__print_i64(fd, i64(len));
os.write_byte(fd, '\n');
__debug_trap();
debug_trap();
}
dynamic_array_expr_error :: proc "contextless" (file: string, line, column: int, low, high, max: int) {
@@ -290,7 +290,7 @@ dynamic_array_expr_error :: proc "contextless" (file: string, line, column: int,
os.write_string(fd, "..");
__print_i64(fd, i64(max));
os.write_byte(fd, '\n');
__debug_trap();
debug_trap();
}
type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: int, from, to: typeid) {
@@ -303,7 +303,7 @@ type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column
os.write_string(fd, " to ");
__print_typeid(fd, to);
os.write_byte(fd, '\n');
__debug_trap();
debug_trap();
}
__string_decode_rune :: inline proc "contextless" (s: string) -> (rune, int) {