Skip to content

Commit

Permalink
Cleanup member function syntactic_environment::identify
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Dec 24, 2024
1 parent f697396 commit a7fabc4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ Then, select one of the following targets and `make` it according to your purpos

| Target | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.309.so` and executable `meevax`.
| `all` | Build shared-library `libmeevax.0.5.310.so` and executable `meevax`.
| `install` | Copy files into `/usr/local` directly.
| `package` | Generate debian package `meevax_0.5.309_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.309_amd64.deb`.
| `package` | Generate debian package `meevax_0.5.310_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.310_amd64.deb`.
| `test` | Test executable `meevax`. This target requires Valgrind to be installed.
| `uninstall` | Remove files copied to `/usr/local` directly by target `install`.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.309
0.5.310
35 changes: 17 additions & 18 deletions include/meevax/kernel/syntactic_environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,37 +933,38 @@ namespace meevax::inline kernel
{
assert(variable.is_also<identifier>());

auto i = 0;

for (auto outer = bound_variables; outer.is<pair>(); ++i, outer = cdr(outer))
for (auto i = 0; let formals : bound_variables)
{
auto j = 0;

for (auto inner = outer.is<pair>() ? car(outer) : unit; not inner.is<null>(); ++j, inner = inner.is<pair>() ? cdr(inner) : unit)
for (auto j = 0; not formals.is<null>(); formals = cdr(formals))
{
if (inner.is<pair>())
if (formals.is<pair>())
{
if (car(inner).is<absolute>() and eq(caar(inner), variable))
if (car(formals).is<absolute>() and eq(caar(formals), variable))
{
return car(inner);
return car(formals);
}
else if (eq(car(inner), variable))
else if (eq(car(formals), variable))
{
return make<relative>(make<std::int32_t>(i), make<std::int32_t>(j));
}
}
else if (inner.is_also<identifier>() and eq(inner, variable))
else if (formals.is_also<identifier>() and eq(formals, variable))
{
return make<variadic>(make<std::int32_t>(i), make<std::int32_t>(j));
}

++j;
}

++i;
}

if (variable.is<syntactic_closure>()) // Resolve alias
if (variable.is<syntactic_closure>() and
variable.as<syntactic_closure>().form.template is_also<identifier>()) // if is an alias
{
return variable.as<syntactic_closure>()
.environment
.template as<syntactic_environment>()
.template as_const<syntactic_environment>()
.identify(variable.as<syntactic_closure>().form,
unify(car(variable.as<syntactic_closure>().environment),
bound_variables));
Expand All @@ -977,11 +978,9 @@ namespace meevax::inline kernel
inline auto identify(object const& variable,
object const& bound_variables)
{
if (not variable.is_also<identifier>())
{
return f;
}
else if (let const& identity = std::as_const(*this).identify(variable, bound_variables); identity != f)
assert(variable.is_also<identifier>());

if (let const& identity = std::as_const(*this).identify(variable, bound_variables); identity != f)
{
return identity;
}
Expand Down

0 comments on commit a7fabc4

Please sign in to comment.