Skip to content

Commit

Permalink
Merge pull request #413 from yamacir-kit/complex
Browse files Browse the repository at this point in the history
Complex
  • Loading branch information
yamacir-kit authored Sep 14, 2022
2 parents dc1157d + 931b885 commit f42ae14
Show file tree
Hide file tree
Showing 45 changed files with 817 additions and 408 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|:-------------------|:--
| `all` (default) | Build shared-library `libmeevax.0.4.209.so` and executable `meevax`.
| `all` (default) | Build shared-library `libmeevax.0.4.232.so` and executable `meevax`.
| `test` | Test executable `meevax`.
| `package` | Generate debian package `meevax_0.4.209_amd64.deb`.
| `package` | Generate debian package `meevax_0.4.232_amd64.deb`.
| `install` | Copy files into `/usr/local` __(1)__.
| `install.deb` | `all` + `package` + `sudo apt install <meevax>.deb`
| `safe-install.deb` | `all` + `test` + `package` + `sudo apt install <meevax>.deb`
Expand All @@ -122,7 +122,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's
## Usage

```
Meevax Lisp System, version 0.4.209
Meevax Lisp System, version 0.4.232
Usage: meevax [OPTION...] [FILE...]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.209
0.4.232
39 changes: 20 additions & 19 deletions basis/r7rs.ss
Original file line number Diff line number Diff line change
Expand Up @@ -433,27 +433,28 @@
(define-library (scheme inexact)
(import (only (meevax inexact) finite? infinite? nan?)
(only (scheme r5rs) exp log sin cos tan asin acos atan sqrt))
(export finite?
infinite?
nan?
exp
log
sin
cos
tan
asin
acos
atan
sqrt))
(export finite? infinite? nan? exp log sin cos tan asin acos atan sqrt))

(define-library (scheme complex)
(export make-rectangular
make-polar
real-part
imag-part
angle
)
)
(import (meevax complex)
(scheme base)
(scheme inexact))

(export make-rectangular make-polar real-part imag-part magnitude angle)

(begin (define (make-polar magnitude angle)
(make-rectangular (* magnitude (cos angle))
(* magnitude (sin angle))))

(define (magnitude z)
(let ((re (real-part z))
(im (imag-part z)))
(sqrt (+ (* re re)
(* im im)))))

(define (angle z)
(atan (imag-part z)
(real-part z)))))

(define-library (scheme cxr)
(import (meevax pair))
Expand Down
2 changes: 1 addition & 1 deletion configure/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ inline namespace kernel
let static const features = list(
make<symbol>("r4rs"),
make<symbol>("exact-closed"),
// make<symbol>("exact-complex"),
make<symbol>("exact-complex"),
make<symbol>("ieee-float"),
// make<symbol>("full-unicode"),
make<symbol>("ratios"),
Expand Down
6 changes: 3 additions & 3 deletions include/meevax/iostream/escape_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ inline namespace iostream

std::tuple<
typename std::conditional<
not std::is_reference<Ts>::value or std::is_scalar<typename std::remove_reference<Ts>::type>::value,
typename std::decay<Ts>::type,
std::reference_wrapper<typename std::remove_reference<Ts>::type>
not std::is_reference_v<Ts> or std::is_scalar_v<std::remove_reference_t<Ts>>,
std::decay_t<Ts>,
std::reference_wrapper<std::remove_reference_t<Ts>>
>::type...
> references;

Expand Down
2 changes: 1 addition & 1 deletion include/meevax/iostream/lexical_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline namespace iostream
{
if (std::stringstream ss; (ss << ... << xs))
{
if constexpr (std::is_same<typename std::decay<To>::type, std::string>::value)
if constexpr (std::is_same_v<std::decay_t<To>, std::string>)
{
return ss.str();
}
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/character.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ inline namespace kernel
return codepoint;
}

explicit operator external_representation() const; // write-char (for display)
explicit operator std::string() const; // write-char (for display)
};

auto operator <<(std::ostream &, character const&) -> std::ostream &; // write
Expand Down
11 changes: 8 additions & 3 deletions include/meevax/kernel/complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#ifndef INCLUDED_MEEVAX_KERNEL_COMPLEX_HPP
#define INCLUDED_MEEVAX_KERNEL_COMPLEX_HPP

#include <complex>
#include <regex>

#include <meevax/kernel/ghost.hpp>
#include <meevax/kernel/pair.hpp>

Expand All @@ -28,13 +31,15 @@ inline namespace kernel
{
using pair::pair;

auto real() const noexcept -> const_reference;
explicit complex(std::string const&, int = 10);

auto real() noexcept -> reference;
auto canonicalize() const -> value_type;

auto imag() const noexcept -> const_reference;

auto imag() noexcept -> reference;
auto real() const noexcept -> const_reference;

explicit operator std::complex<double>();
};

auto operator <<(std::ostream &, complex const&) -> std::ostream &;
Expand Down
30 changes: 0 additions & 30 deletions include/meevax/kernel/constant.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions include/meevax/kernel/environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline namespace kernel

explicit environment(environment const&) = default;

template <typename... Ts, REQUIRES(std::is_convertible<Ts, external_representation>...)>
template <typename... Ts, REQUIRES(std::is_convertible<Ts, std::string>...)>
explicit environment(Ts&&... xs)
{
(import(xs), ...);
Expand Down Expand Up @@ -88,9 +88,9 @@ inline namespace kernel

auto import_(const_reference) -> void;

auto import_(external_representation const&) -> void;
auto import_(std::string const&) -> void;

auto load(external_representation const&) -> value_type;
auto load(std::string const&) -> value_type;

auto resolve(const_reference) -> value_type;

Expand Down
4 changes: 2 additions & 2 deletions include/meevax/kernel/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline namespace kernel

virtual auto raise() const -> void;

virtual auto what() const -> external_representation;
virtual auto what() const -> std::string;
};

auto operator <<(std::ostream &, error const&) -> std::ostream &;
Expand Down Expand Up @@ -97,7 +97,7 @@ inline namespace kernel

catch (std::exception const& error)
{
std::cerr << "; error" << error.what() << std::endl;
std::cerr << "; error " << std::quoted(error.what()) << std::endl;
return underlying_cast(exit_status::failure);
}

Expand Down
4 changes: 2 additions & 2 deletions include/meevax/kernel/exact_integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ inline namespace kernel

explicit exact_integer(double);

explicit exact_integer(external_representation const&, int = 0);
explicit exact_integer(std::string const&, int = 0);

auto operator=(exact_integer const&) -> exact_integer &;

auto operator=(exact_integer &&) noexcept -> exact_integer &;

auto operator=(external_representation const&) -> exact_integer &;
auto operator=(std::string const&) -> exact_integer &;

operator int() const;

Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/ghost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inline namespace kernel
{
struct ghost
{
external_representation const name;
std::string const name;
};

auto operator <<(std::ostream &, ghost const&) -> std::ostream &;
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/heterogeneous.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ inline namespace kernel
template <typename U>
inline auto is() const
{
return type() == typeid(typename std::decay<U>::type);
return type() == typeid(std::decay_t<U>);
}

template <typename U, REQUIRES(std::is_class<U>)>
Expand Down
6 changes: 3 additions & 3 deletions include/meevax/kernel/library.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ inline namespace kernel

auto export_(const_reference) -> void;

auto export_(external_representation const&) -> void;
auto export_(std::string const&) -> void;

auto resolve() -> const_reference;
};

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

extern std::unordered_map<external_representation, library> libraries;
extern std::unordered_map<std::string, library> libraries;

template <typename... Ts>
auto define_library(external_representation const& name, Ts&&... xs)
auto define_library(std::string const& name, Ts&&... xs)
{
return libraries.emplace(name, std::forward<decltype(xs)>(xs)...);
}
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ inline namespace kernel
{
if (current_context.is_tail)
{
assert(lexical_cast<external_representation>(current_continuation) == "(return)");
assert(lexical_cast<std::string>(current_continuation) == "(return)");

return compile(context(),
current_environment,
Expand Down
Loading

0 comments on commit f42ae14

Please sign in to comment.