Phase 5-7: generic inference, extend Type<T>, String stdlib, Map<K,V>, self-hosting audit, docs update

This commit is contained in:
2026-05-31 13:06:29 +03:00
parent 25f846bb00
commit 5c1a00cbd6
17 changed files with 1329 additions and 134 deletions
+19 -33
View File
@@ -1,44 +1,30 @@
// Map - Hash map with String keys and int values
// Generic Map<K, V> — uses Std::Map (stdlib is merged into module)
import Std::Io::{PrintLine, PrintInt};
import Std::Map::{Map, Map_New, Map_Set, Map_Get, Map_Has, Map_Len};
import Std::Map::{Map, Map_New, Map_Set, Map_Get, Map_Has, Map_Free};
func Main() -> int {
let m: Map = Map_New(16);
PrintLine("=== Map<int, String> ===");
let m: Map<int, String> = Map_New<int, String>(16);
PrintLine("Map operations:");
Map_Set<int, String>(&m, 1, "one");
Map_Set<int, String>(&m, 2, "two");
Map_Set<int, String>(&m, 3, "three");
Map_Set(&m, "one", 1);
Map_Set(&m, "two", 2);
Map_Set(&m, "three", 3);
PrintLine("Get 1:");
PrintLine(Map_Get<int, String>(&m, 1));
PrintLine("Length:");
PrintInt(Map_Len(&m));
PrintLine("");
PrintLine("Get 2:");
PrintLine(Map_Get<int, String>(&m, 2));
PrintLine("Get 'one':");
PrintInt(Map_Get(&m, "one"));
PrintLine("");
PrintLine("Get 'two':");
PrintInt(Map_Get(&m, "two"));
PrintLine("");
PrintLine("Get 'three':");
PrintInt(Map_Get(&m, "three"));
PrintLine("");
Map_Set(&m, "two", 22);
PrintLine("Updated 'two':");
PrintInt(Map_Get(&m, "two"));
PrintLine("");
if Map_Has(&m, "one") {
PrintLine("Has 'one': yes");
if Map_Has<int, String>(&m, 1) {
PrintLine("Has 1: yes");
}
if !Map_Has(&m, "four") {
PrintLine("Has 'four': no");
}
// Test update
Map_Set<int, String>(&m, 2, "updated");
PrintLine("Updated 2:");
PrintLine(Map_Get<int, String>(&m, 2));
Map_Free<int, String>(&m);
return 0;
}
}