selfhost: add *_Drop wrappers to stdlib types; auto-drop uses _Drop instead of _Free
- Array.bux, Channel.bux, Set.bux, Map.bux: add *_Drop<T> delegating to *_Free - hir_lower.bux: Lcx_BuildAutoDropFree searches for _Drop suffix instead of _Free - Skip direct lowering of generic functions (only monomorphized instances)
This commit is contained in:
@@ -46,4 +46,8 @@ func Array_Free<T>(self: *Array<T>) {
|
||||
self.cap = 0;
|
||||
}
|
||||
|
||||
func Array_Drop<T>(self: *Array<T>) {
|
||||
Array_Free<T>(self);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ func Channel_Free<T>(ch: *Channel<T>) {
|
||||
bux_channel_free(ch.handle);
|
||||
}
|
||||
|
||||
func Channel_Drop<T>(ch: *Channel<T>) {
|
||||
Channel_Free<T>(ch);
|
||||
}
|
||||
|
||||
/* Convenience wrappers for common types */
|
||||
func Channel_SendInt(ch: *Channel<int>, value: int) {
|
||||
bux_channel_send(ch.handle, (&value) as *void);
|
||||
|
||||
@@ -87,6 +87,10 @@ func Map_Free<K, V>(m: *Map<K, V>) {
|
||||
m.len = 0;
|
||||
}
|
||||
|
||||
func Map_Drop<K, V>(m: *Map<K, V>) {
|
||||
Map_Free<K, V>(m);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// StringMap<V> — specialized Map for String keys, using strcmp
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -68,4 +68,8 @@ func Set_Free<T>(s: *Set<T>) {
|
||||
s.len = 0;
|
||||
}
|
||||
|
||||
func Set_Drop<T>(s: *Set<T>) {
|
||||
Set_Free<T>(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user