SOM is a minimal Smalltalk dialect used to teach VM construction at the Hasso Plattner Institute. It was originally built at the University of Århus (Denmark) where it was also used for teaching.
Implementations exist for instance for Java (SOM), C (CSOM), C++ (SOM++), Python & RPython (PySOM), the Truffle framework (TruffleSOM), and Squeak/Pharo Smalltalk (AweSOM).
A simple SOM Hello World looks like:
Hello = (
run = (
'Hello World!' println.
)
)This repository contains the C++ implementation of SOM. The implementation of the SOM standard library and a number of examples are included as a git submodule. Please see the main project page for links to other VM implementations.
The SOM standard library and examples are located in the core-lib git submodule.
Before building, initialize and fetch the submodules:
git submodule update --init --recursiveSOM++ uses CMake and an optimized release build can be built like this:
mkdir cmake-build && cd cmake-build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -jAfterwards, the tests can be executed with:
./SOM++ -cp ../Smalltalk ../TestSuite/TestHarness.somA simple Hello World program is executed with:
./SOM++ -cp ../Smalltalk ../Examples/Hello.somInformation on previous authors are included in the AUTHORS file. This code is
distributed under the MIT License. Please see the LICENSE file for details.
Additional documentation, detailing for instance the object model and how to
implement primitives, is available in the doc folder.
SOM++ supports different garbage collectors, including a basic mark/sweep, and a generational GC. Furthermore, it implements different variants for integer handling.
Tagged integers:
default: off
option name: TAGGING
example: cmake .. -DUSE_TAGGING=true
Integer caching:
default: off
option name: INT_CACHE
example: cmake .. -DCACHE_INTEGER=true
A build with assertions for development and debugging can be built with:
mkdir cmake-debug && cd cmake-debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -jThis build also creates a unittests binary, which uses cppunit for
implementation-level unit tests, to run the basic interpreter tests
in TestSuite/BasicInterpreterTests, as well as the SOM test suite.
The unit tests need the SOM classpath set as follows:
./unittests -cp ../Smalltalk:../TestSuite/BasicInterpreterTests ../Examples/Hello.somThese tests can also be run with CMake, either all together with make test
or using the ctest tool, which allows to run individual tests:
make test
ctest
ctest -R unittests
To have a somewhat consistent code style and catch some basic bugs, the CI
setup runs clang-format and clang-tidy as part of the CMake setup.
make check-tidy
make check-formatTo run the format and fix tidy issues, we have:
make tidy
make formatThanks to GitHub Actions, this repository is automatically tested.
The current build status is: