Skip to content

Commit

Permalink
Cleanup member function environment::evaluate
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Jun 9, 2024
1 parent 26e9eff commit ad2b990
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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.195_amd64.deb
sudo apt install build/meevax_0.5.196_amd64.deb
```

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

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.195.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.196.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.195_amd64.deb`
| `package` | Generate debian package `meevax_0.5.196_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.195
0.5.196
41 changes: 27 additions & 14 deletions src/kernel/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,37 @@ inline namespace kernel
in the REPL.
*/
if (s or e or c)
struct dump
{
d = cons(std::exchange(s, nullptr),
std::exchange(e, nullptr),
std::exchange(c, nullptr), d);
}
environment & registers;

let const result = execute(optimize(compile(expression)));
let s, e, c, d;

if (d)
{
s = head(d, 0);
e = head(d, 1);
c = head(d, 2);
d = tail(d, 3);
}
explicit dump(environment & registers)
: registers { registers }
, s { std::exchange(registers.s, nullptr) }
, e { std::exchange(registers.e, nullptr) }
, c { std::exchange(registers.c, nullptr) }
, d { std::exchange(registers.d, nullptr) }
{}

~dump()
{
std::invoke(*this);
}

auto operator ()() -> void
{
registers.s = s;
registers.e = e;
registers.c = c;
registers.d = d;
}
};

auto undump = dump(*this);

return result;
return execute(optimize(compile(expression)));
}
catch (object const& x)
{
Expand Down
5 changes: 3 additions & 2 deletions src/kernel/number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <regex>
#include <string_view>

#include <meevax/kernel/error.hpp>
#include <meevax/kernel/ghost.hpp>
#include <meevax/kernel/number.hpp>
#include <meevax/kernel/string.hpp>
Expand Down Expand Up @@ -314,7 +315,7 @@ inline namespace kernel
}
else
{
throw std::domain_error("not an number");
throw error(make<string>("not an number"));
}
}

Expand All @@ -332,7 +333,7 @@ inline namespace kernel
}
else
{
throw std::domain_error("not an number");
throw error(make<string>("not an number"));
}
}

Expand Down

0 comments on commit ad2b990

Please sign in to comment.