mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
0.5.3: Single-module not respected. Fix issue with compiler defined types. Fix optimization levels for projects. Use GEP i8 on offsets. Optimize foreach on len 1 arrays. Move panic blocks last. Fix generic module wildcard imports. Deprecate init_temp / init_new. Fix issue with macro vaarg and untyped lists. Fix extern const globals.
This commit is contained in:
committed by
Christoffer Lerno
parent
e91f6e268e
commit
deb4cc7c4b
@@ -86,15 +86,29 @@ struct GrowableBitSet
|
||||
* @param initial_capacity
|
||||
* @param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||
**/
|
||||
fn GrowableBitSet* GrowableBitSet.init_new(&self, usz initial_capacity = 1, Allocator* allocator = mem::heap())
|
||||
fn GrowableBitSet* GrowableBitSet.new_init(&self, usz initial_capacity = 1, Allocator* allocator = mem::heap())
|
||||
{
|
||||
self.data.init_new(initial_capacity, allocator);
|
||||
self.data.new_init(initial_capacity, allocator);
|
||||
return self;
|
||||
}
|
||||
|
||||
fn GrowableBitSet* GrowableBitSet.init_temp(&self, usz initial_capacity = 1)
|
||||
/**
|
||||
* @param initial_capacity
|
||||
* @param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||
**/
|
||||
fn GrowableBitSet* GrowableBitSet.init_new(&self, usz initial_capacity = 1, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init")
|
||||
{
|
||||
return self.init_new(initial_capacity, mem::temp()) @inline;
|
||||
return self.new_init(initial_capacity, allocator) @inline;
|
||||
}
|
||||
|
||||
fn GrowableBitSet* GrowableBitSet.temp_init(&self, usz initial_capacity = 1)
|
||||
{
|
||||
return self.new_init(initial_capacity, mem::temp()) @inline;
|
||||
}
|
||||
|
||||
fn GrowableBitSet* GrowableBitSet.init_temp(&self, usz initial_capacity = 1) @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return self.temp_init(initial_capacity);
|
||||
}
|
||||
|
||||
fn void GrowableBitSet.free(&self)
|
||||
|
||||
@@ -32,15 +32,29 @@ fn void LinkedList.push_last(&self, Type value)
|
||||
* @param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||
* @return "the initialized list"
|
||||
**/
|
||||
fn LinkedList* LinkedList.init_new(&self, Allocator* allocator = mem::heap())
|
||||
fn LinkedList* LinkedList.new_init(&self, Allocator* allocator = mem::heap())
|
||||
{
|
||||
*self = { .allocator = allocator };
|
||||
return self;
|
||||
}
|
||||
|
||||
fn LinkedList* LinkedList.init_temp(&self)
|
||||
/**
|
||||
* @param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||
* @return "the initialized list"
|
||||
**/
|
||||
fn LinkedList* LinkedList.init_new(&self, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init")
|
||||
{
|
||||
return self.init_new(mem::temp()) @inline;
|
||||
return self.new_init(allocator);
|
||||
}
|
||||
|
||||
fn LinkedList* LinkedList.temp_init(&self)
|
||||
{
|
||||
return self.new_init(mem::temp()) @inline;
|
||||
}
|
||||
|
||||
fn LinkedList* LinkedList.init_temp(&self) @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return self.temp_init() @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,11 +18,12 @@ struct List (Printable)
|
||||
Type *entries;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param initial_capacity "The initial capacity to reserve"
|
||||
* @param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||
**/
|
||||
fn List* List.init_new(&self, usz initial_capacity = 16, Allocator* allocator = mem::heap())
|
||||
fn List* List.new_init(&self, usz initial_capacity = 16, Allocator* allocator = mem::heap())
|
||||
{
|
||||
self.allocator = allocator;
|
||||
self.size = 0;
|
||||
@@ -39,14 +40,33 @@ fn List* List.init_new(&self, usz initial_capacity = 16, Allocator* allocator =
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param initial_capacity "The initial capacity to reserve"
|
||||
* @param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||
**/
|
||||
fn List* List.init_new(&self, usz initial_capacity = 16, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init")
|
||||
{
|
||||
return self.new_init(initial_capacity, allocator) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the list using the temp allocator.
|
||||
*
|
||||
* @param initial_capacity "The initial capacity to reserve"
|
||||
**/
|
||||
fn List* List.init_temp(&self, usz initial_capacity = 16)
|
||||
fn List* List.temp_init(&self, usz initial_capacity = 16)
|
||||
{
|
||||
return self.init_new(initial_capacity, mem::temp()) @inline;
|
||||
return self.new_init(initial_capacity, mem::temp()) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the list using the temp allocator.
|
||||
*
|
||||
* @param initial_capacity "The initial capacity to reserve"
|
||||
**/
|
||||
fn List* List.init_temp(&self, usz initial_capacity = 16) @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return self.temp_init(initial_capacity) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,11 +149,8 @@ fn Type List.pop_first(&self)
|
||||
**/
|
||||
fn void List.remove_at(&self, usz index)
|
||||
{
|
||||
for (usz i = index + 1; i < self.size; i++)
|
||||
{
|
||||
self.entries[i - 1] = self.entries[i];
|
||||
}
|
||||
self.size--;
|
||||
if (!--self.size || index == self.size) return;
|
||||
self.entries[index .. self.size - 1] = self.entries[index + 1 .. self.size];
|
||||
}
|
||||
|
||||
fn void List.add_all(&self, List* other_list)
|
||||
|
||||
@@ -19,6 +19,23 @@ struct HashMap
|
||||
float load_factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&inout] allocator "The allocator to use"
|
||||
* @require capacity > 0 "The capacity must be 1 or higher"
|
||||
* @require load_factor > 0.0 "The load factor must be higher than 0"
|
||||
* @require !self.allocator "Map was already initialized"
|
||||
* @require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||
**/
|
||||
fn HashMap* HashMap.new_init(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator* allocator = mem::heap())
|
||||
{
|
||||
capacity = math::next_power_of_2(capacity);
|
||||
self.allocator = allocator;
|
||||
self.load_factor = load_factor;
|
||||
self.threshold = (uint)(capacity * load_factor);
|
||||
self.table = allocator.new_zero_array(Entry*, capacity);
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&inout] allocator "The allocator to use"
|
||||
* @require capacity > 0 "The capacity must be 1 or higher"
|
||||
@@ -26,14 +43,20 @@ struct HashMap
|
||||
* @require !map.allocator "Map was already initialized"
|
||||
* @require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||
**/
|
||||
fn HashMap* HashMap.init_new(&map, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator* allocator = mem::heap())
|
||||
fn HashMap* HashMap.init_new(&map, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init")
|
||||
{
|
||||
capacity = math::next_power_of_2(capacity);
|
||||
map.allocator = allocator;
|
||||
map.load_factor = load_factor;
|
||||
map.threshold = (uint)(capacity * load_factor);
|
||||
map.table = allocator.new_zero_array(Entry*, capacity);
|
||||
return map;
|
||||
return map.new_init(capacity, load_factor, allocator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @require capacity > 0 "The capacity must be 1 or higher"
|
||||
* @require load_factor > 0.0 "The load factor must be higher than 0"
|
||||
* @require !self.allocator "Map was already initialized"
|
||||
* @require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||
**/
|
||||
fn HashMap* HashMap.temp_init(&self, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR)
|
||||
{
|
||||
return self.new_init(capacity, load_factor, mem::temp()) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,9 +65,9 @@ fn HashMap* HashMap.init_new(&map, uint capacity = DEFAULT_INITIAL_CAPACITY, flo
|
||||
* @require !map.allocator "Map was already initialized"
|
||||
* @require capacity < MAXIMUM_CAPACITY "Capacity cannot exceed maximum"
|
||||
**/
|
||||
fn HashMap* HashMap.init_temp(&map, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR)
|
||||
fn HashMap* HashMap.init_temp(&map, uint capacity = DEFAULT_INITIAL_CAPACITY, float load_factor = DEFAULT_LOAD_FACTOR) @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return map.init_new(capacity, load_factor, mem::temp());
|
||||
return map.temp_init(capacity, load_factor) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,21 +85,40 @@ fn bool HashMap.is_initialized(&map)
|
||||
* @param [&inout] allocator "The allocator to use"
|
||||
* @param [&in] other_map "The map to copy from."
|
||||
**/
|
||||
fn HashMap* HashMap.init_new_from_map(&self, HashMap* other_map, Allocator* allocator = mem::heap())
|
||||
fn HashMap* HashMap.new_init_from_map(&self, HashMap* other_map, Allocator* allocator = mem::heap())
|
||||
{
|
||||
self.init_new(other_map.table.len, other_map.load_factor, allocator);
|
||||
self.new_init(other_map.table.len, other_map.load_factor, allocator);
|
||||
self.put_all_for_create(other_map);
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&inout] allocator "The allocator to use"
|
||||
* @param [&in] other_map "The map to copy from."
|
||||
**/
|
||||
fn HashMap* HashMap.init_temp_from_map(&map, HashMap* other_map)
|
||||
fn HashMap* HashMap.init_new_from_map(&self, HashMap* other_map, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init_from_map")
|
||||
|
||||
{
|
||||
return map.init_new_from_map(other_map, mem::temp()) @inline;
|
||||
return self.new_init_from_map(other_map, allocator) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&in] other_map "The map to copy from."
|
||||
**/
|
||||
fn HashMap* HashMap.temp_init_from_map(&map, HashMap* other_map)
|
||||
{
|
||||
return map.new_init_from_map(other_map, mem::temp()) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&in] other_map "The map to copy from."
|
||||
**/
|
||||
fn HashMap* HashMap.init_temp_from_map(&map, HashMap* other_map) @deprecated("Replaced by temp_init_from_map")
|
||||
{
|
||||
return map.temp_init_from_map(other_map) @inline;
|
||||
}
|
||||
|
||||
|
||||
fn bool HashMap.is_empty(&map) @inline
|
||||
{
|
||||
return !map.count;
|
||||
@@ -146,7 +188,7 @@ fn bool HashMap.set(&map, Key key, Value value) @operator([]=)
|
||||
// If the map isn't initialized, use the defaults to initialize it.
|
||||
if (!map.allocator)
|
||||
{
|
||||
map.init_new();
|
||||
map.new_init();
|
||||
}
|
||||
uint hash = rehash(key.hash());
|
||||
uint index = index_for(hash, map.table.len);
|
||||
|
||||
@@ -168,7 +168,7 @@ fn void Object.init_map_if_needed(&self) @private
|
||||
if (self.is_empty())
|
||||
{
|
||||
self.type = ObjectInternalMap.typeid;
|
||||
self.map.init_new(.allocator = self.allocator);
|
||||
self.map.new_init(.allocator = self.allocator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ fn void Object.init_array_if_needed(&self) @private
|
||||
if (self.is_empty())
|
||||
{
|
||||
self.type = ObjectInternalList.typeid;
|
||||
self.array.init_new(.allocator = self.allocator);
|
||||
self.array.new_init(.allocator = self.allocator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,14 +36,24 @@ struct PrivatePriorityQueue (Printable)
|
||||
Heap heap;
|
||||
}
|
||||
|
||||
fn void PrivatePriorityQueue.init_new(&self, usz initial_capacity = 16, Allocator* allocator = mem::heap()) @inline
|
||||
fn void PrivatePriorityQueue.init_new(&self, usz initial_capacity = 16, Allocator* allocator = mem::heap()) @inline @deprecated("Replaced by new_init")
|
||||
{
|
||||
self.heap.init_new(initial_capacity, allocator);
|
||||
return self.new_init(initial_capacity, allocator);
|
||||
}
|
||||
|
||||
fn void PrivatePriorityQueue.init_temp(&self, usz initial_capacity = 16) @inline
|
||||
fn void PrivatePriorityQueue.new_init(&self, usz initial_capacity = 16, Allocator* allocator = mem::heap()) @inline
|
||||
{
|
||||
self.heap.init_new(initial_capacity, mem::temp()) @inline;
|
||||
self.heap.new_init(initial_capacity, allocator);
|
||||
}
|
||||
|
||||
fn void PrivatePriorityQueue.temp_init(&self, usz initial_capacity = 16) @inline
|
||||
{
|
||||
self.heap.new_init(initial_capacity, mem::temp()) @inline;
|
||||
}
|
||||
|
||||
fn void PrivatePriorityQueue.init_temp(&self, usz initial_capacity = 16) @inline @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return self.temp_init(initial_capacity) @inline;
|
||||
}
|
||||
|
||||
fn void PrivatePriorityQueue.push(&self, Type element)
|
||||
|
||||
@@ -35,7 +35,7 @@ struct TrackingAllocator (Allocator)
|
||||
fn void TrackingAllocator.init(&self, Allocator* allocator)
|
||||
{
|
||||
*self = { .inner_allocator = allocator };
|
||||
self.map.init_new(.allocator = allocator);
|
||||
self.map.new_init(.allocator = allocator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,7 +130,7 @@ fn void panicf(String fmt, String file, String function, uint line, args...)
|
||||
@stack_mem(512; Allocator* allocator)
|
||||
{
|
||||
DString s;
|
||||
s.init_new(.allocator = allocator);
|
||||
s.new_init(.allocator = allocator);
|
||||
s.appendf(fmt, ...args);
|
||||
panic(s.str_view(), file, function, line);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ const usz MIN_CAPACITY @private = 16;
|
||||
/**
|
||||
* @require !self.data() "String already initialized"
|
||||
**/
|
||||
fn DString DString.init_new(&self, usz capacity = MIN_CAPACITY, Allocator* allocator = mem::heap())
|
||||
fn DString DString.new_init(&self, usz capacity = MIN_CAPACITY, Allocator* allocator = mem::heap())
|
||||
{
|
||||
if (capacity < MIN_CAPACITY) capacity = MIN_CAPACITY;
|
||||
StringData* data = allocator.new(StringData, .end_padding = capacity);
|
||||
@@ -21,15 +21,31 @@ fn DString DString.init_new(&self, usz capacity = MIN_CAPACITY, Allocator* alloc
|
||||
/**
|
||||
* @require !self.data() "String already initialized"
|
||||
**/
|
||||
fn DString DString.init_temp(&self, usz capacity = MIN_CAPACITY)
|
||||
fn DString DString.init_new(&self, usz capacity = MIN_CAPACITY, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init")
|
||||
{
|
||||
self.init_new(capacity, mem::temp()) @inline;
|
||||
return self.new_init(capacity, allocator) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @require !self.data() "String already initialized"
|
||||
**/
|
||||
fn DString DString.temp_init(&self, usz capacity = MIN_CAPACITY)
|
||||
{
|
||||
self.new_init(capacity, mem::temp()) @inline;
|
||||
return *self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @require !self.data() "String already initialized"
|
||||
**/
|
||||
fn DString DString.init_temp(&self, usz capacity = MIN_CAPACITY) @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return self.temp_init(capacity) @inline;
|
||||
}
|
||||
|
||||
fn DString new_with_capacity(usz capacity, Allocator* allocator = mem::heap())
|
||||
{
|
||||
return DString{}.init_new(capacity, allocator);
|
||||
return DString{}.new_init(capacity, allocator);
|
||||
}
|
||||
|
||||
fn DString temp_with_capacity(usz capacity) => new_with_capacity(capacity, mem::temp()) @inline;
|
||||
@@ -51,13 +67,15 @@ fn DString temp_new(String s = "") => new(s, mem::temp()) @inline;
|
||||
fn DString DString.new_concat(self, DString b, Allocator* allocator = mem::heap())
|
||||
{
|
||||
DString string;
|
||||
string.init_new(self.len() + b.len(), allocator);
|
||||
string.new_init(self.len() + b.len(), allocator);
|
||||
string.append(self);
|
||||
string.append(b);
|
||||
return string;
|
||||
}
|
||||
|
||||
fn DString DString.new_tconcat(self, DString b) => self.new_concat(b, mem::temp());
|
||||
fn DString DString.temp_concat(self, DString b) => self.new_concat(b, mem::temp());
|
||||
|
||||
fn DString DString.new_tconcat(self, DString b) @deprecated("Replaced by temp_concat") => self.new_concat(b, mem::temp());
|
||||
|
||||
fn ZString DString.zstr_view(&self)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ module std::io::file::os @if(env::POSIX);
|
||||
fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator* allocator)
|
||||
{
|
||||
PathList list;
|
||||
list.init_new(.allocator = allocator);
|
||||
list.new_init(.allocator = allocator);
|
||||
DIRPtr directory = posix::opendir(dir.str_view() ? dir.as_zstr() : (ZString)".");
|
||||
defer if (directory) posix::closedir(directory);
|
||||
if (!directory) return (path::is_dir(dir) ? IoError.CANNOT_READ_DIR : IoError.FILE_NOT_DIR)?;
|
||||
@@ -25,7 +25,7 @@ module std::io::os @if(env::WIN32);
|
||||
fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator* allocator)
|
||||
{
|
||||
PathList list;
|
||||
list.init_new(.allocator = allocator);
|
||||
list.new_init(.allocator = allocator);
|
||||
|
||||
@pool(allocator)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,17 @@ struct ByteBuffer (InStream, OutStream)
|
||||
* max_read defines how many bytes might be kept before its internal buffer is shrinked.
|
||||
* @require self.bytes.len == 0 "Buffer already initialized."
|
||||
**/
|
||||
fn ByteBuffer*! ByteBuffer.init_new(&self, usz max_read, usz initial_capacity = 16, Allocator* allocator = mem::heap())
|
||||
fn ByteBuffer*! ByteBuffer.init_new(&self, usz max_read, usz initial_capacity = 16, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init")
|
||||
{
|
||||
return self.new_init(max_read, initial_capacity, allocator) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* ByteBuffer provides a streamable read/write buffer.
|
||||
* max_read defines how many bytes might be kept before its internal buffer is shrinked.
|
||||
* @require self.bytes.len == 0 "Buffer already initialized."
|
||||
**/
|
||||
fn ByteBuffer*! ByteBuffer.new_init(&self, usz max_read, usz initial_capacity = 16, Allocator* allocator = mem::heap())
|
||||
{
|
||||
*self = { .allocator = allocator, .max_read = max_read };
|
||||
initial_capacity = max(initial_capacity, 16);
|
||||
@@ -24,9 +34,14 @@ fn ByteBuffer*! ByteBuffer.init_new(&self, usz max_read, usz initial_capacity =
|
||||
return self;
|
||||
}
|
||||
|
||||
fn ByteBuffer*! ByteBuffer.init_temp(&self, usz max_read, usz initial_capacity = 16)
|
||||
fn ByteBuffer*! ByteBuffer.init_temp(&self, usz max_read, usz initial_capacity = 16) @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return self.init_new(max_read, initial_capacity, mem::temp());
|
||||
return self.temp_init(max_read, initial_capacity) @inline;
|
||||
}
|
||||
|
||||
fn ByteBuffer*! ByteBuffer.temp_init(&self, usz max_read, usz initial_capacity = 16)
|
||||
{
|
||||
return self.new_init(max_read, initial_capacity, mem::temp());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,20 +13,41 @@ struct ByteWriter (OutStream)
|
||||
* @require self.bytes.len == 0 "Init may not run on on already initialized data"
|
||||
* @ensure (bool)allocator, self.index == 0
|
||||
**/
|
||||
fn ByteWriter* ByteWriter.init_new(&self, Allocator* allocator = mem::heap())
|
||||
fn ByteWriter* ByteWriter.new_init(&self, Allocator* allocator = mem::heap())
|
||||
{
|
||||
*self = { .bytes = {}, .allocator = allocator };
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&inout] self
|
||||
* @param [&inout] allocator
|
||||
* @require self.bytes.len == 0 "Init may not run on on already initialized data"
|
||||
* @ensure (bool)allocator, self.index == 0
|
||||
**/
|
||||
fn ByteWriter* ByteWriter.init_new(&self, Allocator* allocator = mem::heap()) @deprecated("Replaced by new_init")
|
||||
{
|
||||
return self.new_init(allocator) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&inout] self
|
||||
* @require self.bytes.len == 0 "Init may not run on on already initialized data"
|
||||
* @ensure self.index == 0
|
||||
**/
|
||||
fn ByteWriter* ByteWriter.init_temp(&self)
|
||||
fn ByteWriter* ByteWriter.temp_init(&self)
|
||||
{
|
||||
return self.init_new(mem::temp());
|
||||
return self.new_init(mem::temp()) @inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param [&inout] self
|
||||
* @require self.bytes.len == 0 "Init may not run on on already initialized data"
|
||||
* @ensure self.index == 0
|
||||
**/
|
||||
fn ByteWriter* ByteWriter.init_temp(&self) @deprecated("Replaced by temp_init")
|
||||
{
|
||||
return self.temp_init() @inline;
|
||||
}
|
||||
|
||||
fn ByteWriter* ByteWriter.init_with_buffer(&self, char[] data)
|
||||
|
||||
@@ -85,7 +85,7 @@ fn char[8 * 4] entropy()
|
||||
hash(&entropy),
|
||||
random_int,
|
||||
hash(clock::now()),
|
||||
hash(&DString.init_new),
|
||||
hash(&DString.new_init),
|
||||
hash(mem::heap())
|
||||
};
|
||||
return bitcast(entropy_data, char[8 * 4]);
|
||||
|
||||
@@ -203,7 +203,7 @@ fn Backtrace! backtrace_load_element(void* addr, Allocator* allocator = mem::hea
|
||||
fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator* allocator)
|
||||
{
|
||||
BacktraceList list;
|
||||
list.init_new(backtrace.len, allocator);
|
||||
list.new_init(backtrace.len, allocator);
|
||||
defer catch
|
||||
{
|
||||
foreach (trace : list)
|
||||
|
||||
@@ -136,7 +136,7 @@ fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator* allocator)
|
||||
{
|
||||
void *load_addr = (void *)load_address()!;
|
||||
BacktraceList list;
|
||||
list.init_new(backtrace.len, allocator);
|
||||
list.new_init(backtrace.len, allocator);
|
||||
defer catch
|
||||
{
|
||||
foreach (trace : list)
|
||||
|
||||
@@ -152,7 +152,7 @@ Win32_DWORD64 displacement;
|
||||
fn BacktraceList! symbolize_backtrace(void*[] backtrace, Allocator* allocator)
|
||||
{
|
||||
BacktraceList list;
|
||||
list.init_new(backtrace.len, allocator);
|
||||
list.new_init(backtrace.len, allocator);
|
||||
Win32_HANDLE process = getCurrentProcess();
|
||||
symInitialize(process, null, 1);
|
||||
defer symCleanup(process);
|
||||
|
||||
@@ -151,6 +151,7 @@ fn void* callback(void* arg) @private
|
||||
|
||||
fn void! NativeThread.create(&thread, ThreadFn thread_fn, void* arg)
|
||||
{
|
||||
|
||||
PosixThreadData *thread_data = mem::new(PosixThreadData);
|
||||
*thread_data = { .thread_fn = thread_fn, .arg = arg };
|
||||
if (posix::pthread_create(thread, null, &callback, thread_data) != 0)
|
||||
|
||||
Reference in New Issue
Block a user