Appearance
| 1 | namespace Semantic.Symbols is | |
| 2 | // Store-free bits keyed by symbol id rather than held on Function | |
| 3 | // objects. Keying by id keeps a function's bit alive across an | |
| 4 | // incremental edit that replaces the symbol object, when the | |
| 5 | // replacement adopts its predecessor's id: the debounced compile's | |
| 6 | // store-free refresh then compares its re-derived bits against the | |
| 7 | // carried baseline instead of a default, and does not escalate to a | |
| 8 | // full rebuild when nothing store-free-relevant changed. | |
| 9 | // | |
| 10 | // Absent means false — "not proven", the sound default. Cleared | |
| 11 | // whenever the symbol tables are cleared: a full rebuild re-creates | |
| 12 | // every symbol with a fresh id and re-derives every bit, so stale | |
| 13 | // entries would only accumulate. | |
| 14 | class STORE_FREE_BITS is | |
| 15 | _bits: Collections.MutableMap[int, bool]? static; | |
| 16 | ||
| 17 | bits: Collections.MutableMap[int, bool] static is | |
| 18 | if !_bits? then | |
| 19 | _bits = Collections.MAP[int, bool](); | |
| 20 | fi | |
| 21 | ||
| 22 | return _bits; | |
| 23 | si | |
| 24 | ||
| 25 | is_store_free(id: int) -> bool static => | |
| 26 | _bits? /\ _bits.contains_key(id) /\ _bits![id]; | |
| 27 | ||
| 28 | set_store_free(id: int, value: bool) static is | |
| 29 | bits[id] = value; | |
| 30 | si | |
| 31 | ||
| 32 | // A constructor writes only the fresh object being built, so it | |
| 33 | // is stricter than store-free at every call site except a | |
| 34 | // construction: `NEW` reads this bit to keep a construction from | |
| 35 | // counting as state-changing, while `obj.init(...)` on a | |
| 36 | // pre-existing receiver keeps reading the strict bit above. | |
| 37 | _construction_bits: Collections.MutableMap[int, bool]? static; | |
| 38 | ||
| 39 | construction_bits: Collections.MutableMap[int, bool] static is | |
| 40 | if !_construction_bits? then | |
| 41 | _construction_bits = Collections.MAP[int, bool](); | |
| 42 | fi | |
| 43 | ||
| 44 | return _construction_bits; | |
| 45 | si | |
| 46 | ||
| 47 | constructs_store_free(id: int) -> bool static => | |
| 48 | _construction_bits? /\ _construction_bits.contains_key(id) /\ _construction_bits![id]; | |
| 49 | ||
| 50 | set_constructs_store_free(id: int, value: bool) static is | |
| 51 | construction_bits[id] = value; | |
| 52 | si | |
| 53 | ||
| 54 | clear() static is | |
| 55 | if _bits? then | |
| 56 | _bits.clear(); | |
| 57 | fi | |
| 58 | ||
| 59 | if _construction_bits? then | |
| 60 | _construction_bits.clear(); | |
| 61 | fi | |
| 62 | si | |
| 63 | si | |
| 64 | si |