Skip to content

Commit

Permalink
Format again, with updated configs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Feb 2, 2024
1 parent 2cdad16 commit ca28250
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 31 deletions.
7 changes: 4 additions & 3 deletions include/cpp/jank/analyze/expr/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ namespace jank::analyze::expr
runtime::object_ptr pair_maps(make_box<runtime::obj::persistent_vector>());
for(auto const &e : data_exprs)
{
pair_maps = runtime::conj(
pair_maps,
make_box<runtime::obj::persistent_vector>(e.first->to_runtime_data(), e.second->to_runtime_data()));
pair_maps
= runtime::conj(pair_maps,
make_box<runtime::obj::persistent_vector>(e.first->to_runtime_data(),
e.second->to_runtime_data()));
}

return runtime::merge(
Expand Down
10 changes: 7 additions & 3 deletions include/cpp/jank/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ namespace jank::hash
for(auto it(begin); it != end; ++it)
{
/* It's common that we have pairs of data, like with maps. */
if constexpr(requires (T t) { t.first, t.second; })
{ hash += 31 * visit((*it).first) + visit((*it).second); }
if constexpr(requires(T t) { t.first, t.second; })
{
hash += 31 * visit((*it).first) + visit((*it).second);
}
else
{ hash += visit(*it); }
{
hash += visit(*it);
}
++n;
}

Expand Down
5 changes: 4 additions & 1 deletion include/cpp/jank/native_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ namespace jank

template <typename T>
constexpr native_box<T> make_array_box()
{ return nullptr; }
{
return nullptr;
}

template <typename T, typename... Args>
native_box<T> make_array_box(Args &&...args)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace jank::runtime::detail

native_persistent_array_map clone() const;

object_ptr * data{};
object_ptr *data{};
size_t length{};
mutable native_hash hash{};
};
Expand Down
3 changes: 2 additions & 1 deletion include/cpp/jank/runtime/erasure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ namespace jank::runtime
template <typename F1, typename F2, typename... Args>
requires visitable<F1, Args...>
[[gnu::always_inline, gnu::flatten, gnu::hot]]
constexpr auto visit_seqable(F1 &&fn, F2 &&else_fn, object const * const const_erased, Args &&...args)
constexpr auto
visit_seqable(F1 &&fn, F2 &&else_fn, object const * const const_erased, Args &&...args)
{
assert(const_erased);
auto * const erased(const_cast<object *>(const_erased));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ namespace jank::runtime
{
template <>
struct static_object<object_type::persistent_array_map_sequence>
: obj::detail::base_persistent_map_sequence<object_type::persistent_array_map_sequence,
runtime::detail::native_persistent_array_map::const_iterator>
: obj::detail::base_persistent_map_sequence<
object_type::persistent_array_map_sequence,
runtime::detail::native_persistent_array_map::const_iterator>
{
using base_persistent_map_sequence::base_persistent_map_sequence;
};
Expand Down
4 changes: 3 additions & 1 deletion include/cpp/jank/runtime/obj/persistent_hash_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ namespace jank::runtime
static_object() = default;
static_object(static_object &&) = default;
static_object(static_object const &) = default;
static_object(runtime::detail::native_persistent_array_map const &m, object_ptr key, object_ptr val);
static_object(runtime::detail::native_persistent_array_map const &m,
object_ptr key,
object_ptr val);
static_object(value_type &&d);
static_object(value_type const &d);
static_object(runtime::detail::native_transient_hash_map &&d);
Expand Down
4 changes: 3 additions & 1 deletion include/cpp/jank/runtime/seq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ namespace jank::runtime
/* nil is seqable, but we don't want it to be equal to an empty collection.
* An empty seq itself is nil, but that's different. */
if constexpr(std::same_as<T, obj::nil>)
{ return false; }
{
return false;
}
else if constexpr(!behavior::seqable<T>)
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion include/cpp/jank/util/scope_exit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace jank::util
{
struct scope_exit
{
using function_type = std::function<void ()>;
using function_type = std::function<void()>;

scope_exit(function_type const &f);
scope_exit(function_type &&f);
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/jank/analyze/local_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ namespace jank::analyze
sym->name);
}
else
{ qualified_sym = make_box<runtime::obj::symbol>(*sym); }
{
qualified_sym = make_box<runtime::obj::symbol>(*sym);
}

/* We use unique native names, just so var names don't clash with the underlying C++ API. */
lifted_var lv{ runtime::context::unique_symbol(runtime::munge(qualified_sym->name)),
Expand Down
14 changes: 10 additions & 4 deletions src/cpp/jank/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,26 @@ namespace jank::hash
uint32_t integer(native_integer const input)
{
if constexpr(sizeof(uint64_t) == sizeof(native_integer))
{ return integer(static_cast<uint64_t>(input)); }
{
return integer(static_cast<uint64_t>(input));
}
else
{ return integer(static_cast<uint32_t>(input)); }
{
return integer(static_cast<uint32_t>(input));
}
}

uint32_t real(native_real const input)
{
if constexpr(8 == sizeof(native_integer))
{
auto const v(*reinterpret_cast<uint64_t const*>(&input));
auto const v(*reinterpret_cast<uint64_t const *>(&input));
return v ^ (v >> 32);
}
else
{ return *reinterpret_cast<uint32_t const*>(&input); }
{
return *reinterpret_cast<uint32_t const *>(&input);
}
}

uint32_t string(native_persistent_string_view const &input)
Expand Down
8 changes: 5 additions & 3 deletions src/cpp/jank/read/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ namespace jank::read::parse
return err(error{ start_token.pos, native_persistent_string{ "invalid value after quote" } });
}

return runtime::erase(make_box<runtime::obj::persistent_list>(make_box<runtime::obj::symbol>("quote"),
val_result.expect_ok_move()));
return runtime::erase(
make_box<runtime::obj::persistent_list>(make_box<runtime::obj::symbol>("quote"),
val_result.expect_ok_move()));
}

processor::object_result processor::parse_nil()
Expand Down Expand Up @@ -398,7 +399,8 @@ namespace jank::read::parse
auto const token(token_current->expect_ok());
++token_current;
auto const sv(boost::get<native_persistent_string_view>(token.data));
return ok(make_box<runtime::obj::persistent_string>(native_persistent_string{ sv.data(), sv.size() }));
return ok(
make_box<runtime::obj::persistent_string>(native_persistent_string{ sv.data(), sv.size() }));
}

