GOAL P3-5: StrId 를 키로 -- 별도 IntMap 은 필요 없다

std.map 은 바이트 열을 키로 받는다. 이름의 번호를 네 바이트로 써 내려놓으면
그대로 심볼 표가 된다. 감사가 권한 IntMap(V) 를 따로 만들 이유가 없고, 그
쪽이 trait 없는 v0.1 과도 덜 싸운다.

intern.key_of 가 그 네 바이트를 써준다. 리졸버가 스코프마다 할 일이라
손으로 풀게 두지 않았다.

  scope x 10 y 20 of 2

245/245, 38/38.
This commit is contained in:
2026-08-17 16:28:47 +09:00
parent b7ce16f65e
commit b0cc737c6b
2 changed files with 22 additions and 0 deletions
+11
View File
@@ -28,6 +28,17 @@ pub struct StrId {
/// No name.
pub const NONE: u32 = 4294967295;
/// A name written out as map key bytes. `std.map` keys on bytes, so a name
/// used as a key is just its number -- four of them, and nothing allocated.
/// A symbol table is `Map(V)` keyed on this.
pub fn key_of(id: StrId, out: []mut u8) -> []u8 {
out[0] = (id.raw % 256) as u8;
out[1] = ((id.raw / 256) % 256) as u8;
out[2] = ((id.raw / 65536) % 256) as u8;
out[3] = ((id.raw / 16777216) % 256) as u8;
return out[0..4];
}
struct Entry {
at: usize,
len: usize,