refactor: simplify standard library organization

This commit is contained in:
2026-09-20 00:40:48 +02:00
parent 438f660e76
commit 64762a45fa
9 changed files with 7 additions and 19 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ ErrorCode :: enum {
SourceError :: enum { source_too_large } SourceError :: enum { source_too_large }
keywords strmap.StringMap(TokenKind) :: strmap.init([ keywords strmap.StaticStringMap(TokenKind) :: strmap.init([
{ "proc", .proc }, { "proc", .proc },
{ "return", .return }, { "return", .return },
{ "if", .if }, { "if", .if },
+1 -1
View File
@@ -9,7 +9,7 @@ import "@source/parser"
ast_renderer :: import "@source/ast/renderer" ast_renderer :: import "@source/ast/renderer"
test import "@std/enums/enummap" test import "@std/enummap"
test import "@std/arraylist" test import "@std/arraylist"
test import "@std/hashmap" test import "@std/hashmap"
test import "@std/strmap" test import "@std/strmap"
View File
View File
-11
View File
@@ -1,11 +0,0 @@
import "io"
import "enums/enummap"
import "hashmap"
import "arraylist"
import "strmap"
Io :: alias io.Io
EnumMap :: alias enummap.EnumMap
ArrayList :: alias arraylist.ArrayList
StringHashMap :: alias hashmap.StringHashMap
StringMap :: alias strmap.StringMap
+5 -5
View File
@@ -1,6 +1,6 @@
import "@std/mem" import "@std/mem"
StringMap proc($V type) type { StaticStringMap proc($V type) type {
return struct { return struct {
keys [][]u8 keys [][]u8
values []V values []V
@@ -16,7 +16,7 @@ Pair proc($V type) type {
} }
#! initializes a static string map from a list of key-value pairs (constructed at compile-time). #! initializes a static string map from a list of key-value pairs (constructed at compile-time).
init proc($V type, $N usize, $entries [N]Pair(V)) StringMap(V) { init proc($V type, $N usize, $entries [N]Pair(V)) StaticStringMap(V) {
if N > usize(maxval!(u32)) { if N > usize(maxval!(u32)) {
compile_error!("static string map has too many entries") compile_error!("static string map has too many entries")
} }
@@ -40,7 +40,7 @@ init proc($V type, $N usize, $entries [N]Pair(V)) StringMap(V) {
if N == 0 { if N == 0 {
len_indexes [0]u32 := undefined len_indexes [0]u32 := undefined
return StringMap(V){ return StaticStringMap(V){
keys = keys[..], keys = keys[..],
values = values[..], values = values[..],
len_indexes = len_indexes[..], len_indexes = len_indexes[..],
@@ -71,7 +71,7 @@ init proc($V type, $N usize, $entries [N]Pair(V)) StringMap(V) {
len_indexes[length] = u32(entry_index) len_indexes[length] = u32(entry_index)
} }
return StringMap(V) { return StaticStringMap(V) {
keys = keys[..], keys = keys[..],
values = values[..], values = values[..],
len_indexes = len_indexes[..], len_indexes = len_indexes[..],
@@ -80,7 +80,7 @@ init proc($V type, $N usize, $entries [N]Pair(V)) StringMap(V) {
} }
} }
get proc($V type, map @StringMap(V), key []u8) ?V { get proc($V type, map @StaticStringMap(V), key []u8) ?V {
if (map.keys.len == 0 or key.len > maxval!(u32)) return null if (map.keys.len == 0 or key.len > maxval!(u32)) return null
length := u32(key.len) length := u32(key.len)
-1
View File
@@ -1 +0,0 @@
# todo