Compare commits
No commits in common. "90820f24a4ee9e1d1bc883db87994aaf6b06ae5b" and "3ae6ffdb01e02a6ceb0cbd64aab4094c4cda32f7" have entirely different histories.
90820f24a4
...
3ae6ffdb01
|
@ -45,27 +45,27 @@ namespace BAN
|
|||
HashMap<Key, T, HASH>& operator=(const HashMap<Key, T, HASH>&);
|
||||
HashMap<Key, T, HASH>& operator=(HashMap<Key, T, HASH>&&);
|
||||
|
||||
ErrorOr<iterator> insert(const Key& key, const T& value) { return emplace(key, value); }
|
||||
ErrorOr<iterator> insert(const Key& key, T&& value) { return emplace(key, move(value)); }
|
||||
ErrorOr<iterator> insert(Key&& key, const T& value) { return emplace(move(key), value); }
|
||||
ErrorOr<iterator> insert(Key&& key, T&& value) { return emplace(move(key), move(value)); }
|
||||
ErrorOr<void> insert(const Key& key, const T& value) { return emplace(key, value); }
|
||||
ErrorOr<void> insert(const Key& key, T&& value) { return emplace(key, move(value)); }
|
||||
ErrorOr<void> insert(Key&& key, const T& value) { return emplace(move(key), value); }
|
||||
ErrorOr<void> insert(Key&& key, T&& value) { return emplace(move(key), move(value)); }
|
||||
|
||||
ErrorOr<iterator> insert_or_assign(const Key& key, const T& value) { return emplace_or_assign(key, value); }
|
||||
ErrorOr<iterator> insert_or_assign(const Key& key, T&& value) { return emplace_or_assign(key, move(value)); }
|
||||
ErrorOr<iterator> insert_or_assign(Key&& key, const T& value) { return emplace_or_assign(move(key), value); }
|
||||
ErrorOr<iterator> insert_or_assign(Key&& key, T&& value) { return emplace_or_assign(move(key), move(value)); }
|
||||
ErrorOr<void> insert_or_assign(const Key& key, const T& value) { return emplace_or_assign(key, value); }
|
||||
ErrorOr<void> insert_or_assign(const Key& key, T&& value) { return emplace_or_assign(key, move(value)); }
|
||||
ErrorOr<void> insert_or_assign(Key&& key, const T& value) { return emplace_or_assign(move(key), value); }
|
||||
ErrorOr<void> insert_or_assign(Key&& key, T&& value) { return emplace_or_assign(move(key), move(value)); }
|
||||
|
||||
template<typename... Args>
|
||||
ErrorOr<iterator> emplace(const Key& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
ErrorOr<void> emplace(const Key& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
{ return emplace(Key(key), forward<Args>(args)...); }
|
||||
template<typename... Args>
|
||||
ErrorOr<iterator> emplace(Key&&, Args&&...) requires is_constructible_v<T, Args...>;
|
||||
ErrorOr<void> emplace(Key&&, Args&&...) requires is_constructible_v<T, Args...>;
|
||||
|
||||
template<typename... Args>
|
||||
ErrorOr<iterator> emplace_or_assign(const Key& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
ErrorOr<void> emplace_or_assign(const Key& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
{ return emplace_or_assign(Key(key), forward<Args>(args)...); }
|
||||
template<typename... Args>
|
||||
ErrorOr<iterator> emplace_or_assign(Key&&, Args&&...) requires is_constructible_v<T, Args...>;
|
||||
ErrorOr<void> emplace_or_assign(Key&&, Args&&...) requires is_constructible_v<T, Args...>;
|
||||
|
||||
iterator begin() { return iterator(m_buckets.end(), m_buckets.begin()); }
|
||||
iterator end() { return iterator(m_buckets.end(), m_buckets.end()); }
|
||||
|
@ -141,35 +141,34 @@ namespace BAN
|
|||
|
||||
template<typename Key, typename T, typename HASH>
|
||||
template<typename... Args>
|
||||
ErrorOr<typename HashMap<Key, T, HASH>::iterator> HashMap<Key, T, HASH>::emplace(Key&& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
ErrorOr<void> HashMap<Key, T, HASH>::emplace(Key&& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
{
|
||||
ASSERT(!contains(key));
|
||||
TRY(rebucket(m_size + 1));
|
||||
|
||||
auto bucket_it = get_bucket_iterator(key);
|
||||
TRY(bucket_it->emplace_back(move(key), forward<Args>(args)...));
|
||||
auto& bucket = get_bucket(key);
|
||||
TRY(bucket.emplace_back(move(key), forward<Args>(args)...));
|
||||
m_size++;
|
||||
|
||||
return iterator(m_buckets.end(), bucket_it, prev(bucket_it->end(), 1));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Key, typename T, typename HASH>
|
||||
template<typename... Args>
|
||||
ErrorOr<typename HashMap<Key, T, HASH>::iterator> HashMap<Key, T, HASH>::emplace_or_assign(Key&& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
ErrorOr<void> HashMap<Key, T, HASH>::emplace_or_assign(Key&& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
{
|
||||
if (empty())
|
||||
return emplace(move(key), forward<Args>(args)...);
|
||||
|
||||
auto bucket_it = get_bucket_iterator(key);
|
||||
for (auto entry_it = bucket_it->begin(); entry_it != bucket_it->end(); entry_it++)
|
||||
auto& bucket = get_bucket(key);
|
||||
for (Entry& entry : bucket)
|
||||
{
|
||||
if (entry_it->key != key)
|
||||
continue;
|
||||
entry_it->value = T(forward<Args>(args)...);
|
||||
return iterator(m_buckets.end(), bucket_it, entry_it);
|
||||
if (entry.key == key)
|
||||
{
|
||||
entry.value = T(forward<Args>(args)...);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return emplace(move(key), forward<Args>(args)...);
|
||||
TRY(bucket.emplace_back(move(key), forward<Args>(args)...));
|
||||
m_size++;
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Key, typename T, typename HASH>
|
||||
|
@ -209,7 +208,7 @@ namespace BAN
|
|||
for (Entry& entry : bucket)
|
||||
if (entry.key == key)
|
||||
return entry.value;
|
||||
ASSERT_NOT_REACHED();
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
template<typename Key, typename T, typename HASH>
|
||||
|
@ -220,7 +219,7 @@ namespace BAN
|
|||
for (const Entry& entry : bucket)
|
||||
if (entry.key == key)
|
||||
return entry.value;
|
||||
ASSERT_NOT_REACHED();
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
template<typename Key, typename T, typename HASH>
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
|
||||
#define BOCHS_BREAK() asm volatile("xchgw %bx, %bx")
|
||||
|
||||
#define DEBUG_VTTY 1
|
||||
|
||||
#define DEBUG_PCI 0
|
||||
#define DEBUG_SCHEDULER 0
|
||||
|
|
|
@ -251,7 +251,7 @@ namespace Kernel
|
|||
return reset_ansi();
|
||||
}
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character J");
|
||||
dprintln("Unsupported ANSI CSI character J");
|
||||
return;
|
||||
case 'K': // Erase in Line
|
||||
if (m_ansi_state.nums[0] == -1 || m_ansi_state.nums[0] == 0)
|
||||
|
@ -261,7 +261,7 @@ namespace Kernel
|
|||
return reset_ansi();
|
||||
}
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character K");
|
||||
dprintln("Unsupported ANSI CSI character K");
|
||||
return;
|
||||
case 'L': // Insert Line
|
||||
if (m_ansi_state.nums[0] == -1)
|
||||
|
@ -297,15 +297,15 @@ namespace Kernel
|
|||
return reset_ansi();
|
||||
case 'S': // Scroll Up
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character S");
|
||||
dprintln("Unsupported ANSI CSI character S");
|
||||
return;
|
||||
case 'T': // Scroll Down
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character T");
|
||||
dprintln("Unsupported ANSI CSI character T");
|
||||
return;
|
||||
case 'f': // Horizontal Vertical Position
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character f");
|
||||
dprintln("Unsupported ANSI CSI character f");
|
||||
return;
|
||||
case 'm':
|
||||
handle_ansi_csi_color();
|
||||
|
@ -350,7 +350,7 @@ namespace Kernel
|
|||
return reset_ansi();
|
||||
}
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "invalid ANSI CSI ?");
|
||||
dprintln("invalid ANSI CSI ?");
|
||||
return;
|
||||
case 'h':
|
||||
case 'l':
|
||||
|
@ -360,11 +360,11 @@ namespace Kernel
|
|||
return reset_ansi();
|
||||
}
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "invalid ANSI CSI ?{}{}", m_ansi_state.nums[0], (char)ch);
|
||||
dprintln("invalid ANSI CSI ?{}{}", m_ansi_state.nums[0], (char)ch);
|
||||
return;
|
||||
default:
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character {}", ch);
|
||||
dprintln("Unsupported ANSI CSI character {}", ch);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -416,9 +416,7 @@ namespace Kernel
|
|||
}
|
||||
else
|
||||
{
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "invalid utf8");
|
||||
return;
|
||||
dprintln("invalid utf8");
|
||||
}
|
||||
m_state = State::WaitingUTF8;
|
||||
return;
|
||||
|
@ -427,8 +425,8 @@ namespace Kernel
|
|||
m_state = State::WaitingAnsiCSI;
|
||||
else
|
||||
{
|
||||
dprintln("unsupported byte after ansi escape {2H}", (uint8_t)ch);
|
||||
reset_ansi();
|
||||
dprintln_if(DEBUG_VTTY, "unsupported byte after ansi escape {2H}", (uint8_t)ch);
|
||||
}
|
||||
return;
|
||||
case State::WaitingAnsiCSI:
|
||||
|
@ -438,8 +436,8 @@ namespace Kernel
|
|||
case State::WaitingUTF8:
|
||||
if ((ch & 0xC0) != 0x80)
|
||||
{
|
||||
dprintln("invalid utf8");
|
||||
m_state = State::Normal;
|
||||
dprintln_if(DEBUG_VTTY, "invalid utf8");
|
||||
return;
|
||||
}
|
||||
m_utf8_state.codepoint = (m_utf8_state.codepoint << 6) | (ch & 0x3F);
|
||||
|
|
Loading…
Reference in New Issue