processor::object_result processor::parse_escaped_string()
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/jank/runtime/behavior/callable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ namespace jank::runtime
return typed_source->call(a1);
}
}
else if constexpr(std::same_as<T, obj::persistent_set> || std::same_as<T, obj::persistent_hash_map>
else if constexpr(std::same_as<T, obj::persistent_set>
|| std::same_as<T, obj::persistent_hash_map>
|| std::same_as<T, obj::persistent_array_map>
|| std::same_as<T, obj::keyword>)
{
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/jank/runtime/obj/cons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ namespace jank::runtime
native_hash obj::cons::to_hash() const
{
if(hash != 0)
{ return hash; }
{
return hash;
}

return hash = hash::ordered(&base);
}
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/jank/runtime/obj/persistent_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ namespace jank::runtime
native_hash obj::persistent_vector::to_hash() const
{
if(hash != 0)
{ return hash; }
{
return hash;
}

return hash = hash::ordered(data.begin(), data.end());
}
Expand Down
7 changes: 5 additions & 2 deletions src/cpp/jank/runtime/obj/persistent_vector_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace jank::runtime
void obj::persistent_vector_sequence::to_string(fmt::memory_buffer &buff) const
{
return behavior::detail::to_string(
vec->data.begin() + static_cast<decltype(obj::persistent_vector::data)::difference_type>(index),
vec->data.begin()
+ static_cast<decltype(obj::persistent_vector::data)::difference_type>(index),
vec->data.end(),
"[",
']',
Expand All @@ -35,13 +36,15 @@ namespace jank::runtime
{
fmt::memory_buffer buff;
behavior::detail::to_string(
vec->data.begin() + static_cast<decltype(obj::persistent_vector::data)::difference_type>(index),
vec->data.begin()
+ static_cast<decltype(obj::persistent_vector::data)::difference_type>(index),
vec->data.end(),
"[",
']',
buff);
return { buff.data(), buff.size() };
}

native_hash obj::persistent_vector_sequence::to_hash() const
{
return hash::ordered(vec->data.begin(), vec->data.end());
Expand Down
5 changes: 4 additions & 1 deletion src/cpp/jank/runtime/obj/symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ namespace jank::runtime
native_hash obj::symbol::to_hash() const
{
if(hash)
{ return hash; }
{
return hash;
}

return hash = hash::combine(hash::string(name), hash::string(ns));
}
Expand Down Expand Up @@ -127,6 +129,7 @@ namespace jank::runtime
ns = s;
hash = 0;
}

void obj::symbol::set_name(native_persistent_string const &s)
{
name = s;
Expand Down
9 changes: 6 additions & 3 deletions src/cpp/jank/runtime/seq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,17 +450,20 @@ namespace jank::runtime
[&](auto const typed_other) -> object_ptr {
using O = typename decltype(typed_other)::value_type;

if constexpr(std::same_as<O, obj::persistent_hash_map> || std::same_as<O, obj::persistent_array_map>)
if constexpr(std::same_as<O, obj::persistent_hash_map>
|| std::same_as<O, obj::persistent_array_map>)
{
object_ptr ret{ m };
for(auto const &pair : typed_other->data)
{ ret = assoc(ret, pair.first, pair.second); }
{
ret = assoc(ret, pair.first, pair.second);
}
return ret;
}
else
{
throw std::runtime_error{ fmt::format("not associatively readable: {}",
typed_m->to_string()) };
typed_m->to_string()) };
}
},
other);
Expand Down

0 comments on commit ca28250

Please sign in to comment.