From 3232b22eecdc62d2a52f285571388aaa5d95ae34 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 30 Jun 2022 00:09:14 +0900 Subject: [PATCH 01/36] Move some `library` class member definitions into .cpp Signed-off-by: yamacir-kit --- README.md | 6 +-- VERSION | 2 +- include/meevax/kernel/library.hpp | 75 +++---------------------------- src/kernel/library.cpp | 73 +++++++++++++++++++++++++++++- 4 files changed, 82 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 340e996ef..8cb5540f2 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.4.81.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.4.82.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.4.81_amd64.deb`. +| `package` | Generate debian package `meevax_0.4.82_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -120,7 +120,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.4.81 +Meevax Lisp System, version 0.4.82 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 460492218..487f66b64 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.81 +0.4.82 diff --git a/include/meevax/kernel/library.hpp b/include/meevax/kernel/library.hpp index b5c9f11dd..c724da75a 100644 --- a/include/meevax/kernel/library.hpp +++ b/include/meevax/kernel/library.hpp @@ -35,39 +35,11 @@ inline namespace kernel declare(*this); } - explicit library(const_reference declarations) - { - for (let const& declaration : declarations) - { - declare(declaration); - } - } + explicit library(const_reference); static auto boot() -> void; - auto declare(const_reference declaration) -> void - { - if (declaration.is() and car(declaration).is() - and car(declaration).as().value == "export") - { - for (let const& export_spec : cdr(declaration)) - { - declare_export(export_spec); - } - } - else if (declaration.is() and car(declaration).is() - and car(declaration).as().value == "begin") - { - for (let const& command_or_definition : cdr(declaration)) - { - declare(command_or_definition); - } - } - else - { - evaluate(declaration); // Non-standard extension. - } - } + auto declare(const_reference) -> void; auto declare_export(const_reference export_spec) -> void { @@ -79,44 +51,7 @@ inline namespace kernel declare_export(read(export_spec)); } - auto resolve_export_specs() - { - let bindings = unit; - - for (let const& export_spec : export_specs) - { - if (export_spec.is() and car(export_spec).is() - and car(export_spec).as().value == "rename") - { - if (let const& binding = identify(cadr(export_spec), unit); binding.as().is_free()) - { - std::cout << error(make("exported but undefined"), cadr(export_spec)) << std::endl; - } - else - { - bindings = cons(make(caddr(export_spec), binding.as().load()), bindings); - } - } - else - { - if (let const& binding = identify(export_spec, unit); binding.as().is_free()) - { - std::cout << error(make("exported but undefined"), export_spec) << std::endl; - } - else - { - bindings = cons(binding, bindings); - } - } - } - - return bindings; - } - - friend auto operator <<(std::ostream & os, library const& library) -> std::ostream & - { - return os << library.global(); - } + auto resolve_export_specs() -> lvalue; #define DEFINE_BASIS_LIBRARY(NAME) \ struct NAME##_library_t \ @@ -151,7 +86,9 @@ inline namespace kernel #undef DEFINE_BASIS_LIBRARY }; - extern std::map libraries; + auto operator <<(std::ostream &, library const&) -> std::ostream &; + + extern std::unordered_map libraries; template auto define_library(std::string const& name, Ts&&... xs) diff --git a/src/kernel/library.cpp b/src/kernel/library.cpp index 34ab7485c..3ef71f233 100644 --- a/src/kernel/library.cpp +++ b/src/kernel/library.cpp @@ -1144,7 +1144,13 @@ inline namespace kernel declare_export("emergency-exit"); } - std::map libraries {}; + library::library(const_reference declarations) + { + for (let const& declaration : declarations) + { + declare(declaration); + } + } auto library::boot() -> void { @@ -1241,5 +1247,70 @@ inline namespace kernel } } } + + auto library::declare(const_reference declaration) -> void + { + if (declaration.is() and car(declaration).is() + and car(declaration).as().value == "export") + { + for (let const& export_spec : cdr(declaration)) + { + declare_export(export_spec); + } + } + else if (declaration.is() and car(declaration).is() + and car(declaration).as().value == "begin") + { + for (let const& command_or_definition : cdr(declaration)) + { + declare(command_or_definition); + } + } + else + { + evaluate(declaration); // Non-standard extension. + } + } + + auto library::resolve_export_specs() -> lvalue + { + let bindings = unit; + + for (let const& export_spec : export_specs) + { + if (export_spec.is() and car(export_spec).is() + and car(export_spec).as().value == "rename") + { + if (let const& binding = identify(cadr(export_spec), unit); binding.as().is_free()) + { + std::cout << error(make("exported but undefined"), cadr(export_spec)) << std::endl; + } + else + { + bindings = cons(make(caddr(export_spec), binding.as().load()), bindings); + } + } + else + { + if (let const& binding = identify(export_spec, unit); binding.as().is_free()) + { + std::cout << error(make("exported but undefined"), export_spec) << std::endl; + } + else + { + bindings = cons(binding, bindings); + } + } + } + + return bindings; + } + + auto operator <<(std::ostream & os, library const& library) -> std::ostream & + { + return os << library.global(); + } + + std::unordered_map libraries {}; } // namespace kernel } // namespace meevax From a5795d9203eaa8b44ae8e16215b492b9d1286b9d Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 30 Jun 2022 00:24:46 +0900 Subject: [PATCH 02/36] Rename `library::declare_export` to `export_` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/library.hpp | 10 +- src/kernel/library.cpp | 380 +++++++++++++++--------------- 4 files changed, 201 insertions(+), 197 deletions(-) diff --git a/README.md b/README.md index 8cb5540f2..ea9f1ba38 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.4.82.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.4.83.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.4.82_amd64.deb`. +| `package` | Generate debian package `meevax_0.4.83_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -120,7 +120,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.4.82 +Meevax Lisp System, version 0.4.83 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 487f66b64..6f7c9a31a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.82 +0.4.83 diff --git a/include/meevax/kernel/library.hpp b/include/meevax/kernel/library.hpp index c724da75a..aa1866b9f 100644 --- a/include/meevax/kernel/library.hpp +++ b/include/meevax/kernel/library.hpp @@ -41,15 +41,9 @@ inline namespace kernel auto declare(const_reference) -> void; - auto declare_export(const_reference export_spec) -> void - { - export_specs.push_back(export_spec); - } + auto export_(const_reference) -> void; - auto declare_export(std::string const& export_spec) -> void - { - declare_export(read(export_spec)); - } + auto export_(std::string const&) -> void; auto resolve_export_specs() -> lvalue; diff --git a/src/kernel/library.cpp b/src/kernel/library.cpp index 3ef71f233..c5f511c50 100644 --- a/src/kernel/library.cpp +++ b/src/kernel/library.cpp @@ -37,18 +37,18 @@ inline namespace kernel define("quote-syntax", quote_syntax); define("set!", set); - declare_export("begin"); - declare_export("call-with-current-continuation!"); - declare_export("define"); - declare_export("define-syntax"); - declare_export("if"); - declare_export("lambda"); - declare_export("let-syntax"); - declare_export("letrec"); - declare_export("letrec-syntax"); - declare_export("quote"); - declare_export("quote-syntax"); - declare_export("set!"); + export_("begin"); + export_("call-with-current-continuation!"); + export_("define"); + export_("define-syntax"); + export_("if"); + export_("lambda"); + export_("let-syntax"); + export_("letrec"); + export_("letrec-syntax"); + export_("quote"); + export_("quote-syntax"); + export_("set!"); } library::library(environment_library_t) @@ -75,9 +75,9 @@ inline namespace kernel return interaction_environment(); }); - declare_export("environment"); - declare_export("interaction-environment"); - declare_export("%load"); + export_("environment"); + export_("interaction-environment"); + export_("%load"); } library::library(equivalence_library_t) @@ -85,8 +85,8 @@ inline namespace kernel define("eq?", [](let const& xs) { return eq (car(xs), cadr(xs)); }); define("eqv?", [](let const& xs) { return eqv(car(xs), cadr(xs)); }); - declare_export("eq?"); - declare_export("eqv?"); + export_("eq?"); + export_("eqv?"); } library::library(number_library_t) @@ -181,36 +181,36 @@ inline namespace kernel return make(lexical_cast(car(xs))); }); - declare_export("number?"); - declare_export("complex?"); - declare_export("real?"); - declare_export("rational?"); - declare_export("integer?"); - declare_export("exact-integer?"); - declare_export("%complex?"); - declare_export("ratio?"); - declare_export("single-float?"); - declare_export("double-float?"); - declare_export("="); - declare_export("!="); - declare_export("<"); - declare_export("<="); - declare_export(">"); - declare_export(">="); - declare_export("+"); - declare_export("*"); - declare_export("-"); - declare_export("/"); - declare_export("%"); - declare_export("floor"); - declare_export("ceiling"); - declare_export("truncate"); - declare_export("round"); - declare_export("expt"); - declare_export("exact"); - declare_export("inexact"); - declare_export("integer->char"); - declare_export("number->string"); + export_("number?"); + export_("complex?"); + export_("real?"); + export_("rational?"); + export_("integer?"); + export_("exact-integer?"); + export_("%complex?"); + export_("ratio?"); + export_("single-float?"); + export_("double-float?"); + export_("="); + export_("!="); + export_("<"); + export_("<="); + export_(">"); + export_(">="); + export_("+"); + export_("*"); + export_("-"); + export_("/"); + export_("%"); + export_("floor"); + export_("ceiling"); + export_("truncate"); + export_("round"); + export_("expt"); + export_("exact"); + export_("inexact"); + export_("integer->char"); + export_("number->string"); } library::library(inexact_library_t) @@ -268,24 +268,24 @@ inline namespace kernel } }); - declare_export("finite?"); - declare_export("infinite?"); - declare_export("nan?"); - declare_export("exp"); - declare_export("sqrt"); - declare_export("log"); - declare_export("sin"); - declare_export("asin"); - declare_export("sinh"); - declare_export("asinh"); - declare_export("cos"); - declare_export("acos"); - declare_export("cosh"); - declare_export("acosh"); - declare_export("tan"); - declare_export("atan"); - declare_export("tanh"); - declare_export("atanh"); + export_("finite?"); + export_("infinite?"); + export_("nan?"); + export_("exp"); + export_("sqrt"); + export_("log"); + export_("sin"); + export_("asin"); + export_("sinh"); + export_("asinh"); + export_("cos"); + export_("acos"); + export_("cosh"); + export_("acosh"); + export_("tan"); + export_("atan"); + export_("tanh"); + export_("atanh"); } library::library(pair_library_t) @@ -337,40 +337,40 @@ inline namespace kernel define("set-car!", [](auto&& xs) { return caar(xs) = cadr(xs); }); define("set-cdr!", [](auto&& xs) { return cdar(xs) = cadr(xs); }); - declare_export("pair?"); - declare_export("cons"); - declare_export("car"); - declare_export("cdr"); - declare_export("set-car!"); - declare_export("set-cdr!"); - declare_export("caaaar"); - declare_export("caaadr"); - declare_export("caaar"); - declare_export("caadar"); - declare_export("caaddr"); - declare_export("caadr"); - declare_export("caar"); - declare_export("cadaar"); - declare_export("cadadr"); - declare_export("cadar"); - declare_export("caddar"); - declare_export("cadddr"); - declare_export("caddr"); - declare_export("cadr"); - declare_export("cdaaar"); - declare_export("cdaadr"); - declare_export("cdaar"); - declare_export("cdadar"); - declare_export("cdaddr"); - declare_export("cdadr"); - declare_export("cdar"); - declare_export("cddaar"); - declare_export("cddadr"); - declare_export("cddar"); - declare_export("cdddar"); - declare_export("cddddr"); - declare_export("cdddr"); - declare_export("cddr"); + export_("pair?"); + export_("cons"); + export_("car"); + export_("cdr"); + export_("set-car!"); + export_("set-cdr!"); + export_("caaaar"); + export_("caaadr"); + export_("caaar"); + export_("caadar"); + export_("caaddr"); + export_("caadr"); + export_("caar"); + export_("cadaar"); + export_("cadadr"); + export_("cadar"); + export_("caddar"); + export_("cadddr"); + export_("caddr"); + export_("cadr"); + export_("cdaaar"); + export_("cdaadr"); + export_("cdaar"); + export_("cdadar"); + export_("cdaddr"); + export_("cdadr"); + export_("cdar"); + export_("cddaar"); + export_("cddadr"); + export_("cddar"); + export_("cdddar"); + export_("cddddr"); + export_("cdddr"); + export_("cddr"); } library::library(list_library_t) @@ -402,10 +402,10 @@ inline namespace kernel return make(for_each_in, car(xs)); }); - declare_export("null?"); - declare_export("append"); - declare_export("list->string"); - declare_export("list->vector"); + export_("null?"); + export_("append"); + export_("list->string"); + export_("list->vector"); } library::library(symbol_library_t) @@ -420,8 +420,8 @@ inline namespace kernel return make(car(xs).as()); }); - declare_export("symbol?"); - declare_export("symbol->string"); + export_("symbol?"); + export_("symbol->string"); } library::library(character_library_t) @@ -455,9 +455,9 @@ inline namespace kernel } }); - declare_export("char?"); - declare_export("char->integer"); - declare_export("char-codepoint"); + export_("char?"); + export_("char->integer"); + export_("char-codepoint"); } library::library(string_library_t) @@ -582,21 +582,21 @@ inline namespace kernel return intern(car(xs).as()); }); - declare_export("string?"); - declare_export("make-string"); - declare_export("string-append"); - declare_export("string-copy"); - declare_export("string-length"); - declare_export("string-ref"); - declare_export("string-set!"); - declare_export("string=?"); - declare_export("string?"); - declare_export("string>=?"); - declare_export("string->list"); - declare_export("string->number"); - declare_export("string->symbol"); + export_("string?"); + export_("make-string"); + export_("string-append"); + export_("string-copy"); + export_("string-length"); + export_("string-ref"); + export_("string-set!"); + export_("string=?"); + export_("string?"); + export_("string>=?"); + export_("string->list"); + export_("string->number"); + export_("string->symbol"); } library::library(vector_library_t) @@ -700,15 +700,15 @@ inline namespace kernel } }); - declare_export("vector?"); - declare_export("vector"); - declare_export("make-vector"); - declare_export("vector-length"); - declare_export("vector-ref"); - declare_export("vector-set!"); - declare_export("vector-fill!"); - declare_export("vector->list"); - declare_export("vector->string"); + export_("vector?"); + export_("vector"); + export_("make-vector"); + export_("vector-length"); + export_("vector-ref"); + export_("vector-set!"); + export_("vector-fill!"); + export_("vector->list"); + export_("vector->string"); } library::library(control_library_t) @@ -723,8 +723,8 @@ inline namespace kernel return car(xs).is(); }); - declare_export("closure?"); - declare_export("continuation?"); + export_("closure?"); + export_("continuation?"); } library::library(exception_library_t) @@ -759,12 +759,12 @@ inline namespace kernel return car(xs).is(); }); - declare_export("throw"); - declare_export("make-error"); - declare_export("error?"); - declare_export("read-error?"); - declare_export("file-error?"); - declare_export("syntax-error?"); + export_("throw"); + export_("make-error"); + export_("error?"); + export_("read-error?"); + export_("file-error?"); + export_("syntax-error?"); } library::library(port_library_t) @@ -953,32 +953,32 @@ inline namespace kernel return unspecified_object; }); - declare_export("input-port?"); - declare_export("output-port?"); - declare_export("binary-port?"); - declare_export("textual-port?"); - declare_export("port?"); - declare_export("input-port-open?"); - declare_export("output-port-open?"); - declare_export("standard-input-port"); - declare_export("standard-output-port"); - declare_export("standard-error-port"); - declare_export("open-input-file"); - declare_export("open-output-file"); - declare_export("close-input-port"); - declare_export("close-output-port"); - declare_export("open-input-string"); - declare_export("open-output-string"); - declare_export("get-output-string"); - declare_export("%read-char"); - declare_export("%peek-char"); - declare_export("eof-object?"); - declare_export("eof-object"); - declare_export("read-ready?"); - declare_export("%read-string"); - declare_export("put-char"); - declare_export("put-string"); - declare_export("%flush-output-port"); + export_("input-port?"); + export_("output-port?"); + export_("binary-port?"); + export_("textual-port?"); + export_("port?"); + export_("input-port-open?"); + export_("output-port-open?"); + export_("standard-input-port"); + export_("standard-output-port"); + export_("standard-error-port"); + export_("open-input-file"); + export_("open-output-file"); + export_("close-input-port"); + export_("close-output-port"); + export_("open-input-string"); + export_("open-output-string"); + export_("get-output-string"); + export_("%read-char"); + export_("%peek-char"); + export_("eof-object?"); + export_("eof-object"); + export_("read-ready?"); + export_("%read-string"); + export_("put-char"); + export_("put-string"); + export_("%flush-output-port"); } library::library(evaluate_library_t) @@ -988,7 +988,7 @@ inline namespace kernel return cadr(xs).as().evaluate(car(xs)); }); - declare_export("eval"); + export_("eval"); } library::library(read_library_t) @@ -1009,7 +1009,7 @@ inline namespace kernel } }); - declare_export("%read"); + export_("%read"); } library::library(write_library_t) @@ -1039,8 +1039,8 @@ inline namespace kernel return standard_output; }); - declare_export("%write-simple"); - declare_export("print"); + export_("%write-simple"); + export_("print"); } library::library(macro_library_t) @@ -1077,11 +1077,11 @@ inline namespace kernel return make(car(xs), cadr(xs), caddr(xs)); }); - declare_export("identifier?"); - declare_export("identifier->symbol"); - declare_export("transformer?"); - declare_export("syntactic-closure?"); - declare_export("make-syntactic-closure"); + export_("identifier?"); + export_("identifier->symbol"); + export_("transformer?"); + export_("syntactic-closure?"); + export_("make-syntactic-closure"); } library::library(experimental_library_t) @@ -1111,9 +1111,9 @@ inline namespace kernel return std::numeric_limits::is_iec559; }); - declare_export("type-of"); - declare_export("disassemble"); - declare_export("ieee-float?"); + export_("type-of"); + export_("disassemble"); + export_("ieee-float?"); } library::library(context_library_t) @@ -1141,7 +1141,7 @@ inline namespace kernel } }); - declare_export("emergency-exit"); + export_("emergency-exit"); } library::library(const_reference declarations) @@ -1187,8 +1187,8 @@ inline namespace kernel return car(xs).is(); }); - library.declare_export("foreign-function"); - library.declare_export("foreign-function?"); + library.export_("foreign-function"); + library.export_("foreign-function?"); }); define_library("(meevax garbage-collector)", [](library & library) @@ -1203,8 +1203,8 @@ inline namespace kernel return make(gc.count()); }); - library.declare_export("gc-collect"); - library.declare_export("gc-count"); + library.export_("gc-collect"); + library.export_("gc-count"); }); define_library("(meevax version)", [](library & library) @@ -1214,7 +1214,7 @@ inline namespace kernel return features(); }); - library.declare_export("features"); + library.export_("features"); }); std::vector const codes { @@ -1255,7 +1255,7 @@ inline namespace kernel { for (let const& export_spec : cdr(declaration)) { - declare_export(export_spec); + export_(export_spec); } } else if (declaration.is() and car(declaration).is() @@ -1272,6 +1272,16 @@ inline namespace kernel } } + auto library::export_(const_reference export_spec) -> void + { + export_specs.push_back(export_spec); + } + + auto library::export_(std::string const& export_spec) -> void + { + export_(read(export_spec)); + } + auto library::resolve_export_specs() -> lvalue { let bindings = unit; From 472be2a026cc4284ef188df0ac4ba5d3381a5350 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 30 Jun 2022 01:05:16 +0900 Subject: [PATCH 03/36] Rename `library::declare_import` to `import_` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/environment.hpp | 17 ++--- include/meevax/kernel/library.hpp | 2 +- src/kernel/environment.cpp | 92 ++++++++++++++------------- src/kernel/library.cpp | 10 +-- src/main.cpp | 2 +- 7 files changed, 63 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index ea9f1ba38..3740a531e 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.4.83.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.4.84.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.4.83_amd64.deb`. +| `package` | Generate debian package `meevax_0.4.84_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -120,7 +120,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.4.83 +Meevax Lisp System, version 0.4.84 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 6f7c9a31a..1bf629591 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.83 +0.4.84 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 160ad2c46..92cc03f43 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -56,12 +56,6 @@ inline namespace kernel explicit environment(Ts&&... xs) { (import(xs), ...); - - // define("set-batch!", [this](let const& xs, auto&&...) { return batch = select(car(xs)); }); - // define("set-debug!", [this](let const& xs, auto&&...) { return debug = select(car(xs)); }); - // define("set-interactive!", [this](let const& xs, auto&&...) { return interactive = select(car(xs)); }); - // define("set-trace!", [this](let const& xs, auto&&...) { return trace = select(car(xs)); }); - // define("set-verbose!", [this](let const& xs, auto&&...) { return verbose = select(car(xs)); }); } auto operator [](const_reference) -> const_reference; @@ -70,13 +64,6 @@ inline namespace kernel auto apply(const_reference, const_reference) -> lvalue; - auto declare_import(const_reference) -> void; - - auto declare_import(std::string const& import_set) -> void - { - declare_import(read(import_set)); - } - auto define(const_reference, const_reference = undefined) -> void; auto define(symbol::value_type const&, const_reference = undefined) -> void; @@ -109,6 +96,10 @@ inline namespace kernel auto global() const noexcept -> const_reference; + auto import_(const_reference) -> void; + + auto import_(std::string const&) -> void; + auto load(std::string const&) -> lvalue; auto scope() const noexcept -> const_reference; diff --git a/include/meevax/kernel/library.hpp b/include/meevax/kernel/library.hpp index aa1866b9f..b6ed7b76f 100644 --- a/include/meevax/kernel/library.hpp +++ b/include/meevax/kernel/library.hpp @@ -39,7 +39,7 @@ inline namespace kernel static auto boot() -> void; - auto declare(const_reference) -> void; + auto evaluate(const_reference) -> void; auto export_(const_reference) -> void; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 60b22e459..695fcb8d8 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -51,49 +51,6 @@ inline namespace kernel return result; } - auto resolve_import_set(const_reference import_set) -> lvalue - { - if (car(import_set).as().value == "only") - { - let const exported_bindings = resolve_import_set(cadr(import_set)); - - let filtered_bindings = unit; - - for (let const& identifier : cddr(import_set)) - { - if (let const& binding = assq(identifier, exported_bindings); select(binding)) - { - filtered_bindings = cons(binding, filtered_bindings); - } - else - { - throw error(make("no such identifier"), identifier); - } - } - - return filtered_bindings; - } - else if (auto iter = libraries.find(lexical_cast(import_set)); iter != std::end(libraries)) - { - return std::get<1>(*iter).resolve_export_specs(); - } - else - { - throw error(make("no such library"), import_set); - } - } - - auto environment::declare_import(const_reference import_set) -> void - { - let const bindings = resolve_import_set(import_set); - - for (let const& binding : bindings) - { - define(binding.as().symbol(), - binding.as().load()); - } - } - auto environment::define(const_reference name, const_reference value) -> void { assert(name.is_also()); @@ -119,7 +76,7 @@ inline namespace kernel { for (let const& import_set : cdr(expression)) { - declare_import(import_set); + import_(import_set); } return unspecified_object; @@ -172,6 +129,53 @@ inline namespace kernel return second; } + auto resolve_import_set(const_reference import_set) -> lvalue + { + if (car(import_set).as().value == "only") + { + let const exported_bindings = resolve_import_set(cadr(import_set)); + + let filtered_bindings = unit; + + for (let const& identifier : cddr(import_set)) + { + if (let const& binding = assq(identifier, exported_bindings); select(binding)) + { + filtered_bindings = cons(binding, filtered_bindings); + } + else + { + throw error(make("no such identifier"), identifier); + } + } + + return filtered_bindings; + } + else if (auto iter = libraries.find(lexical_cast(import_set)); iter != std::end(libraries)) + { + return std::get<1>(*iter).resolve_export_specs(); + } + else + { + throw error(make("no such library"), import_set); + } + } + + auto environment::import_(const_reference import_set) -> void + { + let const bindings = resolve_import_set(import_set); + + for (let const& binding : bindings) + { + define(binding.as().symbol(), binding.as().load()); + } + } + + auto environment::import_(std::string const& import_set) -> void + { + import_(read(import_set)); + } + auto environment::load(std::string const& s) -> lvalue { if (let port = make(s); port and port.as().is_open()) diff --git a/src/kernel/library.cpp b/src/kernel/library.cpp index c5f511c50..01d0baabc 100644 --- a/src/kernel/library.cpp +++ b/src/kernel/library.cpp @@ -59,7 +59,7 @@ inline namespace kernel for (let const& x : xs) { - e.as().declare_import(x); + e.as().import_(x); } return e; @@ -1148,7 +1148,7 @@ inline namespace kernel { for (let const& declaration : declarations) { - declare(declaration); + evaluate(declaration); } } @@ -1248,7 +1248,7 @@ inline namespace kernel } } - auto library::declare(const_reference declaration) -> void + auto library::evaluate(const_reference declaration) -> void { if (declaration.is() and car(declaration).is() and car(declaration).as().value == "export") @@ -1263,12 +1263,12 @@ inline namespace kernel { for (let const& command_or_definition : cdr(declaration)) { - declare(command_or_definition); + evaluate(command_or_definition); } } else { - evaluate(declaration); // Non-standard extension. + environment::evaluate(declaration); // Non-standard extension. } } diff --git a/src/main.cpp b/src/main.cpp index 0aca95e72..3cdd734dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,7 @@ auto main(int const argc, char const* const* const argv) -> int if (main.interactive) { main.display_version(); - main.declare_import("(scheme r5rs)"); + main.import_("(scheme r5rs)"); } while (main.interactive and main.char_ready()) From 25dfbef3d10c2f83bbd8225348eaa0b78b32192c Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 30 Jun 2022 01:52:21 +0900 Subject: [PATCH 04/36] Rename typename `lvalue` to `value_type` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/complex.hpp | 14 ++++---- include/meevax/kernel/configurator.hpp | 8 ++--- include/meevax/kernel/constant.hpp | 2 +- include/meevax/kernel/environment.hpp | 16 ++++----- include/meevax/kernel/exact_integer.hpp | 20 +++++------ include/meevax/kernel/floating_point.hpp | 28 +++++++-------- include/meevax/kernel/identity.hpp | 16 ++++----- include/meevax/kernel/iterator.hpp | 8 ++--- include/meevax/kernel/library.hpp | 4 +-- include/meevax/kernel/list.hpp | 22 ++++++------ include/meevax/kernel/machine.hpp | 8 ++--- include/meevax/kernel/number.hpp | 22 ++++++------ include/meevax/kernel/object.hpp | 4 +-- include/meevax/kernel/optimizer.hpp | 2 +- include/meevax/kernel/overview.hpp | 26 +++++++------- include/meevax/kernel/pair.hpp | 6 ++-- include/meevax/kernel/procedure.hpp | 2 +- include/meevax/kernel/ratio.hpp | 20 +++++------ include/meevax/kernel/reader.hpp | 14 ++++---- include/meevax/kernel/string.hpp | 4 +-- include/meevax/kernel/syntax.hpp | 2 +- include/meevax/kernel/vector.hpp | 5 ++- src/kernel/constant.cpp | 2 +- src/kernel/environment.cpp | 16 ++++----- src/kernel/exact_integer.cpp | 10 +++--- src/kernel/identity.cpp | 12 +++---- src/kernel/library.cpp | 14 ++++---- src/kernel/list.cpp | 12 +++---- src/kernel/number.cpp | 44 ++++++++++++------------ src/kernel/ratio.cpp | 10 +++--- src/kernel/string.cpp | 4 +-- 33 files changed, 191 insertions(+), 194 deletions(-) diff --git a/README.md b/README.md index 3740a531e..028c6ab0a 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.4.84.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.4.85.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.4.84_amd64.deb`. +| `package` | Generate debian package `meevax_0.4.85_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -120,7 +120,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.4.84 +Meevax Lisp System, version 0.4.85 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1bf629591..aab4c6e65 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.84 +0.4.85 diff --git a/include/meevax/kernel/complex.hpp b/include/meevax/kernel/complex.hpp index 59f173cfb..c75d3cd81 100644 --- a/include/meevax/kernel/complex.hpp +++ b/include/meevax/kernel/complex.hpp @@ -38,7 +38,7 @@ inline namespace kernel auto imag() noexcept -> reference; #define DEFINE(NAME) \ - auto NAME() const -> lvalue override \ + auto NAME() const -> value_type override \ { \ return unspecified_object; \ } \ @@ -55,7 +55,7 @@ inline namespace kernel #undef DEFINE #define DEFINE(NAME) \ - auto NAME(const_reference) const -> lvalue override \ + auto NAME(const_reference) const -> value_type override \ { \ return unspecified_object; \ } \ @@ -66,11 +66,11 @@ inline namespace kernel #undef DEFINE - auto operator + (const_reference) const -> lvalue override { return unspecified_object; } - auto operator - (const_reference) const -> lvalue override { return unspecified_object; } - auto operator * (const_reference) const -> lvalue override { return unspecified_object; } - auto operator / (const_reference) const -> lvalue override { return unspecified_object; } - auto operator % (const_reference) const -> lvalue override { return unspecified_object; } + auto operator + (const_reference) const -> value_type override { return unspecified_object; } + auto operator - (const_reference) const -> value_type override { return unspecified_object; } + auto operator * (const_reference) const -> value_type override { return unspecified_object; } + auto operator / (const_reference) const -> value_type override { return unspecified_object; } + auto operator % (const_reference) const -> value_type override { return unspecified_object; } auto operator ==(const_reference) const -> bool override { return false; }; auto operator !=(const_reference) const -> bool override { return false; }; diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index 6d58d3de6..705c4ca7a 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -90,7 +90,7 @@ inline namespace kernel return make(debug = true); }), - std::make_pair('h', [](auto&&...) -> lvalue + std::make_pair('h', [](auto&&...) -> value_type { configurator::display_help(); throw exit_status::success; @@ -101,7 +101,7 @@ inline namespace kernel return make(interactive = true); }), - std::make_pair('v', [](auto&&...) -> lvalue + std::make_pair('v', [](auto&&...) -> value_type { configurator::display_version(); throw exit_status::success; @@ -140,7 +140,7 @@ inline namespace kernel return make(debug = true); }), - std::make_pair("help", [](auto&&...) -> lvalue + std::make_pair("help", [](auto&&...) -> value_type { display_help(); throw exit_status::success; @@ -161,7 +161,7 @@ inline namespace kernel return make(verbose = true); }), - std::make_pair("version", [](auto&&...) -> lvalue + std::make_pair("version", [](auto&&...) -> value_type { display_version(); throw exit_status::success; diff --git a/include/meevax/kernel/constant.hpp b/include/meevax/kernel/constant.hpp index 120aeafb3..dfdd9a564 100644 --- a/include/meevax/kernel/constant.hpp +++ b/include/meevax/kernel/constant.hpp @@ -23,7 +23,7 @@ namespace meevax { inline namespace kernel { - extern std::unordered_map const constants; + extern std::unordered_map const constants; } // namespace kernel } // namespace meevax diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 92cc03f43..8fff4a5d4 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -62,7 +62,7 @@ inline namespace kernel auto operator [](std::string const&) -> const_reference; - auto apply(const_reference, const_reference) -> lvalue; + auto apply(const_reference, const_reference) -> value_type; auto define(const_reference, const_reference = undefined) -> void; @@ -74,13 +74,13 @@ inline namespace kernel define(name, make(name, std::forward(xs)...)); } - auto evaluate(const_reference) -> lvalue; + auto evaluate(const_reference) -> value_type; - auto execute() -> lvalue; + auto execute() -> value_type; - auto execute(const_reference) -> lvalue; + auto execute(const_reference) -> value_type; - auto fork() const -> lvalue + auto fork() const -> value_type { return make(*this); } @@ -100,15 +100,15 @@ inline namespace kernel auto import_(std::string const&) -> void; - auto load(std::string const&) -> lvalue; + auto load(std::string const&) -> value_type; auto scope() const noexcept -> const_reference; auto scope() noexcept -> reference; - auto identify(const_reference, const_reference) -> lvalue; + auto identify(const_reference, const_reference) -> value_type; - auto identify(const_reference, const_reference) const -> lvalue; + auto identify(const_reference, const_reference) const -> value_type; }; auto operator >>(std::istream &, environment &) -> std::istream &; diff --git a/include/meevax/kernel/exact_integer.hpp b/include/meevax/kernel/exact_integer.hpp index bf50a8313..f11e5f387 100644 --- a/include/meevax/kernel/exact_integer.hpp +++ b/include/meevax/kernel/exact_integer.hpp @@ -28,13 +28,11 @@ inline namespace kernel { struct exact_integer : public number { - using value_type = mpz_t; - - value_type value; + mpz_t value; explicit exact_integer() noexcept; - explicit exact_integer(value_type) noexcept; + explicit exact_integer(mpz_t) noexcept; exact_integer(exact_integer const&) noexcept; @@ -85,7 +83,7 @@ inline namespace kernel auto truncate_quotient(exact_integer const&) const -> exact_integer; - #define DEFINE(NAME) auto NAME() const -> lvalue override + #define DEFINE(NAME) auto NAME() const -> value_type override DEFINE(exact); DEFINE(inexact); @@ -97,7 +95,7 @@ inline namespace kernel #undef DEFINE - #define DEFINE(NAME) auto NAME(const_reference) const -> lvalue override + #define DEFINE(NAME) auto NAME(const_reference) const -> value_type override DEFINE(atan2); DEFINE(pow); @@ -118,11 +116,11 @@ inline namespace kernel explicit operator std::string() const; - auto operator + (const_reference) const -> lvalue override; - auto operator - (const_reference) const -> lvalue override; - auto operator * (const_reference) const -> lvalue override; - auto operator / (const_reference) const -> lvalue override; - auto operator % (const_reference) const -> lvalue override; + auto operator + (const_reference) const -> value_type override; + auto operator - (const_reference) const -> value_type override; + auto operator * (const_reference) const -> value_type override; + auto operator / (const_reference) const -> value_type override; + auto operator % (const_reference) const -> value_type override; auto operator ==(const_reference) const -> bool override; auto operator !=(const_reference) const -> bool override; diff --git a/include/meevax/kernel/floating_point.hpp b/include/meevax/kernel/floating_point.hpp index c9b8a6364..da2dda972 100644 --- a/include/meevax/kernel/floating_point.hpp +++ b/include/meevax/kernel/floating_point.hpp @@ -31,23 +31,21 @@ inline namespace kernel struct floating_point : public number , public std::numeric_limits { - using value_type = T; - - value_type value; + T value; explicit constexpr floating_point(T value = {}) : value { value } {} explicit floating_point(std::string const& token) try - : value { lexical_cast(token) } + : value { lexical_cast(token) } {} catch (...) { throw read_error(make("not a decimal"), make(token)); } - auto exact() const -> lvalue override + auto exact() const -> value_type override { /* ---- R7RS 6.2.6 (exact z) --------------------------------------------- * @@ -103,13 +101,13 @@ inline namespace kernel return lexical_cast(value); } - auto inexact() const -> lvalue override + auto inexact() const -> value_type override { return make(floating_point(value)); } #define DEFINE(NAME) \ - auto NAME() const -> lvalue override \ + auto NAME() const -> value_type override \ { \ return make(floating_point(std::NAME(value))); \ } \ @@ -127,7 +125,7 @@ inline namespace kernel #undef DEFINE #define DEFINE(NAME) \ - auto NAME(const_reference x) const -> lvalue override \ + auto NAME(const_reference x) const -> value_type override \ { \ return make(floating_point(std::NAME(value, x.as().inexact().as()))); \ } \ @@ -138,14 +136,14 @@ inline namespace kernel #undef DEFINE - constexpr operator value_type() const noexcept { return value; } - constexpr operator value_type() noexcept { return value; } + constexpr operator T() const noexcept { return value; } + constexpr operator T() noexcept { return value; } - auto operator + (const_reference) const -> lvalue override; - auto operator - (const_reference) const -> lvalue override; - auto operator * (const_reference) const -> lvalue override; - auto operator / (const_reference) const -> lvalue override; - auto operator % (const_reference) const -> lvalue override; + auto operator + (const_reference) const -> value_type override; + auto operator - (const_reference) const -> value_type override; + auto operator * (const_reference) const -> value_type override; + auto operator / (const_reference) const -> value_type override; + auto operator % (const_reference) const -> value_type override; auto operator ==(const_reference) const -> bool override; auto operator !=(const_reference) const -> bool override; diff --git a/include/meevax/kernel/identity.hpp b/include/meevax/kernel/identity.hpp index c970475f6..de71a0570 100644 --- a/include/meevax/kernel/identity.hpp +++ b/include/meevax/kernel/identity.hpp @@ -36,9 +36,9 @@ inline namespace kernel virtual auto load(const_reference) const -> const_reference = 0; - virtual auto make_load_mnemonic() const -> lvalue = 0; + virtual auto make_load_mnemonic() const -> value_type = 0; - virtual auto make_store_mnemonic() const -> lvalue = 0; + virtual auto make_store_mnemonic() const -> value_type = 0; virtual auto symbol() const -> const_reference; }; @@ -57,9 +57,9 @@ inline namespace kernel auto load(const_reference = unit) const -> const_reference override; - auto make_load_mnemonic() const -> lvalue override; + auto make_load_mnemonic() const -> value_type override; - auto make_store_mnemonic() const -> lvalue override; + auto make_store_mnemonic() const -> value_type override; }; struct keyword : public absolute @@ -77,9 +77,9 @@ inline namespace kernel auto load(const_reference) const -> const_reference override; - auto make_load_mnemonic() const -> lvalue override; + auto make_load_mnemonic() const -> value_type override; - auto make_store_mnemonic() const -> lvalue override; + auto make_store_mnemonic() const -> value_type override; }; auto operator ==(relative const&, relative const&) -> bool; @@ -90,9 +90,9 @@ inline namespace kernel auto load(const_reference e) const -> const_reference override; - auto make_load_mnemonic() const -> lvalue override; + auto make_load_mnemonic() const -> value_type override; - auto make_store_mnemonic() const -> lvalue override; + auto make_store_mnemonic() const -> value_type override; }; } // namespace kernel } // namespace meevax diff --git a/include/meevax/kernel/iterator.hpp b/include/meevax/kernel/iterator.hpp index 10c884cb1..2f845eb46 100644 --- a/include/meevax/kernel/iterator.hpp +++ b/include/meevax/kernel/iterator.hpp @@ -25,24 +25,24 @@ namespace meevax { inline namespace kernel { - struct iterator : public std::reference_wrapper + struct iterator : public std::reference_wrapper { using iterator_category = std::forward_iterator_tag; - using value_type = lvalue; + using value_type = meevax::value_type; using reference = meevax::reference; using const_reference = meevax::const_reference; - using pointer = typename std::add_pointer::type; + using pointer = typename std::add_pointer::type; using difference_type = std::ptrdiff_t; using size_type = std::size_t; iterator(const_reference x) - : std::reference_wrapper { std::cref(x) } + : std::reference_wrapper { std::cref(x) } {} auto operator *() const -> const_reference; diff --git a/include/meevax/kernel/library.hpp b/include/meevax/kernel/library.hpp index b6ed7b76f..0c5026d25 100644 --- a/include/meevax/kernel/library.hpp +++ b/include/meevax/kernel/library.hpp @@ -27,7 +27,7 @@ inline namespace kernel { struct library : public environment { - std::vector export_specs; + std::vector export_specs; template )> explicit library(F&& declare) @@ -45,7 +45,7 @@ inline namespace kernel auto export_(std::string const&) -> void; - auto resolve_export_specs() -> lvalue; + auto resolve_export_specs() -> value_type; #define DEFINE_BASIS_LIBRARY(NAME) \ struct NAME##_library_t \ diff --git a/include/meevax/kernel/list.hpp b/include/meevax/kernel/list.hpp index fc2a6405b..0b490e73b 100644 --- a/include/meevax/kernel/list.hpp +++ b/include/meevax/kernel/list.hpp @@ -36,7 +36,7 @@ inline namespace kernel { return x.get().template as(); } - else if constexpr (std::is_same::value) + else if constexpr (std::is_same::value) { return x.template as(); } @@ -56,8 +56,8 @@ inline namespace kernel return std::get<1>(unwrap(std::forward(x))); }; - template , - std::is_convertible)> + template , + std::is_convertible)> auto operator |(T&& x, U&& y) -> decltype(auto) { return make(std::forward(x), std::forward(y)); @@ -104,7 +104,7 @@ inline namespace kernel auto list_copy = [](auto const& x) { - auto copy = [](auto&& rec, const_reference x) -> lvalue + auto copy = [](auto&& rec, const_reference x) -> value_type { if (x.is()) { @@ -178,25 +178,25 @@ inline namespace kernel return car(list_tail(std::forward(xs)...)); }; - auto take(const_reference, std::size_t) -> lvalue; + auto take(const_reference, std::size_t) -> value_type; auto length = [](auto const& x) constexpr { return std::distance(std::cbegin(x), std::cend(x)); }; - auto append2(const_reference, const_reference) -> lvalue; + auto append2(const_reference, const_reference) -> value_type; - auto reverse(const_reference) -> lvalue; + auto reverse(const_reference) -> value_type; - auto zip(const_reference, const_reference) -> lvalue; + auto zip(const_reference, const_reference) -> value_type; - auto unzip1(const_reference xs) -> lvalue; + auto unzip1(const_reference xs) -> value_type; - auto unzip2(const_reference xs) -> std::tuple; + auto unzip2(const_reference xs) -> std::tuple; template - auto map(Function&& function, const_reference x) -> lvalue + auto map(Function&& function, const_reference x) -> value_type { return x.is() ? unit : cons(function(car(x)), map(function, cdr(x))); } diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index afddfdad7..5bc119eb3 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -118,7 +118,7 @@ inline namespace kernel , identity { syntactic_environment.as().identify(expression, syntactic_environment.as().scope()) } {} - auto identify_with_offset(const_reference use_env_scope) -> lvalue + auto identify_with_offset(const_reference use_env_scope) -> value_type { if (identity.is()) { @@ -188,7 +188,7 @@ inline namespace kernel environment & current_environment, const_reference current_expression, const_reference current_scope = unit, - const_reference current_continuation = list(make(mnemonic::stop))) -> lvalue + const_reference current_continuation = list(make(mnemonic::stop))) -> value_type { if (current_expression.is()) /* ------------------------------------ * @@ -328,7 +328,7 @@ inline namespace kernel } template - inline auto execute() -> lvalue + inline auto execute() -> value_type { decode: if constexpr (trace) @@ -693,7 +693,7 @@ inline namespace kernel } } - static auto identify(const_reference variable, const_reference scope) -> lvalue + static auto identify(const_reference variable, const_reference scope) -> value_type { for (auto outer = std::begin(scope); outer != std::end(scope); ++outer) { diff --git a/include/meevax/kernel/number.hpp b/include/meevax/kernel/number.hpp index 93ecec62d..eea218cd5 100644 --- a/include/meevax/kernel/number.hpp +++ b/include/meevax/kernel/number.hpp @@ -187,17 +187,17 @@ inline namespace kernel template auto operator > (ratio const& a, floating_point const& b) -> bool { return a.inexact().as() > b; } template auto operator >=(ratio const& a, floating_point const& b) -> bool { return a.inexact().as() >= b; } - template auto floating_point::operator * (const_reference x) const -> lvalue { return apply(mul, *this, x); } - template auto floating_point::operator + (const_reference x) const -> lvalue { return apply(add, *this, x); } - template auto floating_point::operator - (const_reference x) const -> lvalue { return apply(sub, *this, x); } - template auto floating_point::operator / (const_reference x) const -> lvalue { return apply(div, *this, x); } - template auto floating_point::operator % (const_reference x) const -> lvalue { return apply(mod, *this, x); } - template auto floating_point::operator !=(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a != b; }, *this, x); } - template auto floating_point::operator < (const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a < b; }, *this, x); } - template auto floating_point::operator <=(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a <= b; }, *this, x); } - template auto floating_point::operator ==(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a == b; }, *this, x); } - template auto floating_point::operator > (const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a > b; }, *this, x); } - template auto floating_point::operator >=(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a >= b; }, *this, x); } + template auto floating_point::operator * (const_reference x) const -> value_type { return apply(mul, *this, x); } + template auto floating_point::operator + (const_reference x) const -> value_type { return apply(add, *this, x); } + template auto floating_point::operator - (const_reference x) const -> value_type { return apply(sub, *this, x); } + template auto floating_point::operator / (const_reference x) const -> value_type { return apply(div, *this, x); } + template auto floating_point::operator % (const_reference x) const -> value_type { return apply(mod, *this, x); } + template auto floating_point::operator !=(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a != b; }, *this, x); } + template auto floating_point::operator < (const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a < b; }, *this, x); } + template auto floating_point::operator <=(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a <= b; }, *this, x); } + template auto floating_point::operator ==(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a == b; }, *this, x); } + template auto floating_point::operator > (const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a > b; }, *this, x); } + template auto floating_point::operator >=(const_reference x) const -> bool { return apply([](auto&& a, auto&& b) { return a >= b; }, *this, x); } template auto operator * (floating_point const& a, exact_integer const& b) { return a * b.inexact().as(); } template auto operator + (floating_point const& a, exact_integer const& b) { return a + b.inexact().as(); } diff --git a/include/meevax/kernel/object.hpp b/include/meevax/kernel/object.hpp index 958698de4..3d4ca3d72 100644 --- a/include/meevax/kernel/object.hpp +++ b/include/meevax/kernel/object.hpp @@ -52,13 +52,13 @@ inline namespace kernel template auto make(Ts&&... xs) { - return lvalue::allocate(std::forward(xs)...); // NOTE: This leaks memory if exception thrown from T's constructor. + return value_type::allocate(std::forward(xs)...); // NOTE: This leaks memory if exception thrown from T's constructor. } template auto make(T&& x) { - return lvalue::allocate::type>(std::forward(x)); + return value_type::allocate::type>(std::forward(x)); } } // namespace kernel } // namespace meevax diff --git a/include/meevax/kernel/optimizer.hpp b/include/meevax/kernel/optimizer.hpp index f10466acb..e8211f12d 100644 --- a/include/meevax/kernel/optimizer.hpp +++ b/include/meevax/kernel/optimizer.hpp @@ -27,7 +27,7 @@ inline namespace kernel { static inline auto fmerge_constants = true; - static auto merge_constants(const_reference c) -> lvalue + static auto merge_constants(const_reference c) -> value_type { if (not c.is()) { diff --git a/include/meevax/kernel/overview.hpp b/include/meevax/kernel/overview.hpp index 3d3ad6c3c..c96fb0f37 100644 --- a/include/meevax/kernel/overview.hpp +++ b/include/meevax/kernel/overview.hpp @@ -44,17 +44,19 @@ inline namespace kernel template