diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2023-11-13 22:04:32 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2023-11-13 22:04:32 -0500 |
commit | ebbde43fa98315a57a15650944f80757f9652b9b (patch) | |
tree | 71fb83ce0d0e7f1b03959f2ddb0663bc2e142578 /libalee/dictionary.cpp | |
parent | 23d746d646adb6b11fa7758a2490ff955c8a9b91 (diff) | |
parent | 0810456e9c5c19a47511a682eeabc71008632a2c (diff) |
Merge branch 'documentation'
Diffstat (limited to 'libalee/dictionary.cpp')
-rw-r--r-- | libalee/dictionary.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libalee/dictionary.cpp b/libalee/dictionary.cpp index b98b312..b1cbc5f 100644 --- a/libalee/dictionary.cpp +++ b/libalee/dictionary.cpp @@ -37,7 +37,7 @@ Addr Dictionary::allot(Cell amount) noexcept if (neww < capacity()) { write(Here, static_cast<Addr>(neww)); } else { - // TODO + // TODO how to handle allot failure? Error code? } return old; @@ -68,7 +68,7 @@ void Dictionary::addDefinition(Word word) noexcept Cell wsize = word.size(); add(wsize); - if (alignhere() - latest() >= ((1 << (sizeof(Cell) * 8 - 6)) - 1)) + if (alignhere() - latest() >= MaxDistance) add(0); auto addr = allot(wsize); @@ -91,7 +91,7 @@ Addr Dictionary::find(Word word) noexcept const Addr len = l & 0x1F; Word lw; - if ((l >> 6) < 1023) { + if ((l >> 6) < MaxDistance) { lw = Word::fromLength(lt + sizeof(Cell), len); if (equal(word, lw)) return lt; @@ -120,7 +120,7 @@ Addr Dictionary::getexec(Addr addr) noexcept const Addr len = l & 0x1Fu; addr += sizeof(Cell); - if ((l >> 6) == 1023) + if ((l >> 6) == MaxDistance) addr += sizeof(Cell); addr += len; @@ -132,7 +132,7 @@ bool Dictionary::hasInput() const noexcept { const Addr src = read(Dictionary::Source); const Addr end = read(Dictionary::SourceLen); - uint8_t idx = read(Dictionary::Input) & 0xFFu; + auto idx = static_cast<uint8_t>(read(Dictionary::Input)); while (idx < end) { auto ch = readbyte(src + idx); @@ -154,7 +154,7 @@ Word Dictionary::input() noexcept { const Addr src = read(Dictionary::Source); const Addr end = read(Dictionary::SourceLen); - uint8_t idx = read(Dictionary::Input) & 0xFFu; + auto idx = static_cast<uint8_t>(read(Dictionary::Input)); Addr wstart = src + idx; Addr wend = wstart; |