Skip to content

Commit

Permalink
Remove struct identity
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Mar 31, 2024
1 parent 96c97a3 commit ad67df5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 40 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.163_amd64.deb
sudo apt install build/meevax_0.5.164_amd64.deb
```

or
Expand Down Expand Up @@ -123,9 +123,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.163.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.164.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.163_amd64.deb`
| `package` | Generate debian package `meevax_0.5.164_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.163
0.5.164
40 changes: 16 additions & 24 deletions include/meevax/kernel/dynamic_environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ inline namespace kernel

assert(operand.is<relative>());

using index = relative::index;
assert(car(operand).is<std::int32_t>());
assert(cdr(operand).is<std::int32_t>());

assert(car(operand).is<index>());
assert(cdr(operand).is<index>());

auto i = car(operand).as<index>();
auto j = cdr(operand).as<index>();
auto i = car(operand).as<std::int32_t>();
auto j = cdr(operand).as<std::int32_t>();

assert(i < length(e));

Expand All @@ -174,13 +172,11 @@ inline namespace kernel

assert(operand.is<variadic>());

using index = variadic::index;

assert(car(operand).is<index>());
assert(cdr(operand).is<index>());
assert(car(operand).is<std::int32_t>());
assert(cdr(operand).is<std::int32_t>());

auto i = car(operand).as<index>();
auto j = cdr(operand).as<index>();
auto i = car(operand).as<std::int32_t>();
auto j = cdr(operand).as<std::int32_t>();

assert(i < length(e));

Expand Down Expand Up @@ -461,13 +457,11 @@ inline namespace kernel

assert(operand.is<relative>());

using index = relative::index;
assert(car(operand).is<std::int32_t>());
assert(cdr(operand).is<std::int32_t>());

assert(car(operand).is<index>());
assert(cdr(operand).is<index>());

auto i = car(operand).as<index>();
auto j = cdr(operand).as<index>();
auto i = car(operand).as<std::int32_t>();
auto j = cdr(operand).as<std::int32_t>();

assert(i < length(e));

Expand All @@ -487,13 +481,11 @@ inline namespace kernel

assert(operand.is<variadic>());

using index = variadic::index;

assert(car(operand).is<index>());
assert(cdr(operand).is<index>());
assert(car(operand).is<std::int32_t>());
assert(cdr(operand).is<std::int32_t>());

auto i = car(operand).as<index>();
auto j = cdr(operand).as<index>();
auto i = car(operand).as<std::int32_t>();
auto j = cdr(operand).as<std::int32_t>();

assert(i < length(e));

Expand Down
8 changes: 0 additions & 8 deletions include/meevax/kernel/identity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,14 @@ namespace meevax
{
inline namespace kernel
{
struct identity
{
using index = std::int32_t;
};

struct absolute : public virtual pair // (<identifier> . <object>)
, public identity
{
using pair::pair;
};

auto operator <<(std::ostream &, absolute const&) -> std::ostream &;

struct relative : public virtual pair // de Bruijn index
, public identity
{
using pair::pair;
};
Expand All @@ -48,7 +41,6 @@ inline namespace kernel
}

struct variadic : public virtual pair // de Bruijn index
, public identity
{
using pair::pair;
};
Expand Down
8 changes: 4 additions & 4 deletions include/meevax/kernel/syntactic_environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,11 +1128,11 @@ inline namespace kernel
}
else
{
auto i = identity::index(0);
auto i = 0;

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

for (auto inner = outer.is<pair>() ? car(outer) : unit; not inner.is<null>(); ++j, inner = inner.is<pair>() ? cdr(inner) : unit)
{
Expand All @@ -1144,12 +1144,12 @@ inline namespace kernel
}
else if (eq(car(inner), variable))
{
return make<relative>(make(i), make(j));
return make<relative>(make<std::int32_t>(i), make<std::int32_t>(j));
}
}
else if (inner.is_also<identifier>() and eq(inner, variable))
{
return make<variadic>(make(i), make(j));
return make<variadic>(make<std::int32_t>(i), make<std::int32_t>(j));
}
}
}
Expand Down

0 comments on commit ad67df5

Please sign in to comment.