-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a01d6f
commit c08f727
Showing
18 changed files
with
715 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma once | ||
|
||
#include <jank/detail/to_runtime_data.hpp> | ||
#include <jank/analyze/expression_base.hpp> | ||
#include <jank/runtime/obj/persistent_sorted_map.hpp> | ||
#include <jank/runtime/obj/persistent_hash_set.hpp> | ||
|
||
namespace jank::analyze::expr | ||
{ | ||
using namespace jank::runtime; | ||
|
||
template <typename E> | ||
struct case_ : expression_base | ||
{ | ||
enum switch_type | ||
{ | ||
integers, | ||
hashes, | ||
hash_equiv, | ||
hash_identity, | ||
}; | ||
|
||
native_box<E> value_expr{}; | ||
native_integer shift{}; | ||
native_integer mask{}; | ||
native_box<E> default_expr{}; | ||
std::vector<native_integer> keys{}; | ||
// // native_vector<native_integer> keys{}; | ||
// obj::persistent_vector_ptr exprs{}; | ||
std::vector<native_box<E>> exprs{}; | ||
native_bool is_compact{}; | ||
switch_type switch_type{}; | ||
obj::persistent_hash_set_ptr collided_keys{}; | ||
|
||
void propagate_position(expression_position const pos) | ||
{ | ||
std::cout << "set case expr position to " << expression_position_str(pos) << std::endl; | ||
default_expr->propagate_position(pos); | ||
for(auto &expr : exprs) | ||
{ | ||
expr->propagate_position(pos); | ||
} | ||
position = pos; | ||
} | ||
|
||
object_ptr to_runtime_data() const | ||
{ | ||
return merge(static_cast<expression_base const *>(this)->to_runtime_data(), | ||
obj::persistent_array_map::create_unique(make_box("__type"), | ||
make_box("expr::case"), | ||
make_box("value_expr"), | ||
value_expr->to_runtime_data(), | ||
make_box("shift"), | ||
make_box(shift), | ||
make_box("mask"), | ||
make_box(mask), | ||
make_box("default_expr"), | ||
default_expr->to_runtime_data(), | ||
// make_box("keys"), | ||
// keys, | ||
// make_box("body_exprs"), | ||
// exprs, | ||
make_box("is_compact"), | ||
make_box(is_compact), | ||
make_box("switch_type"), | ||
make_box(switch_type), | ||
make_box("collided_keys"), | ||
collided_keys)); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.