Skip to content

Commit

Permalink
Merge branch 'ratio' of https://github.com/jianlingzhong/jank
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Dec 10, 2024
2 parents d9dff4f + 2321b22 commit c776a47
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 163 deletions.
2 changes: 1 addition & 1 deletion compiler+runtime/bin/format
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

git_root=$(git rev-parse --show-toplevel)

for i in $(git status | grep -E "modified:" | sed 's/modified:\s*//'); do
for i in $(git status | grep -E "modified:.*[hc]pp" | sed 's/modified:\s*//'); do
"$git_root"/compiler+runtime/build/llvm-install/usr/local/bin/clang-format -i "$i"
echo "formatted" "$i"
done
1 change: 1 addition & 0 deletions compiler+runtime/src/cpp/jank/read/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <magic_enum.hpp>

#include <jank/runtime/obj/ratio.hpp>
#include <jank/read/parse.hpp>
#include <jank/util/escape.hpp>
#include <jank/runtime/visit.hpp>
Expand Down
21 changes: 9 additions & 12 deletions compiler+runtime/src/cpp/jank/runtime/obj/ratio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ namespace jank::runtime
[this](auto const typed_o) -> native_integer {
return (data > typed_o->data) - (data < typed_o->data);
},
[&]() -> native_integer {
throw std::runtime_error{ fmt::format("not comparable: {}", runtime::to_string(&o)) };
},
&o);
}

Expand Down Expand Up @@ -229,12 +226,12 @@ namespace jank::runtime

object_ptr operator*(obj::integer_ptr const l, obj::ratio_data const &r)
{
return obj::ratio_data(l->data, 1LL) * r;
return obj::ratio_data(l->data, 1ll) * r;
}

object_ptr operator*(obj::ratio_data const &l, obj::integer_ptr const r)
{
return l * obj::ratio_data(r->data, 1LL);
return l * obj::ratio_data(r->data, 1ll);
}

native_real operator*(obj::real_ptr const l, obj::ratio_data const &r)
Expand All @@ -259,7 +256,7 @@ namespace jank::runtime

object_ptr operator*(obj::ratio_data const &l, native_integer const r)
{
return l * obj::ratio_data(r, 1LL);
return l * obj::ratio_data(r, 1ll);
}

object_ptr operator*(native_integer const l, obj::ratio_data const &r)
Expand All @@ -274,7 +271,7 @@ namespace jank::runtime

object_ptr operator/(obj::integer_ptr const l, obj::ratio_data const &r)
{
return obj::ratio_data(l->data, 1LL) / r;
return obj::ratio_data(l->data, 1ll) / r;
}

obj::ratio_ptr operator/(obj::ratio_data const &l, obj::integer_ptr const r)
Expand Down Expand Up @@ -309,7 +306,7 @@ namespace jank::runtime

object_ptr operator/(native_integer const l, obj::ratio_data const &r)
{
return obj::ratio_data(l, 1LL) / r;
return obj::ratio_data(l, 1ll) / r;
}

native_bool operator==(obj::ratio_data const &l, obj::ratio_data const &r)
Expand Down Expand Up @@ -539,22 +536,22 @@ namespace jank::runtime

native_bool operator>(native_bool l, obj::ratio_data const &r)
{
return (l ? 1LL : 0LL) > r;
return (l ? 1ll : 0ll) > r;
}

native_bool operator<(native_bool l, obj::ratio_data const &r)
{
return (l ? 1LL : 0LL) < r;
return (l ? 1ll : 0ll) < r;
}

native_bool operator>(obj::ratio_data const &l, native_bool const r)
{
return l > (r ? 1LL : 0LL);
return l > (r ? 1ll : 0ll);
}

native_bool operator<(obj::ratio_data const &l, native_bool const r)
{
return l < (r ? 1LL : 0LL);
return l < (r ? 1ll : 0ll);
}
}
}
Loading

0 comments on commit c776a47

Please sign in to comment.