Skip to content

Commit 828dc59

Browse files
authored
Merge pull request #444 from yamacir-kit/miscellaneous
Miscellaneous
2 parents 8ffa0c1 + 8b44ecd commit 828dc59

File tree

169 files changed

+2275
-4429
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+2275
-4429
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
build
2+
src/kernel/basis.cpp
23
src/kernel/version.cpp

CMakeLists.txt

+34-53
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,29 @@ project(meevax DESCRIPTION "A programmable programming language"
1010
LANGUAGES CXX
1111
VERSION ${CURRENT_VERSION})
1212

13-
include(GNUInstallDirs)
14-
include(TestBigEndian)
15-
1613
set(CMAKE_CXX_EXTENSIONS OFF)
1714
set(CMAKE_CXX_STANDARD 17)
1815
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1916
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2017
set(CMAKE_VERBOSE_MAKEFILE OFF)
2118

22-
string(JOIN " " UNSTABLE_OPTIMIZATION_OPTIONS
23-
# "-flto " # This optimization causes a SEGV when compiling with Clang 10.
24-
# "-fmerge-all-constants " # This optimization is very effective in reducing binary size, but non-standard to the C++ standard.
25-
# "-march=native " # This optimization causes "Illegal instruction" error (is Valgrind's bug) on CI.
26-
# "-mtune=native "
19+
string(JOIN " " AGGRESSIVE_OPTIMIZATION_OPTIONS
20+
# "-fdata-sections"
21+
# "-ffunction-sections"
22+
# "-flto" # This optimization causes a SEGV when compiling with Clang 10.
23+
# "-fmerge-all-constants" # This optimization is very effective in reducing binary size, but non-standard to the C++ standard.
24+
# "-march=native" # This optimization causes "Illegal instruction" error (is Valgrind's bug) on CI.
25+
# "-mtune=native"
2726
)
2827

2928
# NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782
3029
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe")
3130
set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4")
3231
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
3332
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gdwarf-4 -DNDEBUG")
34-
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${UNSTABLE_OPTIMIZATION_OPTIONS}")
33+
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${AGGRESSIVE_OPTIMIZATION_OPTIONS}")
34+
35+
include(GNUInstallDirs)
3536

3637
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
3738
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
@@ -46,37 +47,32 @@ else()
4647
set(${PROJECT_NAME}_VERSION_EXACT "")
4748
endif()
4849

50+
include(TestBigEndian)
51+
4952
TEST_BIG_ENDIAN(IS_BIG_ENDIAN) # Use CMAKE_CXX_BYTE_ORDER if CMake >= 3.20
53+
5054
if(${IS_BIG_ENDIAN})
5155
set(${PROJECT_NAME}_BYTE_ORDER "big-endian")
5256
else()
5357
set(${PROJECT_NAME}_BYTE_ORDER "little-endian")
5458
endif()
5559

60+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/help.txt ${CMAKE_CURRENT_BINARY_DIR}/help.txt)
61+
62+
file(READ ${CMAKE_CURRENT_BINARY_DIR}/help.txt ${PROJECT_NAME}_HELP_TEXT)
63+
5664
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/version.cpp)
5765
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
5866

59-
# ---- Convert Basis-Library Sources to Binary ---------------------------------
60-
6167
file(GLOB ${PROJECT_NAME}_BASIS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/basis/*.ss)
6268

63-
set(${PROJECT_NAME}_BASIS "")
64-
6569
foreach(EACH IN LISTS ${PROJECT_NAME}_BASIS_SOURCES)
6670
get_filename_component(FILENAME ${EACH} NAME)
67-
get_filename_component(FILEPATH ${EACH} PATH)
68-
add_custom_command(
69-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}.o
70-
WORKING_DIRECTORY ${FILEPATH}
71-
COMMAND ${CMAKE_OBJCOPY}
72-
ARGS -I binary
73-
-O elf64-x86-64
74-
-B i386
75-
${FILENAME}
76-
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}.o)
77-
list(APPEND ${PROJECT_NAME}_BASIS ${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}.o)
71+
file(READ ${EACH} ${PROJECT_NAME}_BASIS_${FILENAME})
7872
endforeach()
7973

74+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/basis.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/basis.cpp)
75+
8076
# ---- Target kernel -----------------------------------------------------------
8177

8278
add_library(kernel SHARED "")
@@ -85,8 +81,7 @@ add_library(${PROJECT_NAME}::kernel ALIAS kernel)
8581

8682
file(GLOB_RECURSE ${PROJECT_NAME}_KERNEL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*/*.cpp)
8783

