Skip to content

Commit

Permalink
Re-format everything (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Jan 15, 2024
1 parent 4ec8513 commit e0b531a
Show file tree
Hide file tree
Showing 113 changed files with 7,484 additions and 4,864 deletions.
19 changes: 11 additions & 8 deletions include/cpp/jank/analyze/expr/call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ namespace jank::analyze::expr
{
runtime::object_ptr arg_expr_maps(make_box<runtime::obj::vector>());
for(auto const &e : arg_exprs)
{ arg_expr_maps = runtime::conj(arg_expr_maps, e->to_runtime_data()); }
{
arg_expr_maps = runtime::conj(arg_expr_maps, e->to_runtime_data());
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::call"),
make_box("source_expr"), source_expr->to_runtime_data(),
make_box("args"), args,
make_box("arg_exprs"), arg_expr_maps
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::call"),
make_box("source_expr"),
source_expr->to_runtime_data(),
make_box("args"),
args,
make_box("arg_exprs"),
arg_expr_maps);
}
};
}
12 changes: 6 additions & 6 deletions include/cpp/jank/analyze/expr/def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ namespace jank::analyze::expr

runtime::object_ptr to_runtime_data() const
{
return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::def"),
make_box("name"), name,
make_box("value"), detail::to_runtime_data(value)
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::def"),
make_box("name"),
name,
make_box("value"),
detail::to_runtime_data(value));
}
};
}
13 changes: 7 additions & 6 deletions include/cpp/jank/analyze/expr/do.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ namespace jank::analyze::expr
{
runtime::object_ptr body_maps(make_box<runtime::obj::vector>());
for(auto const &e : body)
{ body_maps = runtime::conj(body_maps, e->to_runtime_data()); }
{
body_maps = runtime::conj(body_maps, e->to_runtime_data());
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::do"),
make_box("body"), body_maps
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::do"),
make_box("body"),
body_maps);
}
};
}
43 changes: 26 additions & 17 deletions include/cpp/jank/analyze/expr/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace jank::analyze::expr
bool is_tail_recursive{};
/* TODO: is_pure */
};

using function_context_ptr = native_box<function_context>;

template <typename E>
Expand All @@ -35,23 +36,29 @@ namespace jank::analyze::expr
{
runtime::object_ptr param_maps(make_box<runtime::obj::vector>());
for(auto const &e : params)
{ param_maps = runtime::conj(param_maps, e); }
{
param_maps = runtime::conj(param_maps, e);
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::function_arity"),
make_box("params"), param_maps,
make_box("body"), detail::to_runtime_data(body),
make_box("frame"), detail::to_runtime_data(frame),
make_box("fn_ctx"), detail::to_runtime_data(fn_ctx)
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::function_arity"),
make_box("params"),
param_maps,
make_box("body"),
detail::to_runtime_data(body),
make_box("frame"),
detail::to_runtime_data(frame),
make_box("fn_ctx"),
detail::to_runtime_data(fn_ctx));
}
};

struct arity_key
{
bool operator==(arity_key const &rhs) const
{ return param_count == rhs.param_count && is_variadic == rhs.is_variadic; }
{
return param_count == rhs.param_count && is_variadic == rhs.is_variadic;
}

size_t param_count{};
bool is_variadic{};
Expand All @@ -67,14 +74,16 @@ namespace jank::analyze::expr
{
runtime::object_ptr arity_maps(make_box<runtime::obj::vector>());
for(auto const &e : arities)
{ arity_maps = runtime::conj(arity_maps, e.to_runtime_data()); }
{
arity_maps = runtime::conj(arity_maps, e.to_runtime_data());
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::function"),
make_box("name"), detail::to_runtime_data(name),
make_box("arities"), arity_maps
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::function"),
make_box("name"),
detail::to_runtime_data(name),
make_box("arities"),
arity_maps);
}
};
}
Expand Down
15 changes: 8 additions & 7 deletions include/cpp/jank/analyze/expr/if.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ namespace jank::analyze::expr

runtime::object_ptr to_runtime_data() const
{
return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::if"),
make_box("condition"), detail::to_runtime_data(*condition),
make_box("then"), detail::to_runtime_data(*then),
make_box("else"), detail::to_runtime_data(else_)
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::if"),
make_box("condition"),
detail::to_runtime_data(*condition),
make_box("then"),
detail::to_runtime_data(*then),
make_box("else"),
detail::to_runtime_data(else_));
}
};
}
26 changes: 12 additions & 14 deletions include/cpp/jank/analyze/expr/let.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace jank::analyze::expr

let(expression_type const type, bool const needs_box, local_frame_ptr const f)
: expression_base{ gc{}, type, f, needs_box }
{ }
{
}

native_vector<pair_type> pairs;
do_<E> body;

Expand All @@ -25,23 +27,19 @@ namespace jank::analyze::expr
runtime::object_ptr pair_maps(make_box<runtime::obj::vector>());
for(auto const &e : pairs)
{
pair_maps = runtime::conj
(
pair_maps = runtime::conj(
pair_maps,
make_box<runtime::obj::vector>
(
make_box<runtime::obj::vector>(
detail::to_runtime_data(frame->find_local_or_capture(e.first).unwrap().binding),
e.second->to_runtime_data()
)
);
e.second->to_runtime_data()));
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::let"),
make_box("pairs"), pair_maps,
make_box("body"), detail::to_runtime_data(body)
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::let"),
make_box("pairs"),
pair_maps,
make_box("body"),
detail::to_runtime_data(body));
}
};
}
12 changes: 6 additions & 6 deletions include/cpp/jank/analyze/expr/local_reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ namespace jank::analyze::expr

runtime::object_ptr to_runtime_data() const
{
return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::local_reference"),
make_box("name"), name,
make_box("binding"), detail::to_runtime_data(binding)
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::local_reference"),
make_box("name"),
name,
make_box("binding"),
detail::to_runtime_data(binding));
}
};
}
15 changes: 6 additions & 9 deletions include/cpp/jank/analyze/expr/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ namespace jank::analyze::expr
runtime::object_ptr pair_maps(make_box<runtime::obj::vector>());
for(auto const &e : data_exprs)
{
pair_maps = runtime::conj
(
pair_maps = runtime::conj(
pair_maps,
make_box<runtime::obj::vector>(e.first->to_runtime_data(), e.second->to_runtime_data())
);
make_box<runtime::obj::vector>(e.first->to_runtime_data(), e.second->to_runtime_data()));
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::map"),
make_box("data_exprs"), pair_maps
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::map"),
make_box("data_exprs"),
pair_maps);
}
};
}
39 changes: 18 additions & 21 deletions include/cpp/jank/analyze/expr/native_raw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,27 @@ namespace jank::analyze::expr
runtime::object_ptr chunk_maps(make_box<runtime::obj::vector>());
for(auto const &e : chunks)
{
chunk_maps = runtime::conj
(
chunk_maps,
boost::apply_visitor
(
[](auto const &d) -> runtime::object_ptr
{
using T = std::decay_t<decltype(d)>;
chunk_maps = runtime::conj(chunk_maps,
boost::apply_visitor(
[](auto const &d) -> runtime::object_ptr {
using T = std::decay_t<decltype(d)>;

if constexpr(std::same_as<T, native_persistent_string>)
{ return make_box(d); }
else
{ return d->to_runtime_data(); }
},
e
)
);
if constexpr(std::same_as<T, native_persistent_string>)
{
return make_box(d);
}
else
{
return d->to_runtime_data();
}
},
e));
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::native_raw"),
make_box("chunks"), chunk_maps
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::native_raw"),
make_box("chunks"),
chunk_maps);
}
};
}
9 changes: 4 additions & 5 deletions include/cpp/jank/analyze/expr/primitive_literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ namespace jank::analyze::expr

runtime::object_ptr to_runtime_data() const
{
return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::primitive_literal"),
make_box("data"), data
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::primitive_literal"),
make_box("data"),
data);
}
};
}
16 changes: 9 additions & 7 deletions include/cpp/jank/analyze/expr/recur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ namespace jank::analyze::expr
{
runtime::object_ptr arg_expr_maps(make_box<runtime::obj::vector>());
for(auto const &e : arg_exprs)
{ arg_expr_maps = runtime::conj(arg_expr_maps, e->to_runtime_data()); }
{
arg_expr_maps = runtime::conj(arg_expr_maps, e->to_runtime_data());
}

return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::recur"),
make_box("args"), args,
make_box("arg_exprs"), arg_expr_maps
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::recur"),
make_box("args"),
args,
make_box("arg_exprs"),
arg_expr_maps);
}
};
}
9 changes: 4 additions & 5 deletions include/cpp/jank/analyze/expr/throw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ namespace jank::analyze::expr

runtime::object_ptr to_runtime_data() const
{
return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::throw"),
make_box("value"), detail::to_runtime_data(*value)
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::throw"),
make_box("value"),
detail::to_runtime_data(*value));
}
};
}
12 changes: 6 additions & 6 deletions include/cpp/jank/analyze/expr/var_deref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace jank::analyze::expr

runtime::object_ptr to_runtime_data() const
{
return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::var_deref"),
make_box("qualified_name"), qualified_name,
make_box("var"), var
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::var_deref"),
make_box("qualified_name"),
qualified_name,
make_box("var"),
var);
}
};
}
12 changes: 6 additions & 6 deletions include/cpp/jank/analyze/expr/var_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace jank::analyze::expr

runtime::object_ptr to_runtime_data() const
{
return runtime::obj::persistent_array_map::create_unique
(
make_box("__type"), make_box("expr::var_ref"),
make_box("qualified_name"), qualified_name,
make_box("var"), var
);
return runtime::obj::persistent_array_map::create_unique(make_box("__type"),
make_box("expr::var_ref"),
make_box("qualified_name"),
qualified_name,
make_box("var"),
var);
}
};
}
Loading

0 comments on commit e0b531a

Please sign in to comment.