Skip to content

Commit

Permalink
Rename data member dynamic_environment::raise to exception_handler
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 6, 2024
1 parent 3828f9b commit 26e9eff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 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.194_amd64.deb
sudo apt install build/meevax_0.5.195_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.194.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.195.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.194_amd64.deb`
| `package` | Generate debian package `meevax_0.5.195_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.194
0.5.195
46 changes: 19 additions & 27 deletions include/meevax/kernel/dynamic_environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ inline namespace kernel
std::array<let, 3> a;

/*
raise is a one-argument procedure for propagating C++ exceptions thrown
in the Meevax kernel to the exception handler of the language running on
the Meevax kernel.
exception_handler is a one-argument procedure for propagating C++
exceptions thrown in the Meevax kernel to the exception handler of the
language running on the Meevax kernel.
raise is set to null by default. In this default state, that is, if raise
is null, C++ exceptions thrown in the kernel are rethrown to the outer
environment.
exception_handler is set to null by default. In this default state, that
is, if exception_handler is null, C++ exceptions thrown in the kernel
are rethrown to the outer environment.
Although raise can be set to any one-argument procedure by procedure
`kernel-exception-handler-set!`, it is basically assumed to be set to
R7RS Scheme's standard procedure `raise`.
Although exception_handler can be set to any one-argument procedure by
procedure `kernel-exception-handler-set!`, it is basically assumed to be
set to R7RS Scheme's standard procedure `raise`.
*/
let static inline raise = nullptr;
let static inline exception_handler = nullptr;

template <typename... Ts>
auto apply(object const& f, Ts&&... xs) -> decltype(auto)
auto apply(object const& procedure, Ts&&... xs) -> decltype(auto)
{
s = list(f, list(std::forward<decltype(xs)>(xs)...));
s = list(procedure, list(std::forward<decltype(xs)>(xs)...));
e = nullptr;
c = list(make(instruction::call),
make(instruction::stop));
Expand All @@ -94,9 +94,9 @@ inline namespace kernel
return run();
}

auto reraise(object const& x) -> decltype(auto)
auto raise(object const& x) -> decltype(auto)
{
return raise.is<null>() ? throw x : apply(raise, x);
return exception_handler.is<null>() ? throw x : apply(exception_handler, x);
}

auto run() -> object
Expand All @@ -119,17 +119,9 @@ inline namespace kernel
*
* ----------------------------------------------------------------- */
assert(cadr(c).template is<absolute>());

if (let const& x = cdadr(c); x == undefined)
{
throw error(make<string>("undefined variable"), caadr(c));
}
else
{
s = cons(x, s);
c = cddr(c);
goto fetch;
}
s = cons(cdadr(c), s);
c = cddr(c);
goto fetch;

case instruction::load_relative: /* ------------------------------------
*
Expand Down Expand Up @@ -527,11 +519,11 @@ inline namespace kernel
}
catch (error const& error)
{
return reraise(make(error));
return raise(make(error));
}
catch (std::exception const& exception)
{
return reraise(make<error>(make<string>(exception.what())));
return raise(make<error>(make<string>(exception.what())));
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ inline namespace kernel

library.define<procedure>("kernel-exception-handler-set!", [](let const& xs)
{
environment::raise = car(xs);
environment::exception_handler = car(xs);
});
});

Expand Down

0 comments on commit 26e9eff

Please sign in to comment.