88-
target_sources(kernel PRIVATE ${${PROJECT_NAME}_BASIS}
89-
PRIVATE ${${PROJECT_NAME}_KERNEL_SOURCES})
84+
target_sources(kernel PRIVATE ${${PROJECT_NAME}_KERNEL_SOURCES})
9085

9186
target_include_directories(kernel PUBLIC
9287
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -161,38 +156,24 @@ include(CPack)
161156

162157
enable_testing()
163158

164-
macro(check TEST_NAME)
165-
add_test(NAME ${TEST_NAME}
159+
file(GLOB ${PROJECT_NAME}_TEST_SS ${CMAKE_CURRENT_SOURCE_DIR}/test/*.ss)
160+
161+
foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_SS)
162+
get_filename_component(FILENAME ${EACH} NAME_WE)
163+
add_test(NAME ${FILENAME}
166164
COMMAND valgrind --error-exitcode=1 # = EXIT_FAILURE
167165
--leak-check=full
168166
--quiet
169167
--show-leak-kinds=all
170168
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax
171-
${CMAKE_CURRENT_SOURCE_DIR}/test/${TEST_NAME}.ss)
172-
endmacro()
173-
174-
check(abandoned)
175-
check(chibi-basic)
176-
check(identifier)
177-
check(internal-definition)
178-
check(library-declaration)
179-
check(macro-transformers)
180-
check(numerical-operations)
181-
check(parameterize)
182-
check(r4rs)
183-
check(r4rs-appendix)
184-
check(r5rs)
185-
check(r7rs)
186-
check(sicp-1)
187-
check(srfi-8)
188-
check(tail-call)
189-
check(values)
190-
check(with-exception-handler)
191-
192-
file(GLOB ${PROJECT_NAME}_TEST_CXX ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)
193-
foreach(FILEPATH IN LISTS ${PROJECT_NAME}_TEST_CXX)
194-
get_filename_component(FILENAME ${FILEPATH} NAME_WE)
195-
add_executable(assert-${FILENAME} ${FILEPATH})
169+
${EACH})
170+
endforeach()
171+
172+
file(GLOB ${PROJECT_NAME}_TEST_CPP ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)
173+
174+
foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_CPP)
175+
get_filename_component(FILENAME ${EACH} NAME_WE)
176+
add_executable(assert-${FILENAME} ${EACH})
196177
target_link_libraries(assert-${FILENAME} PRIVATE kernel)
197178
add_test(NAME assert-${FILENAME}
198179
COMMAND valgrind --error-exitcode=1 # = EXIT_FAILURE

README.md

+14-20
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Subset of R7RS-small.
4646
| [ 1](https://srfi.schemers.org/srfi-1/srfi-1.html) | List Library | [`(srfi 1)`](./basis/srfi-1.ss) | |
4747
| [ 6](https://srfi.schemers.org/srfi-6/srfi-6.html) | Basic String Ports | [`(srfi 6)`](./basis/srfi-6.ss) | R7RS 6.13 |
4848
| [ 8](https://srfi.schemers.org/srfi-8/srfi-8.html) | receive: Binding to multiple values | [`(srfi 8)`](./basis/srfi-8.ss) | |
49+
| [ 9](https://srfi.schemers.org/srfi-9/srfi-9.html) | Defining Record Types | [`(srfi 9)`](./basis/srfi-9.ss) | R7RS 5.5 |
4950
| [ 10](https://srfi.schemers.org/srfi-10/srfi-10.html) | #, external form | | |
5051
| [ 11](https://srfi.schemers.org/srfi-11/srfi-11.html) | Syntax for receiving multiple values | [`(srfi 11)`](./basis/srfi-11.ss) | R7RS 4.2.2 |
5152
| [ 23](https://srfi.schemers.org/srfi-23/srfi-23.html) | Error reporting mechanism | [`(srfi 23)`](./basis/srfi-23.ss) | R7RS 6.11 |
@@ -91,23 +92,14 @@ $ make install.deb
9192
``` bash
9293
$ sudo apt remove meevax
9394
```
94-
<!--
95-
or
96-
``` bash
97-
sudo rm -rf /usr/local/bin/meevax
98-
sudo rm -rf /usr/local/include/meevax
99-
sudo rm -rf /usr/local/lib/libmeevax*
100-
sudo rm -rf /usr/local/share/meevax
101-
```
102-
-->
10395

10496
### CMake targets
10597

10698
| Target Name | Description
107-
|:-------------------|:--
108-
| `all` (default) | Build shared-library `libmeevax.0.4.567.so` and executable `meevax`.
99+
|--------------------|---
100+
| `all` (default) | Build shared-library `libmeevax.0.4.597.so` and executable `meevax`.
109101
| `test` | Test executable `meevax`.
110-
| `package` | Generate debian package `meevax_0.4.567_amd64.deb`.
102+
| `package` | Generate debian package `meevax_0.4.597_amd64.deb`.
111103
| `install` | Copy files into `/usr/local` __(1)__.
112104
| `install.deb` | `all` + `package` + `sudo apt install <meevax>.deb`
113105
| `safe-install.deb` | `all` + `test` + `package` + `sudo apt install <meevax>.deb`
@@ -122,17 +114,19 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's
122114
## Usage
123115

124116
```
125-
Meevax Lisp 0.4.567
117+
Meevax Lisp 0.4.597
126118
127-
Usage: meevax [OPTION...] [FILE...]
119+
Usage:
120+
meevax [option...] [file...]
128121
129122
Options:
130-
-e, --evaluate=STRING Read and evaluate given STRING at configuration step.
131-
-h, --help Display this help text and exit.
132-
-i, --interactive Take over control of root environment.
133-
-l, --load=FILENAME Same as -e '(load FILENAME)'
134-
-v, --version Display version information and exit.
135-
-w, --write=OBJECT Same as -e '(write OBJECT)'
123+
-e, --evaluate=<string> read and evaluate <string> on interaction-environment
124+
-h, --help display this help and exit
125+
-i, --interactive enter an interactive session
126+
-l, --load=<file> load <file> into interaction-environment
127+
-v, --version display version information and exit
128+
-w, --write=<string> same as `(write (read <string>))`
129+
136130
```
137131

138132
| Example | Effects |

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.567
1+
0.4.597

basis/r7rs.ss

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
(only (meevax write) put-char put-string)
1010
(scheme r5rs)
1111
(srfi 6)
12+
(srfi 9)
1213
(srfi 11)
1314
(srfi 23)
1415
(srfi 34)
@@ -26,8 +27,7 @@
2627
letrec-syntax syntax-rules _ ... syntax-error
2728

2829
; 5.3. Variable definitions
29-
define define-values define-syntax
30-
; define-record-type
30+
define define-values define-syntax define-record-type
3131

3232
; 6.1. Equivalence predicates
3333
eqv? eq? equal?

basis/srfi-34.ss

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@
6565
(define-syntax guard
6666
(syntax-rules ()
6767
((guard (var clause ...) e1 e2 ...)
68-
((call/cc
68+
((call-with-current-continuation
6969
(lambda (guard-k)
7070
(with-exception-handler
7171
(lambda (condition)
72-
((call/cc
72+
((call-with-current-continuation
7373
(lambda (handler-k)
7474
(guard-k
7575
(lambda ()

0 commit comments

Comments
 (0)