diff --git a/.build/environment.py b/.build/environment.py index db8151da..bc6c5777 100755 --- a/.build/environment.py +++ b/.build/environment.py @@ -30,6 +30,7 @@ def load_config(): cp.set("Windows", "VisualStudio9", "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0") cp.set("Windows", "Graphviz", pathjoin(dirname(__file__), "Graphviz")) cp.set("Windows", "pypyextlibs", pathjoin(dirname(__file__), "pypyextlibs")) + cp.add_section("macOS") cp.write(f) print "I've just added a config file at %s. Please review the values and run `install_dependencies` (if needed)." % config else: diff --git a/.travis/build-osx.sh b/.travis/build-macos.sh similarity index 100% rename from .travis/build-osx.sh rename to .travis/build-macos.sh diff --git a/.travis/build.sh b/.travis/build.sh index 51c2e904..e8de7063 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -64,7 +64,7 @@ case "$TRAVIS_OS_NAME" in fi # set up PKG_CONFIG_PATH in order to use openssl installed via Homebrew export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl/lib/pkgconfig - SCRIPT_NAME="build-osx.sh" + SCRIPT_NAME="build-macos.sh" ;; esac diff --git a/.travis/install_requirements.sh b/.travis/install_requirements.sh index 1881eebd..5490575c 100755 --- a/.travis/install_requirements.sh +++ b/.travis/install_requirements.sh @@ -4,7 +4,7 @@ set -ex readonly BASE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" presetup_osx() { - echo "OS X Pre-setup" + echo "macOS Pre-setup" } setup_osx() { @@ -29,7 +29,7 @@ setup_osx() { # todo: Squeak for jittests - # Don't install coveralls on OS X, because it's too slow (see #116) + # Don't install coveralls on macOS, because it's too slow (see #116) # curl -L -O https://bootstrap.pypa.io/get-pip.py # sudo python get-pip.py # sudo pip install coveralls pytest-cov diff --git a/README.md b/README.md index 690eaf53..b0f62399 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -## RSqueak/VM [![Linux Build Status](https://travis-ci.org/HPI-SWA-Lab/RSqueak.svg?branch=master)](https://travis-ci.org/HPI-SWA-Lab/RSqueak) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/e37a79tt5irr7sx1/branch/master?svg=true)](https://ci.appveyor.com/project/timfel/rsqueak) [![Coverage Status](https://coveralls.io/repos/github/HPI-SWA-Lab/RSqueak/badge.svg?branch=master)](https://coveralls.io/github/HPI-SWA-Lab/RSqueak?branch=master) [![Benchmarks](https://img.shields.io/badge/benchmarks-open-yellowgreen.svg)](http://speed.squeak.org/) [![Documentation Status](https://readthedocs.org/projects/rsqueak/badge/?version=latest)](http://rsqueak.readthedocs.io/en/latest/?badge=latest) +## RSqueak/VM [![Linux Build Status][travis_badge]][travis] [![Windows Build Status][appveyor_badge]][appveyor] [![Coverage Status][coveralls_badge]][coveralls] [![Benchmarks][benchmarks_badge]][benchmarks] [![Documentation Status][docs_badge]][docs] A Squeak VM written in RPython. ### Download -All-in-One bundle for Linux, Windows and OS X: +All-in-One bundle for Linux, Windows and macOS: -[![Download zip](https://img.shields.io/badge/Download-zip-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.zip) [![Download tar.gz](https://img.shields.io/badge/Download-tar.gz-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.tar.gz) +[![Download zip][dl_zip_badge]][dl_zip] [![Download tar.gz][dl_tgz_badge]][dl_tgz] Pre-built 32-bit binaries: -[![Download Linux](https://img.shields.io/badge/Download-Linux-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-latest) [![Download Mac OS X](https://img.shields.io/badge/Download-Mac_OS_X-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-latest) [![Download Windows](https://img.shields.io/badge/Download-Windows-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-win32-latest.exe) +[![Download Linux][dl_linux_badge]][dl_linux] [![Download macOS][dl_macos_badge]][dl_macos] [![Download Windows][dl_win_badge]][dl_win] Pre-built 64-bit binaries (note that the goal for RSqueak/VM to support all image formats that are <= the native word size - so the 64-bit VMs should open @@ -18,11 +18,11 @@ both 32-bit and 64-bit images; it should simply be faster. Due to limitations of the underlying RPython toolchain, Windows binaries cannot currently be built in 64-bit mode): -[![Download Linux x86_64](https://img.shields.io/badge/Download-Linux_x86__64-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-x86_64-latest) [![Download Mac OS X x86_64](https://img.shields.io/badge/Download-Mac%20OS%20X%20x86__64-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-x86_64-latest) +[![Download Linux x86_64][dl_linux64_badge]][dl_linux64] [![Download macOS x86_64][dl_macos64_badge]][dl_macos64] We also have experimental builds for Raspberry Pi: -[![Download Raspberry Pi 1](https://img.shields.io/badge/Download-Raspberry_Pi_1-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv6raspbian-latest) [![Download Raspberry Pi 2](https://img.shields.io/badge/Download-Raspberry_Pi_2-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv7-araspbian-latest) [![Download Raspberry Pi 3](https://img.shields.io/badge/Download-Raspberry_Pi_3-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv8-araspbian-latest) +[![Download Raspberry Pi 1][dl_raspi1_badge]][dl_raspi1] [![Download Raspberry Pi 2][dl_raspi2_badge]][dl_raspi2] [![Download Raspberry Pi 3][dl_raspi3_badge]][dl_raspi3] ### Finding a working image @@ -42,125 +42,39 @@ Note that RSqueak/VM will *always* save images in 32-bit Cog-Spur format, regardless of what it was when you opened it. So make sure to save as new version if you want to keep the original around. -### Building from Source - -###### Common to all systems - -We have scripts for installing dependencies, building, running the unit tests, -and running JIT tests in the `.build` subdirectory. You need the `PyPy` source -tree, and the `rsdl` source tree. If you already have all these, run -`.build/build.py --32bit` to build 32-bit VM. Run `.build/build.py` to compile a -64-bit VM. The script passes all other arguments on to the `rpython` translator, -so you can pass other options. - -It will generate a config file `.build/buildconfig.ini` where you can set your -paths. You can also run `.build/download_dependencies.py` to download the -dependencies automatically. You will also need a Python and a C compiler for -32-bit compilation, if you plan to do 32-bit development. - -###### Windows - -On Windows, you will have to use the C compiler that comes with Visual Studio -2008, because newer ones crash the JIT. It suffices to just install the -[Microsoft C compiler V90 plus Windows SDK 7](https://github.com/HPI-SWA-Lab/RSqueak/releases/download/Dependencies/vc_stdx86.zip). -Also, install the [Python 2.7 Visual Studio compiler package](aka.ms/vcpython27). -The -packages provided in the link install it to the default paths. If you already -have the compiler and SDK, you can also just update the paths in -`.build/buildconfig.ini`. - -###### Linux - -RSqueak/VM can currently be compiled in both 32-bit and 64-bit -configurations. For 32-bit, you need to use 32-bit python and SDL2 using 32-bit -libraries for everything. The easiest way to ensure that is to use a chroot, but -you can also install the `:i386` versions of the SDL2 dependencies for your -distro. - -###### Mac OS X - -To compile RSqueak/VM for 32-bit, run - -```bash -export VERSIONER_PYTHON_PREFER_32_BIT=yes -``` - -before you run any of the python scripts in the `.build` directory. You also -need to download SDL2 as a framework (homebrew version is not tested). Check -the `.travis/build-osx.sh` if you get stuck anywhere. - -### Developing - -The `.build` directory includes several scripts that make development -easier. Once you've setup your system for building, you can use these -to work on the RSqueak/VM. - -###### run.py - -This script executes RSqueak/VM in *hosted* mode, that is, it runs on -top of a Python interpreter. This is very slow (we recommend using PyPy), -but it can be useful to debug specific aspects of the VM quickly. Ideally, -you set up an image so that it executes the code that you are interested in -early during startup (`DisplayScreen class>>startUp` is a good candidate) -and then you add your breakpoints to the source. You can also pass commandline -arguments to the script or tweak the default arguments in the script itself. - -__Running a "Smalltalk REPL"__ - -When you want to work on primitives or plugins, it is useful to prepare an image -a little (for example, make it so test runs print to the console), and then run -the following: - -```bash -pypy .build/run.py --shell -``` - -This will load the image and dump you in a simple REPL for Smalltalk, but with -some commands to help you execute Python code and, in particular, to reload the -Python code you write in any plugin or primitive file. Thus, you can run some -Smalltalk code, check for errors, change the primitive code, reload it, and try -again. This avoids having to reload the image in interpreted mode all the time -(which can be slow). - -There is an integrated help that you can get by typing !help, and there is -limited autocomplete, too. - -Note that the REPL only loads the image, but does not process startup. For many -things, you might want to run `FileStream startUp: true` or `Delay startUp` to -get basic I/O working or delays working. - -###### unittests.py - -The second script that is useful for working on issues regarding the -interpreter is `unittests.py`. By default it runs all tests under the -`rsqueakvm/test` directory (but not those in `rsqueakvm/test/jittest/`). This -is a standalone pytest script, so you can pass arguments or select single -test files as you would for pytest. - -###### jittests.py - -This script requires that you have already built an `rsqueak` binary and -that you have the C Squeak VM installed. It executes the tests in -`rsqueakvm/test/jittest/` and checks for the JIT output. We use these tests to -ensure that development on the VM does not break JIT optimizations. - -###### jit.py - -This script is useful to figure out what the JIT is doing. Like `run.py`, -it executes the RSqueak/VM in hosted mode, but this time it also simulates -the JIT. This is even slower, but allows us to test small code snippets -without having to retranslate the entire VM. The code snippets are configured -directly in the file. When you run it, it does part of the translation process -(but only enough to execute your specific code) and then runs the code. When -the JIT kicks in, the compiled loop is shown in a PyGame window. You can then -inspect it at your leisure and when you quit the window, the code continues -executing. In order for this to work, you need to have `pygame` and `graphviz` -installed and in your PATH. - -###### shell.py - -This script sets all the environment variables as if for translating the VM, -and the drops you into an interactive Python prompt. You can type `terminal()` -to drop into a system shell (`%COMSPEC%` on Windows `$SHELL` or `/bin/sh` on -Unices) which then has all the environment variables set up that you need to -do manual partial translations or similar things. +### [Building from Source][build_from_source] +### [Development][development] + + +[appveyor]: https://ci.appveyor.com/project/timfel/rsqueak +[appveyor_badge]: https://ci.appveyor.com/api/projects/status/e37a79tt5irr7sx1/branch/master?svg=true +[benchmarks]: http://speed.squeak.org/ +[benchmarks_badge]: https://img.shields.io/badge/benchmarks-open-yellowgreen.svg +[build_from_source]: http://rsqueak.readthedocs.io/en/latest/building_from_source.html +[coveralls]: https://coveralls.io/github/HPI-SWA-Lab/RSqueak?branch=master +[coveralls_badge]: https://coveralls.io/repos/github/HPI-SWA-Lab/RSqueak/badge.svg?branch=master +[development]: http://rsqueak.readthedocs.io/en/latest/development.html +[dl_linux64]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-x86_64-latest +[dl_linux64_badge]: https://img.shields.io/badge/Download-Linux_x86__64-blue.svg +[dl_linux]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-latest +[dl_linux_badge]: https://img.shields.io/badge/Download-Linux-blue.svg +[dl_macos64]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-x86_64-latest +[dl_macos64_badge]: https://img.shields.io/badge/Download-Mac%20OS%20X%20x86__64-blue.svg +[dl_macos]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-latest +[dl_macos_badge]: https://img.shields.io/badge/Download-Mac_OS_X-blue.svg +[dl_raspi1]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv6raspbian-latest +[dl_raspi1_badge]: https://img.shields.io/badge/Download-Raspberry_Pi_1-blue.svg +[dl_raspi2]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv7-araspbian-latest +[dl_raspi2_badge]: https://img.shields.io/badge/Download-Raspberry_Pi_2-blue.svg +[dl_raspi3]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv8-araspbian-latest +[dl_raspi3_badge]: https://img.shields.io/badge/Download-Raspberry_Pi_3-blue.svg +[dl_tgz]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.tar.gz +[dl_tgz_badge]: https://img.shields.io/badge/Download-tar.gz-blue.svg +[dl_win]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-win32-latest.exe +[dl_win_badge]: https://img.shields.io/badge/Download-Windows-blue.svg +[dl_zip]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.zip +[dl_zip_badge]: https://img.shields.io/badge/Download-zip-blue.svg +[docs]: http://rsqueak.readthedocs.io/en/latest/?badge=latest +[docs_badge]: https://readthedocs.org/projects/rsqueak/badge/?version=latest +[travis]: https://travis-ci.org/HPI-SWA-Lab/RSqueak +[travis_badge]: https://travis-ci.org/HPI-SWA-Lab/RSqueak.svg?branch=master diff --git a/docs/building_from_source.rst b/docs/building_from_source.rst new file mode 100644 index 00000000..602bd711 --- /dev/null +++ b/docs/building_from_source.rst @@ -0,0 +1,53 @@ +Building from Source +===================== + +Common to all systems +---------------------- + +We have scripts for installing dependencies, building, running the unit tests, +and running JIT tests in the `.build` subdirectory. You need the `PyPy` source +tree, and the `rsdl` source tree. If you already have all these, run +`.build/build.py --32bit` to build 32-bit VM. Run `.build/build.py` to compile a +64-bit VM. The script passes all other arguments on to the `rpython` translator, +so you can pass other options. + +It will generate a config file `.build/buildconfig.ini` where you can set your +paths. You can also run `.build/download_dependencies.py` to download the +dependencies automatically. You will also need a Python and a C compiler for +32-bit compilation, if you plan to do 32-bit development. + +Windows +-------- + +On Windows, you will have to use the C compiler that comes with Visual Studio +2008, because newer ones crash the JIT. It suffices to just install the +`Microsoft C compiler V90 plus Windows SDK 7`_. +Also, install the `Python 2.7 Visual Studio compiler package`_. +The packages provided in the link install it to the default paths. If you +already have the compiler and SDK, you can also just update the paths in +`.build/buildconfig.ini`. + +.. _Microsoft C compiler V90 plus Windows SDK 7: https://github.com/HPI-SWA-Lab/RSqueak/releases/download/Dependencies/vc_stdx86.zip +.. _Python 2.7 Visual Studio compiler package: https://aka.ms/vcpython27 + +Linux +------ + +RSqueak/VM can currently be compiled in both 32-bit and 64-bit +configurations. For 32-bit, you need to use 32-bit python and SDL2 using 32-bit +libraries for everything. The easiest way to ensure that is to use a chroot, but +you can also install the `:i386` versions of the SDL2 dependencies for your +distro. + +macOS +--------- + +To compile RSqueak/VM for 32-bit, run + +.. code-block:: bash + + export VERSIONER_PYTHON_PREFER_32_BIT=yes + +before you run any of the python scripts in the `.build` directory. You also +need to download SDL2 as a framework (homebrew version is not tested). Check +the `.travis/build-osx.sh` if you get stuck anywhere. \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 131c2052..3f4c9007 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,6 +44,9 @@ # 'sphinx.ext.githubpages' ] +# Do not include full module names in member list +add_module_names = False + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -94,7 +97,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +# html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/docs/development.rst b/docs/development.rst new file mode 100644 index 00000000..bad2e2ef --- /dev/null +++ b/docs/development.rst @@ -0,0 +1,81 @@ +Development +====================================== + +The `.build` directory includes several scripts that make development +easier. Once you've setup your system for building, you can use these +to work on the RSqueak/VM. + +run.py +---------- + +This script executes RSqueak/VM in *hosted* mode, that is, it runs on +top of a Python interpreter. This is very slow (we recommend using PyPy), +but it can be useful to debug specific aspects of the VM quickly. Ideally, +you set up an image so that it executes the code that you are interested in +early during startup (`DisplayScreen class>>startUp` is a good candidate) +and then you add your breakpoints to the source. You can also pass commandline +arguments to the script or tweak the default arguments in the script itself. + +*Running a "Smalltalk REPL"* + +When you want to work on primitives or plugins, it is useful to prepare an image +a little (for example, make it so test runs print to the console), and then run +the following: + +.. code-block:: bash + + pypy .build/run.py --shell + +This will load the image and dump you in a simple REPL for Smalltalk, but with +some commands to help you execute Python code and, in particular, to reload the +Python code you write in any plugin or primitive file. Thus, you can run some +Smalltalk code, check for errors, change the primitive code, reload it, and try +again. This avoids having to reload the image in interpreted mode all the time +(which can be slow). + +There is an integrated help that you can get by typing !help, and there is +limited autocomplete, too. + +Note that the REPL only loads the image, but does not process startup. For many +things, you might want to run `FileStream startUp: true` or `Delay startUp` to +get basic I/O working or delays working. + +unittests.py +------------- + +The second script that is useful for working on issues regarding the +interpreter is `unittests.py`. By default it runs all tests under the +`rsqueakvm/test` directory (but not those in `rsqueakvm/test/jittest/`). This +is a standalone pytest script, so you can pass arguments or select single +test files as you would for pytest. + +jittests.py +------------ + +This script requires that you have already built an `rsqueak` binary and +that you have the C Squeak VM installed. It executes the tests in +`rsqueakvm/test/jittest/` and checks for the JIT output. We use these tests to +ensure that development on the VM does not break JIT optimizations. + +jit.py +------- + +This script is useful to figure out what the JIT is doing. Like `run.py`, +it executes the RSqueak/VM in hosted mode, but this time it also simulates +the JIT. This is even slower, but allows us to test small code snippets +without having to retranslate the entire VM. The code snippets are configured +directly in the file. When you run it, it does part of the translation process +(but only enough to execute your specific code) and then runs the code. When +the JIT kicks in, the compiled loop is shown in a PyGame window. You can then +inspect it at your leisure and when you quit the window, the code continues +executing. In order for this to work, you need to have `pygame` and `graphviz` +installed and in your PATH. + +shell.py +--------- + +This script sets all the environment variables as if for translating the VM, +and the drops you into an interactive Python prompt. You can type `terminal()` +to drop into a system shell (`%COMSPEC%` on Windows `$SHELL` or `/bin/sh` on +Unices) which then has all the environment variables set up that you need to +do manual partial translations or similar things. diff --git a/docs/index.rst b/docs/index.rst index 98d3540c..c7b7e7e0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,6 +10,9 @@ RSqueak/VM's documentation :maxdepth: 2 :caption: Contents: + building_from_source + development + .. toctree:: :maxdepth: 4 diff --git a/docs/rsqueakvm.plugins.immutability.rst b/docs/rsqueakvm.plugins.immutability.rst new file mode 100644 index 00000000..a6e0de00 --- /dev/null +++ b/docs/rsqueakvm.plugins.immutability.rst @@ -0,0 +1,34 @@ +rsqueakvm.plugins.immutability package +====================================== + +Submodules +---------- + +rsqueakvm.plugins.immutability.bytes module +------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability.bytes + :members: + :show-inheritance: + +rsqueakvm.plugins.immutability.pointers module +---------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability.pointers + :members: + :show-inheritance: + +rsqueakvm.plugins.immutability.words module +------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability.words + :members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: rsqueakvm.plugins.immutability + :members: + :show-inheritance: diff --git a/docs/rsqueakvm.plugins.rst b/docs/rsqueakvm.plugins.rst index 3b542b05..92ca1659 100644 --- a/docs/rsqueakvm.plugins.rst +++ b/docs/rsqueakvm.plugins.rst @@ -7,6 +7,7 @@ Subpackages .. toctree:: rsqueakvm.plugins.database + rsqueakvm.plugins.immutability rsqueakvm.plugins.vmdebugging Submodules @@ -28,6 +29,14 @@ rsqueakvm.plugins.file_plugin module :undoc-members: :show-inheritance: +rsqueakvm.plugins.immutability_plugin module +-------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability_plugin + :members: + :undoc-members: + :show-inheritance: + rsqueakvm.plugins.large_integers module --------------------------------------- diff --git a/repository/ImmutableObjects.package/.filetree b/repository/ImmutableObjects.package/.filetree new file mode 100644 index 00000000..8998102c --- /dev/null +++ b/repository/ImmutableObjects.package/.filetree @@ -0,0 +1,4 @@ +{ + "noMethodMetaData" : true, + "separateMethodMetaAndSource" : false, + "useCypressPropertiesFile" : true } diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st b/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st new file mode 100644 index 00000000..07fe9f41 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st @@ -0,0 +1,4 @@ +*ImmutableObjects +allImmutableInstances + + ^ self allInstances select: [:ea | ea isImmutable] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st new file mode 100644 index 00000000..96859b12 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st @@ -0,0 +1,4 @@ +*ImmutableObjects +immutableFrom: anObject + + ^ self primImmutableFrom: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFrom..st b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFrom..st new file mode 100644 index 00000000..4df5f230 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFrom..st @@ -0,0 +1,5 @@ +*ImmutableObjects +primImmutableFrom: anObject + + + self primitiveFailed \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFromArgs.st b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFromArgs.st new file mode 100644 index 00000000..d424253c --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFromArgs.st @@ -0,0 +1,11 @@ +*ImmutableObjects +primImmutableFromArgs + "Primitive. Answer an instance of the receiver (which is a class) with + all fields initialized to the arguments given. + This is a template. + Do not use directly. + Copy into your class with appropriate arguments! + See Object documentation whatIsAPrimitive." + + + self primitiveFailed \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json new file mode 100644 index 00000000..feb0db47 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json @@ -0,0 +1,8 @@ +{ + "class" : { + }, + "instance" : { + "allImmutableInstances" : "topa 11/28/2016 15:23", + "immutableFrom:" : "topa 11/28/2016 15:23", + "primImmutableFrom:" : "topa 11/28/2016 15:23", + "primImmutableFromArgs" : "topa 12/5/2016 09:16" } } diff --git a/repository/ImmutableObjects.package/Behavior.extension/properties.json b/repository/ImmutableObjects.package/Behavior.extension/properties.json new file mode 100644 index 00000000..37061187 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "Behavior" } diff --git a/repository/ImmutableObjects.package/Cons.class/README.md b/repository/ImmutableObjects.package/Cons.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st b/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st new file mode 100644 index 00000000..5f867934 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st @@ -0,0 +1,10 @@ +instance creation +car: anObject cdr: anotherObject + + + " Fallback for non-immutable " + + ^ self basicNew + instVarNamed: 'car' put: anObject; + instVarNamed: 'cdr' put: anotherObject; + initialize \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/class/new.st b/repository/ImmutableObjects.package/Cons.class/class/new.st new file mode 100644 index 00000000..a4307b49 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/class/new.st @@ -0,0 +1,4 @@ +instance creation +new + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/class/withAll..st b/repository/ImmutableObjects.package/Cons.class/class/withAll..st new file mode 100644 index 00000000..c894914f --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/class/withAll..st @@ -0,0 +1,12 @@ +instance creation +withAll: aCollection + +" ^ aCollection + ifEmpty: [nil] + ifNotEmpty: [:collection | + self car: collection first cdr: (self withAll: collection allButFirst)] +" + | list | + list := nil. + aCollection reverseDo: [:each | list := Cons car: each cdr: list]. + ^ list diff --git a/repository/ImmutableObjects.package/Cons.class/instance/^comma.st b/repository/ImmutableObjects.package/Cons.class/instance/^comma.st new file mode 100644 index 00000000..feffe2a6 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/^comma.st @@ -0,0 +1,4 @@ +collection api +, aCons + + ^ self append: aCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/^tilde.st b/repository/ImmutableObjects.package/Cons.class/instance/^tilde.st new file mode 100644 index 00000000..1d71a06c --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/^tilde.st @@ -0,0 +1,4 @@ +convenience +~ anObject + + ^ self append: anObject asCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/append..st b/repository/ImmutableObjects.package/Cons.class/instance/append..st new file mode 100644 index 00000000..589593f6 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/append..st @@ -0,0 +1,7 @@ +functional iteration +append: aCons + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ Cons + car: self car + cdr: (self cdr append: aCons) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/asCons.st b/repository/ImmutableObjects.package/Cons.class/instance/asCons.st new file mode 100644 index 00000000..dfeb4e3a --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/asCons.st @@ -0,0 +1,4 @@ +converting +asCons + + ^ self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/at..st b/repository/ImmutableObjects.package/Cons.class/instance/at..st new file mode 100644 index 00000000..361aad8d --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/at..st @@ -0,0 +1,4 @@ +accessing +at: index + + ^ self at: index ifAbsent: [self errorSubscriptBounds: index] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/at.ifAbsent..st b/repository/ImmutableObjects.package/Cons.class/instance/at.ifAbsent..st new file mode 100644 index 00000000..ba8561df --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/at.ifAbsent..st @@ -0,0 +1,7 @@ +accessing +at: index ifAbsent: exceptionBlock + + | i | + index < 1 ifTrue: [^exceptionBlock value]. + i := 0. + ^ self findf: [:ea | (i := i + 1) = index] ifNone: exceptionBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/car.st b/repository/ImmutableObjects.package/Cons.class/instance/car.st new file mode 100644 index 00000000..298d4982 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/car.st @@ -0,0 +1,4 @@ +accessing +car + + ^ car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/cdr.st b/repository/ImmutableObjects.package/Cons.class/instance/cdr.st new file mode 100644 index 00000000..abd0453a --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/cdr.st @@ -0,0 +1,4 @@ +accessing +cdr + + ^ cdr \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/collect..st b/repository/ImmutableObjects.package/Cons.class/instance/collect..st new file mode 100644 index 00000000..fe526359 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/collect..st @@ -0,0 +1,4 @@ +collection api +collect: aBlock + + ^ self map: aBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/detect.ifNone..st b/repository/ImmutableObjects.package/Cons.class/instance/detect.ifNone..st new file mode 100644 index 00000000..e67a8f20 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/detect.ifNone..st @@ -0,0 +1,4 @@ +collection api +detect: aBlock ifNone: exceptionBlock + + self findf: aBlock ifNone: exceptionBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/do..st b/repository/ImmutableObjects.package/Cons.class/instance/do..st new file mode 100644 index 00000000..44467e73 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/do..st @@ -0,0 +1,4 @@ +collection api +do: aBlock + + self forEach: aBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/filter..st b/repository/ImmutableObjects.package/Cons.class/instance/filter..st new file mode 100644 index 00000000..67f7e8e0 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/filter..st @@ -0,0 +1,7 @@ +functional iteration +filter: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ (aBlock value: self car) + ifTrue: [Cons car: self car cdr: (self cdr filter: aBlock)] + ifFalse: [self cdr filter: aBlock] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/findf..st b/repository/ImmutableObjects.package/Cons.class/instance/findf..st new file mode 100644 index 00000000..1758c25c --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/findf..st @@ -0,0 +1,4 @@ +functional iteration +findf: aBlock + + ^ self findf: aBlock ifNone: [false] diff --git a/repository/ImmutableObjects.package/Cons.class/instance/findf.ifNone..st b/repository/ImmutableObjects.package/Cons.class/instance/findf.ifNone..st new file mode 100644 index 00000000..b37aaf5a --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/findf.ifNone..st @@ -0,0 +1,7 @@ +functional iteration +findf: aBlock ifNone: anotherBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ (aBlock value: self car) + ifTrue: [self car] + ifFalse: [self cdr findf: aBlock ifNone: anotherBlock] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/first.st b/repository/ImmutableObjects.package/Cons.class/instance/first.st new file mode 100644 index 00000000..e8ac84e1 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/first.st @@ -0,0 +1,4 @@ +accessing +first + + ^ self car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/foldl.withInit..st b/repository/ImmutableObjects.package/Cons.class/instance/foldl.withInit..st new file mode 100644 index 00000000..a93542a7 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/foldl.withInit..st @@ -0,0 +1,5 @@ +functional iteration +foldl: aBlock withInit: anObject + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ self cdr foldl: aBlock withInit: (aBlock value: anObject value: self car) diff --git a/repository/ImmutableObjects.package/Cons.class/instance/foldr.withInit..st b/repository/ImmutableObjects.package/Cons.class/instance/foldr.withInit..st new file mode 100644 index 00000000..05da91f8 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/foldr.withInit..st @@ -0,0 +1,7 @@ +functional iteration +foldr: aBlock withInit: anObject + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ aBlock + value: (self cdr foldr: aBlock withInit: anObject) + value: self car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/forEach..st b/repository/ImmutableObjects.package/Cons.class/instance/forEach..st new file mode 100644 index 00000000..c53c3cc1 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/forEach..st @@ -0,0 +1,6 @@ +functional iteration +forEach: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + aBlock value: self car. + self cdr map: aBlock. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/inject.into..st b/repository/ImmutableObjects.package/Cons.class/instance/inject.into..st new file mode 100644 index 00000000..51e3f466 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/inject.into..st @@ -0,0 +1,4 @@ +collection api +inject: anObject into: aBlock + + ^ self foldl: aBlock withInit: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/innerPrintListOn..st b/repository/ImmutableObjects.package/Cons.class/instance/innerPrintListOn..st new file mode 100644 index 00000000..d74f7e04 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/innerPrintListOn..st @@ -0,0 +1,12 @@ +testing +innerPrintListOn: aStream + + self car printOn: aStream. + self cdr + ifNotNil: [:cont | cont isCons + ifFalse: [ + aStream nextPutAll: ' . '. + cont printOn: aStream] + ifTrue: [ + aStream space. + cont innerPrintListOn: aStream]] diff --git a/repository/ImmutableObjects.package/Cons.class/instance/isCons.st b/repository/ImmutableObjects.package/Cons.class/instance/isCons.st new file mode 100644 index 00000000..002442b7 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/isCons.st @@ -0,0 +1,4 @@ +testing +isCons + + ^ true \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/isEmpty.st b/repository/ImmutableObjects.package/Cons.class/instance/isEmpty.st new file mode 100644 index 00000000..cd367045 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/isEmpty.st @@ -0,0 +1,4 @@ +testing +isEmpty + + ^ false \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/last.st b/repository/ImmutableObjects.package/Cons.class/instance/last.st new file mode 100644 index 00000000..e264fe60 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/last.st @@ -0,0 +1,6 @@ +accessing +last + + | prev | + prev := nil. + ^ self findf: [:ea | prev := ea. false "continue to end"] ifNone: [prev] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/map..st b/repository/ImmutableObjects.package/Cons.class/instance/map..st new file mode 100644 index 00000000..811a0de5 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/map..st @@ -0,0 +1,7 @@ +functional iteration +map: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ Cons + car: (aBlock value: self car) + cdr: (self cdr map: aBlock) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/printListOn..st b/repository/ImmutableObjects.package/Cons.class/instance/printListOn..st new file mode 100644 index 00000000..48651a39 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/printListOn..st @@ -0,0 +1,6 @@ +printing +printListOn: aStream + + aStream nextPutAll: '''('. + self innerPrintListOn: aStream. + aStream nextPutAll: ')'. diff --git a/repository/ImmutableObjects.package/Cons.class/instance/printOn..st b/repository/ImmutableObjects.package/Cons.class/instance/printOn..st new file mode 100644 index 00000000..59185ce8 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/printOn..st @@ -0,0 +1,4 @@ +printing +printOn: aStream + + self printListOn: aStream. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reduce..st b/repository/ImmutableObjects.package/Cons.class/instance/reduce..st new file mode 100644 index 00000000..e958b8e9 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reduce..st @@ -0,0 +1,5 @@ +functional iteration +reduce: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ self cdr foldl: aBlock withInit: self car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reject..st b/repository/ImmutableObjects.package/Cons.class/instance/reject..st new file mode 100644 index 00000000..8c305f70 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reject..st @@ -0,0 +1,4 @@ +collection api +reject: aBlock + + ^ self filter: [:each | (aBlock value: each) not] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reverse..st b/repository/ImmutableObjects.package/Cons.class/instance/reverse..st new file mode 100644 index 00000000..7e955300 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reverse..st @@ -0,0 +1,5 @@ +functional iteration +reverse: acc + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ self cdr reverse: (Cons car: self car cdr: acc) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reverse.st b/repository/ImmutableObjects.package/Cons.class/instance/reverse.st new file mode 100644 index 00000000..cce8032e --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reverse.st @@ -0,0 +1,4 @@ +functional iteration +reverse + + ^ self reverse: nil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/select..st b/repository/ImmutableObjects.package/Cons.class/instance/select..st new file mode 100644 index 00000000..d2a449fd --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/select..st @@ -0,0 +1,4 @@ +collection api +select: aBlock + + ^ self filter: aBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/size.st b/repository/ImmutableObjects.package/Cons.class/instance/size.st new file mode 100644 index 00000000..8fb700fb --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/size.st @@ -0,0 +1,4 @@ +accessing +size + + ^ self count: [:ea | true] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/methodProperties.json b/repository/ImmutableObjects.package/Cons.class/methodProperties.json new file mode 100644 index 00000000..a9d9b2a8 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/methodProperties.json @@ -0,0 +1,38 @@ +{ + "class" : { + "car:cdr:" : "topa 12/5/2016 09:18", + "new" : "topa 12/5/2016 08:19", + "withAll:" : "topa 1/4/2017 11:34" }, + "instance" : { + "," : "topa 12/5/2016 16:41", + "append:" : "topa 12/5/2016 16:30", + "asCons" : "topa 12/5/2016 17:42", + "at:" : "topa 12/5/2016 21:52", + "at:ifAbsent:" : "topa 12/6/2016 16:43", + "car" : "topa 12/5/2016 08:18", + "cdr" : "topa 12/5/2016 08:18", + "collect:" : "topa 12/5/2016 16:38", + "detect:ifNone:" : "topa 12/6/2016 16:34", + "do:" : "topa 12/5/2016 17:34", + "filter:" : "topa 12/5/2016 16:32", + "findf:" : "topa 12/5/2016 17:31", + "findf:ifNone:" : "topa 12/5/2016 17:31", + "first" : "topa 12/5/2016 21:52", + "foldl:withInit:" : "topa 12/5/2016 17:15", + "foldr:withInit:" : "topa 12/5/2016 17:19", + "forEach:" : "topa 12/5/2016 17:34", + "inject:into:" : "topa 12/5/2016 16:54", + "innerPrintListOn:" : "topa 12/5/2016 09:25", + "isCons" : "topa 12/5/2016 09:25", + "isEmpty" : "topa 12/5/2016 22:09", + "last" : "topa 12/5/2016 22:11", + "map:" : "topa 12/5/2016 16:27", + "printListOn:" : "topa 12/5/2016 09:22", + "printOn:" : "topa 12/5/2016 09:20", + "reduce:" : "topa 12/5/2016 17:26", + "reject:" : "topa 12/5/2016 17:28", + "reverse" : "topa 12/5/2016 16:33", + "reverse:" : "topa 12/5/2016 16:36", + "select:" : "topa 12/5/2016 16:41", + "size" : "topa 12/5/2016 21:46", + "~" : "topa 12/5/2016 17:45" } } diff --git a/repository/ImmutableObjects.package/Cons.class/properties.json b/repository/ImmutableObjects.package/Cons.class/properties.json new file mode 100644 index 00000000..5b687d23 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/properties.json @@ -0,0 +1,15 @@ +{ + "category" : "ImmutableObjects-Structures", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "car", + "cdr" ], + "name" : "Cons", + "pools" : [ + ], + "super" : "SequenceableCollection", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/README.md b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st new file mode 100644 index 00000000..1bcac077 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st @@ -0,0 +1,4 @@ +defaults +defaultProblemSize + + ^ 1000 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st new file mode 100644 index 00000000..2817a7ec --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st @@ -0,0 +1,4 @@ +benchmark hooks +classUnderBenching + + ^ Cons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st new file mode 100644 index 00000000..f381381e --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st @@ -0,0 +1,6 @@ +set up +consWith: aBlock through: aNumber + + ^ aNumber = 0 + ifTrue: [nil] + ifFalse: [Cons car: (aBlock cull: aNumber) cdr: (self consWith: aBlock through: (aNumber - 1))] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st new file mode 100644 index 00000000..be889449 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st @@ -0,0 +1,6 @@ +benchmark hooks +createCharacterListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self consWith: [($a to: $z) atRandom: rng] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st new file mode 100644 index 00000000..26a9cce7 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st @@ -0,0 +1,13 @@ +benchmark hooks +createMixedListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self + consWith: [ + | roll | + roll := 3 atRandom: rng. + roll = 1 ifTrue: [rng nextInt: aNumber] ifFalse: [ + roll = 2 ifTrue: [($a to: $z) atRandom: rng] ifFalse: [ + roll = 3 ifTrue: [SMarkBox new value: (rng nextInt: aNumber)]]]] + through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st new file mode 100644 index 00000000..ac4947d1 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st @@ -0,0 +1,6 @@ +benchmark hooks +createNumberListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self consWith: [rng nextInt: aNumber] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st new file mode 100644 index 00000000..ba016341 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st @@ -0,0 +1,6 @@ +benchmark hooks +createObjectListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self consWith: [SMarkBox new value: (rng nextInt: aNumber)] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json new file mode 100644 index 00000000..5593410e --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json @@ -0,0 +1,10 @@ +{ + "class" : { + "defaultProblemSize" : "jc 1/5/2017 16:25" }, + "instance" : { + "classUnderBenching" : "topa 12/6/2016 16:16", + "consWith:through:" : "jc 1/5/2017 16:51", + "createCharacterListOfSize:" : "jc 1/5/2017 16:51", + "createMixedListOfSize:" : "jc 1/5/2017 16:51", + "createNumberListOfSize:" : "jc 1/5/2017 16:51", + "createObjectListOfSize:" : "jc 1/5/2017 16:51" } } diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json new file mode 100644 index 00000000..dd8b8051 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-ListNanos", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ConsNanoBenchmark", + "pools" : [ + ], + "super" : "SMarkCollectionNanoBenchmark", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/README.md b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField..st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField..st new file mode 100644 index 00000000..3c1514ba --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField..st @@ -0,0 +1,4 @@ +accessing +aField: anObject + + aField := anObject. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField.st new file mode 100644 index 00000000..f0fbcc22 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField.st @@ -0,0 +1,4 @@ +accessing +aField + + ^ aField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField..st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField..st new file mode 100644 index 00000000..bc823466 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField..st @@ -0,0 +1,4 @@ +accessing +anotherField: anObject + + anotherField := anObject. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField.st new file mode 100644 index 00000000..543c3da7 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField.st @@ -0,0 +1,4 @@ +accessing +anotherField + + ^ anotherField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar.someOtherVar..st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar.someOtherVar..st new file mode 100644 index 00000000..3519c0c9 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar.someOtherVar..st @@ -0,0 +1,5 @@ +accessing +someVar: aValue someOtherVar: anotherValue + + someVar1 := aValue. + someVar2 := anotherValue. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar1.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar1.st new file mode 100644 index 00000000..36d3922a --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar1.st @@ -0,0 +1,4 @@ +accessing +someVar1 + + ^ someVar1 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar2.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar2.st new file mode 100644 index 00000000..614acfaf --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar2.st @@ -0,0 +1,4 @@ +accessing +someVar2 + + ^ someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/methodProperties.json b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/methodProperties.json new file mode 100644 index 00000000..1afd06ee --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/methodProperties.json @@ -0,0 +1,11 @@ +{ + "class" : { + }, + "instance" : { + "aField" : "fn 11/14/2016 17:42", + "aField:" : "topa 11/28/2016 15:31", + "anotherField" : "fn 11/14/2016 17:42", + "anotherField:" : "topa 11/28/2016 15:31", + "someVar1" : "fn 11/14/2016 18:44", + "someVar2" : "fn 11/14/2016 18:44", + "someVar:someOtherVar:" : "topa 11/28/2016 15:31" } } diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json new file mode 100644 index 00000000..17b150d2 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json @@ -0,0 +1,17 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "aField", + "anotherField", + "someVar1", + "someVar2" ], + "name" : "ImmJustFixedPointersClass", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/README.md b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/methodProperties.json b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/methodProperties.json new file mode 100644 index 00000000..0e4a6622 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/methodProperties.json @@ -0,0 +1,5 @@ +{ + "class" : { + }, + "instance" : { + } } diff --git a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json new file mode 100644 index 00000000..a13a8874 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmJustVariablePointersClass", + "pools" : [ + ], + "super" : "Object", + "type" : "variable" } diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/README.md b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField..st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField..st new file mode 100644 index 00000000..1aa8db77 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField..st @@ -0,0 +1,4 @@ +accessing +aField: anObject + + aField := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField.st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField.st new file mode 100644 index 00000000..f0fbcc22 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField.st @@ -0,0 +1,4 @@ +accessing +aField + + ^ aField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField..st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField..st new file mode 100644 index 00000000..ec340273 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField..st @@ -0,0 +1,4 @@ +accessing +anotherField: anObject + + anotherField := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField.st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField.st new file mode 100644 index 00000000..543c3da7 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField.st @@ -0,0 +1,4 @@ +accessing +anotherField + + ^ anotherField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/methodProperties.json b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/methodProperties.json new file mode 100644 index 00000000..f3d0d1df --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/methodProperties.json @@ -0,0 +1,8 @@ +{ + "class" : { + }, + "instance" : { + "aField" : "fn 11/28/2016 20:48", + "aField:" : "fn 11/28/2016 20:48", + "anotherField" : "fn 11/28/2016 20:48", + "anotherField:" : "fn 11/28/2016 20:48" } } diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json new file mode 100644 index 00000000..cd616efa --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json @@ -0,0 +1,15 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "aField", + "anotherField" ], + "name" : "ImmMixedPointersClass", + "pools" : [ + ], + "super" : "Object", + "type" : "variable" } diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/README.md b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/allTestSelectors.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/allTestSelectors.st new file mode 100644 index 00000000..737934e3 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/allTestSelectors.st @@ -0,0 +1,7 @@ +accessing +allTestSelectors + " Ensure those tests are not run on a 'normal' VM " + + ^ self immutabilityAvailable + ifFalse: [#()] + ifTrue: [super allTestSelectors] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/immutabilityAvailable.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/immutabilityAvailable.st new file mode 100644 index 00000000..4737f967 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/immutabilityAvailable.st @@ -0,0 +1,4 @@ +primimitive support +immutabilityAvailable + + ^ self primSomeImmutablePrimitive notNil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/isAbstract.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/isAbstract.st new file mode 100644 index 00000000..18e11899 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/isAbstract.st @@ -0,0 +1,4 @@ +testing +isAbstract + + ^ self name == #ImmutabilityTestCase \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/primSomeImmutablePrimitive.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/primSomeImmutablePrimitive.st new file mode 100644 index 00000000..e86f8583 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/primSomeImmutablePrimitive.st @@ -0,0 +1,6 @@ +primimitive support +primSomeImmutablePrimitive + " returns nil on failure on purpose " + + + ^ nil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/testSelectors.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/testSelectors.st new file mode 100644 index 00000000..6253e2bf --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/testSelectors.st @@ -0,0 +1,7 @@ +accessing +testSelectors + " Ensure those tests are not run on a 'normal' VM " + + ^ self immutabilityAvailable + ifFalse: [#()] + ifTrue: [super testSelectors] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/methodProperties.json new file mode 100644 index 00000000..2cfbc5f6 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/methodProperties.json @@ -0,0 +1,9 @@ +{ + "class" : { + "allTestSelectors" : "topa 11/28/2016 16:04", + "immutabilityAvailable" : "topa 11/28/2016 16:02", + "isAbstract" : "topa 11/28/2016 16:05", + "primSomeImmutablePrimitive" : "topa 11/28/2016 16:02", + "testSelectors" : "topa 11/28/2016 16:03" }, + "instance" : { + } } diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json new file mode 100644 index 00000000..4b3007be --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutabilityTestCase", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..e3e2e899 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,5 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: $T equals: anImmutableObject first. + self assert: 'This is a test string!' equals: anImmutableObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/attemptToModify..st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/attemptToModify..st new file mode 100644 index 00000000..41431772 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/attemptToModify..st @@ -0,0 +1,4 @@ +test objects +attemptToModify: anImmutableObject + + anImmutableObject at: 1 put: $x diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..80eddf2e --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ ByteString \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..ec49838a --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,4 @@ +test objects +objectUnderTest + + ^ 'This is a test string!' \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/methodProperties.json new file mode 100644 index 00000000..04dd467f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/methodProperties.json @@ -0,0 +1,8 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "fn 11/28/2016 20:36", + "attemptToModify:" : "fn 11/28/2016 20:38", + "classUnderTest" : "fn 11/28/2016 20:35", + "objectUnderTest" : "fn 11/28/2016 20:35" } } diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json new file mode 100644 index 00000000..a872928b --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableBytesObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..c47e2fb3 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,7 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: 'foo' equals: anImmutableObject aField. + self assert: #(2) equals: anImmutableObject anotherField. + self assert: 'bar' equals: anImmutableObject someVar1. + self assert: true equals: anImmutableObject someVar2. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/attemptToModify..st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/attemptToModify..st new file mode 100644 index 00000000..78e25e79 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/attemptToModify..st @@ -0,0 +1,4 @@ +test objects +attemptToModify: anImmutableObject + + anImmutableObject aField: 42 diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..74182401 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ImmJustFixedPointersClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..51eb84aa --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,8 @@ +test objects +objectUnderTest + + ^ self classUnderTest new + aField: 'foo'; + anotherField: #(2); + someVar: 'bar' someOtherVar: true; + yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json new file mode 100644 index 00000000..dc39f0d8 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json @@ -0,0 +1,8 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "topa 11/28/2016 16:13", + "attemptToModify:" : "jc 12/1/2016 10:24", + "classUnderTest" : "topa 11/28/2016 16:11", + "objectUnderTest" : "fn 11/28/2016 20:28" } } diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json new file mode 100644 index 00000000..51ab31b6 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableFixedObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st new file mode 100644 index 00000000..f6ec36af --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st @@ -0,0 +1,9 @@ +testing +testForeignFixedAsImmutable + + | objectUnderTest | + objectUnderTest := #( 'foo' (2) 'bar' true ) asImmutable: ImmJustFixedPointersClass. + self assert: 'foo' equals: objectUnderTest aField. + self assert: #(2) equals: objectUnderTest anotherField. + self assert: 'bar' equals: objectUnderTest someVar1. + self assert: true equals: objectUnderTest someVar2. diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st new file mode 100644 index 00000000..0362e0b3 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st @@ -0,0 +1,11 @@ +testing +testForeignVariableAsImmutable + + | objectUnderTest | + objectUnderTest := #( 'foo' (2) 'bar' true ) asImmutable: ImmJustVariablePointersClass. + self assert: 4 equals: objectUnderTest size. + self assert: 'foo' equals: (objectUnderTest at: 1). + self assert: #(2) equals: (objectUnderTest at: 2). + self assert: 'bar' equals: (objectUnderTest at: 3). + self assert: true equals: (objectUnderTest at: 4). + diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json new file mode 100644 index 00000000..c2ccffac --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json @@ -0,0 +1,6 @@ +{ + "class" : { + }, + "instance" : { + "testForeignFixedAsImmutable" : "topa 11/28/2016 16:27", + "testForeignVariableAsImmutable" : "fn 11/28/2016 20:26" } } diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json new file mode 100644 index 00000000..93a1fef2 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableForeignObjectTest", + "pools" : [ + ], + "super" : "ImmutabilityTestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..726a6943 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,8 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: 'foo' equals: anImmutableObject aField. + self assert: #(2) equals: anImmutableObject anotherField. + self assert: true equals: (anImmutableObject at: 1). + self assert: {} equals: (anImmutableObject at: 2). + self assert: 'bar' equals: (anImmutableObject at: 3). \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..af1db842 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ ImmMixedPointersClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..40ee0562 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,10 @@ +test objects +objectUnderTest + + ^ (self classUnderTest new: 3) + aField: 'foo'; + anotherField: #(2); + at: 1 put: true; + at: 2 put: {}; + at: 3 put: 'bar'; + yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/methodProperties.json new file mode 100644 index 00000000..39dae129 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/methodProperties.json @@ -0,0 +1,7 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "fn 11/28/2016 20:51", + "classUnderTest" : "fn 11/28/2016 20:55", + "objectUnderTest" : "fn 11/28/2016 20:50" } } diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json new file mode 100644 index 00000000..5e5e8fed --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableMixedObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/class/isAbstract.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/class/isAbstract.st new file mode 100644 index 00000000..6b49fe5f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/class/isAbstract.st @@ -0,0 +1,4 @@ +testing +isAbstract + + ^ self name == #ImmutableObjectTest \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..b581b5fd --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,4 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: false. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/attemptToModify..st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/attemptToModify..st new file mode 100644 index 00000000..4421d640 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/attemptToModify..st @@ -0,0 +1,4 @@ +test objects +attemptToModify: anImmutableObject + + anImmutableObject at: 1 put: 42 diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..124fd29e --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ self subclassResponsibility \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..186e2952 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,4 @@ +test objects +objectUnderTest + + ^ self subclassResponsibility \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st new file mode 100644 index 00000000..952446df --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st @@ -0,0 +1,7 @@ +testing +testAsImmutable + + | objectUnderTest | + objectUnderTest := self objectUnderTest asImmutable: self classUnderTest. + self attemptToModify: objectUnderTest. + self assertPropertiesOf: objectUnderTest. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st new file mode 100644 index 00000000..ee622a63 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st @@ -0,0 +1,6 @@ +testing +testImmutableCopy + + | objectUnderTest | + objectUnderTest := self objectUnderTest immutableCopy. + self assertPropertiesOf: objectUnderTest. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st new file mode 100644 index 00000000..8463188f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st @@ -0,0 +1,6 @@ +testing +testImmutableFrom + + | objectUnderTest | + objectUnderTest := self classUnderTest immutableFrom: self objectUnderTest. + self assertPropertiesOf: objectUnderTest. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json new file mode 100644 index 00000000..6ab30066 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json @@ -0,0 +1,11 @@ +{ + "class" : { + "isAbstract" : "topa 11/28/2016 16:18" }, + "instance" : { + "assertPropertiesOf:" : "topa 11/28/2016 16:12", + "attemptToModify:" : "fn 11/28/2016 20:38", + "classUnderTest" : "topa 11/28/2016 16:12", + "objectUnderTest" : "topa 11/28/2016 16:12", + "testAsImmutable" : "fn 11/28/2016 20:37", + "testImmutableCopy" : "topa 11/28/2016 16:09", + "testImmutableFrom" : "topa 11/28/2016 16:10" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json new file mode 100644 index 00000000..d3709382 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableObjectTest", + "pools" : [ + ], + "super" : "ImmutabilityTestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/README.md b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/instance/testImmutableObjectVMSupport.st b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/instance/testImmutableObjectVMSupport.st new file mode 100644 index 00000000..65cec62c --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/instance/testImmutableObjectVMSupport.st @@ -0,0 +1,6 @@ +testing +testImmutableObjectVMSupport + + self + assert: (Object new immutableCopy) isImmutable + description: 'Immutable objects not supported by VM' \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/methodProperties.json new file mode 100644 index 00000000..45c3f0ab --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/methodProperties.json @@ -0,0 +1,5 @@ +{ + "class" : { + }, + "instance" : { + "testImmutableObjectVMSupport" : "topa 11/28/2016 16:20" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json new file mode 100644 index 00000000..c84bdaed --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableObjectsVMTest", + "pools" : [ + ], + "super" : "ImmutabilityTestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..b6c1b4e1 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,7 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: 'foo' equals: (anImmutableObject at: 1). + self assert: #(2) equals: (anImmutableObject at: 2). + self assert: true equals: (anImmutableObject at: 3). + self assert: nil equals: (anImmutableObject at: 4). \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..39b90c01 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ImmJustVariablePointersClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..ad4939c8 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,8 @@ +test objects +objectUnderTest + + ^ (self classUnderTest new: 4) + at: 1 put: 'foo'; + at: 2 put: #(2); + at: 3 put: true; + yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json new file mode 100644 index 00000000..72266991 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json @@ -0,0 +1,7 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "fn 11/28/2016 20:23", + "classUnderTest" : "topa 11/28/2016 16:16", + "objectUnderTest" : "fn 11/28/2016 20:28" } } diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json new file mode 100644 index 00000000..b81cef9f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableVariableObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..a711a79f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,5 @@ +test objects +assertPropertiesOf: anImmutableObject + + (1 to: 10) do: [:i | + self assert: (i * 2) equals: (anImmutableObject at: i)]. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..56eb7a55 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ Bitmap \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..3b55e438 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,4 @@ +test objects +objectUnderTest + + ^ self classUnderTest withAll: ((1 to: 10) collect: [:i | i * 2]) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/methodProperties.json new file mode 100644 index 00000000..df5b03a8 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/methodProperties.json @@ -0,0 +1,7 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "fn 11/28/2016 20:41", + "classUnderTest" : "fn 11/28/2016 20:33", + "objectUnderTest" : "fn 11/28/2016 20:40" } } diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json new file mode 100644 index 00000000..994b0061 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableWordsObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/Object.extension/instance/^tilde.st b/repository/ImmutableObjects.package/Object.extension/instance/^tilde.st new file mode 100644 index 00000000..b1dd72fc --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/^tilde.st @@ -0,0 +1,5 @@ +*ImmutableObjects-Structures-testing +~ anObject + " printIt: [1 ~ 2 ~ 3] " + + ^ self asCons ~ anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/asCons.st b/repository/ImmutableObjects.package/Object.extension/instance/asCons.st new file mode 100644 index 00000000..839f8746 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/asCons.st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures-testing +asCons + + ^ Cons car: self cdr: nil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st new file mode 100644 index 00000000..447670de --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st @@ -0,0 +1,4 @@ +*ImmutableObjects +asImmutable: aClass + + ^ aClass immutableFrom: self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st new file mode 100644 index 00000000..24ae3d76 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st @@ -0,0 +1,4 @@ +*ImmutableObjects +immutableCopy + + ^ self asImmutable: self class \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/isCons.st b/repository/ImmutableObjects.package/Object.extension/instance/isCons.st new file mode 100644 index 00000000..c02a0f28 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/isCons.st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures-testing +isCons + + ^ false \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st b/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st new file mode 100644 index 00000000..79557939 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st @@ -0,0 +1,4 @@ +*ImmutableObjects +isImmutable + + ^ self primIsImmutable \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/primIsImmutable.st b/repository/ImmutableObjects.package/Object.extension/instance/primIsImmutable.st new file mode 100644 index 00000000..65009fd8 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/primIsImmutable.st @@ -0,0 +1,5 @@ +*ImmutableObjects +primIsImmutable + + + ^ false \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/methodProperties.json b/repository/ImmutableObjects.package/Object.extension/methodProperties.json new file mode 100644 index 00000000..9f58e454 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/methodProperties.json @@ -0,0 +1,11 @@ +{ + "class" : { + }, + "instance" : { + "asCons" : "topa 12/5/2016 17:42", + "asImmutable:" : "topa 11/28/2016 15:23", + "immutableCopy" : "topa 11/28/2016 15:24", + "isCons" : "topa 12/5/2016 09:25", + "isImmutable" : "topa 11/28/2016 15:23", + "primIsImmutable" : "topa 11/28/2016 15:23", + "~" : "topa 12/5/2016 17:45" } } diff --git a/repository/ImmutableObjects.package/Object.extension/properties.json b/repository/ImmutableObjects.package/Object.extension/properties.json new file mode 100644 index 00000000..3d3b9ec4 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "Object" } diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/append..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/append..st new file mode 100644 index 00000000..37bbf1bd --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/append..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +append: aCons + + ^ aCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/filter..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/filter..st new file mode 100644 index 00000000..e7a28846 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/filter..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +filter: aBlock + + ^ self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/findf.ifNone..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/findf.ifNone..st new file mode 100644 index 00000000..9dcc0b3e --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/findf.ifNone..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +findf: aBlock ifNone: anotherBlock + + ^ anotherBlock value \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldl.withInit..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldl.withInit..st new file mode 100644 index 00000000..0680f01f --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldl.withInit..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +foldl: aBlock withInit: anObject + + ^ anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldr.withInit..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldr.withInit..st new file mode 100644 index 00000000..8ff8e3db --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldr.withInit..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +foldr: aBlock withInit: anObject + + ^ anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/isCons.st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/isCons.st new file mode 100644 index 00000000..078149d3 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/isCons.st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +isCons + + ^ true \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/map..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/map..st new file mode 100644 index 00000000..bfeb41cf --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/map..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +map: aBlock + + ^ self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/reverse..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/reverse..st new file mode 100644 index 00000000..d599c732 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/reverse..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +reverse: aCons + + ^ aCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/methodProperties.json b/repository/ImmutableObjects.package/UndefinedObject.extension/methodProperties.json new file mode 100644 index 00000000..ab643692 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/methodProperties.json @@ -0,0 +1,12 @@ +{ + "class" : { + }, + "instance" : { + "append:" : "topa 12/5/2016 16:30", + "filter:" : "topa 12/5/2016 16:31", + "findf:ifNone:" : "topa 12/5/2016 17:32", + "foldl:withInit:" : "topa 12/5/2016 17:13", + "foldr:withInit:" : "topa 12/5/2016 16:53", + "isCons" : "topa 12/5/2016 16:26", + "map:" : "topa 12/5/2016 16:22", + "reverse:" : "topa 12/5/2016 16:40" } } diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/properties.json b/repository/ImmutableObjects.package/UndefinedObject.extension/properties.json new file mode 100644 index 00000000..508a24a8 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "UndefinedObject" } diff --git a/repository/ImmutableObjects.package/Vector.class/README.md b/repository/ImmutableObjects.package/Vector.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/Vector.class/class/new..st b/repository/ImmutableObjects.package/Vector.class/class/new..st new file mode 100644 index 00000000..5cf46568 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/new..st @@ -0,0 +1,4 @@ +instance creation +new: size + + self shouldNotImplement \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/new.st b/repository/ImmutableObjects.package/Vector.class/class/new.st new file mode 100644 index 00000000..8b15851a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/new.st @@ -0,0 +1,5 @@ +instance creation +new + + + ^ (self basicNew: 0) initialize \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/new.withAll..st b/repository/ImmutableObjects.package/Vector.class/class/new.withAll..st new file mode 100644 index 00000000..7f290564 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/new.withAll..st @@ -0,0 +1,4 @@ +instance creation +new: size withAll: value + + ^ self immutableFrom: (Array new: size withAll: value) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/newFrom..st b/repository/ImmutableObjects.package/Vector.class/class/newFrom..st new file mode 100644 index 00000000..570ce81b --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/newFrom..st @@ -0,0 +1,4 @@ +instance creation +newFrom: aCollection + + ^ self immutableFrom: aCollection asArray \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/newFromStream..st b/repository/ImmutableObjects.package/Vector.class/class/newFromStream..st new file mode 100644 index 00000000..9b04f6ac --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/newFromStream..st @@ -0,0 +1,5 @@ +instance creation +newFromStream: aStream + + self flag: #topa. "Todo." + self shouldBeImplemented. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/primImmutableFrom..st b/repository/ImmutableObjects.package/Vector.class/class/primImmutableFrom..st new file mode 100644 index 00000000..38db8c54 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/primImmutableFrom..st @@ -0,0 +1,8 @@ +instance creation +primImmutableFrom: aCollection + " Overridden to be co-usable in mutable form " + + aCollection class isVariable ifFalse: [^ self primitiveFailed]. + + ^ (self basicNew: aCollection size) + replaceFrom: 1 to: aCollection size with: aCollection \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with..st b/repository/ImmutableObjects.package/Vector.class/class/with..st new file mode 100644 index 00000000..2d5f5fb5 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with..st @@ -0,0 +1,6 @@ +instance creation +with: anObject + "Answer a new instance of me, containing only anObject." + + " Fallback for non-immutable " + ^ super with: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with..st new file mode 100644 index 00000000..980301f0 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with..st @@ -0,0 +1,7 @@ +instance creation +with: firstObject with: secondObject + "Answer a new instance of me, containing firstObject and secondObject." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with..st new file mode 100644 index 00000000..f5fd3368 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with..st @@ -0,0 +1,8 @@ +instance creation +with: firstObject with: secondObject with: thirdObject + "Answer a new instance of me, containing only the three arguments as + elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with..st new file mode 100644 index 00000000..0003c228 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with..st @@ -0,0 +1,8 @@ +instance creation +with: firstObject with: secondObject with: thirdObject with: fourthObject + "Answer a new instance of me, containing only the four arguments as + elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject with: fourthObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with..st new file mode 100644 index 00000000..f881eb95 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with..st @@ -0,0 +1,8 @@ +instance creation +with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject + "Answer a new instance of me, containing only the five arguments as + elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with.with..st new file mode 100644 index 00000000..36c97bb9 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with.with..st @@ -0,0 +1,7 @@ +instance creation +with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject with: sixthObject + "Answer a new instance of me, containing only the 6 arguments as elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject with: sixthObject diff --git a/repository/ImmutableObjects.package/Vector.class/class/withAll..st b/repository/ImmutableObjects.package/Vector.class/class/withAll..st new file mode 100644 index 00000000..103c2b9f --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/withAll..st @@ -0,0 +1,6 @@ +instance creation +withAll: aCollection + "Create a new collection containing all the elements from aCollection." + + ^ self immutableFrom: aCollection asArray + \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/^comma.st b/repository/ImmutableObjects.package/Vector.class/instance/^comma.st new file mode 100644 index 00000000..4b7d3058 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/^comma.st @@ -0,0 +1,11 @@ +copying +, otherCollection + + | intermediateHolder | + intermediateHolder := self species + new: (self size + otherCollection size) + streamContents: [:stream | + stream + nextPutAll: self; + nextPutAll: otherCollection]. + ^ self class newFrom: intermediateHolder \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/at.incrementBy..st b/repository/ImmutableObjects.package/Vector.class/instance/at.incrementBy..st new file mode 100644 index 00000000..7cc5489a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/at.incrementBy..st @@ -0,0 +1,4 @@ +unsupported mutation +at: index incrementBy: value + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atAll.put..st b/repository/ImmutableObjects.package/Vector.class/instance/atAll.put..st new file mode 100644 index 00000000..567dad35 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atAll.put..st @@ -0,0 +1,4 @@ +unsupported mutation +atAll: aCollection put: anObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atAll.putAll..st b/repository/ImmutableObjects.package/Vector.class/instance/atAll.putAll..st new file mode 100644 index 00000000..572ee66d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atAll.putAll..st @@ -0,0 +1,4 @@ +unsupported mutation +atAll: indexArray putAll: valueArray + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atAllPut..st b/repository/ImmutableObjects.package/Vector.class/instance/atAllPut..st new file mode 100644 index 00000000..c8dff94e --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atAllPut..st @@ -0,0 +1,4 @@ +unsupported mutation +atAllPut: anObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atLast.put..st b/repository/ImmutableObjects.package/Vector.class/instance/atLast.put..st new file mode 100644 index 00000000..12bb3227 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atLast.put..st @@ -0,0 +1,4 @@ +unsupported mutation +atLast: indexFromEnd put: obj + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atWrap.put..st b/repository/ImmutableObjects.package/Vector.class/instance/atWrap.put..st new file mode 100644 index 00000000..cf56dbe3 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atWrap.put..st @@ -0,0 +1,4 @@ +unsupported mutation +atWrap: index put: value + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/collect..st b/repository/ImmutableObjects.package/Vector.class/instance/collect..st new file mode 100644 index 00000000..906a8e57 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/collect..st @@ -0,0 +1,4 @@ +enumerating +collect: aBlock + + ^ self class newFrom: (super collect: aBlock) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/collect.from.to..st b/repository/ImmutableObjects.package/Vector.class/instance/collect.from.to..st new file mode 100644 index 00000000..c19b7df1 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/collect.from.to..st @@ -0,0 +1,4 @@ +enumerating +collect: aBlock from: first to: last + + ^ self class newFrom: (super collect: aBlock from: first to: last) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyEmpty.st b/repository/ImmutableObjects.package/Vector.class/instance/copyEmpty.st new file mode 100644 index 00000000..9991f7e6 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyEmpty.st @@ -0,0 +1,4 @@ +copying +copyEmpty + " Whyever useful.. " + ^ self class new \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyFrom.to..st b/repository/ImmutableObjects.package/Vector.class/instance/copyFrom.to..st new file mode 100644 index 00000000..a347ede9 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyFrom.to..st @@ -0,0 +1,12 @@ +copying +copyFrom: start to: stop + + | temporaryHolder | + stop < start ifTrue: [^ self copyEmpty]. + + temporaryHolder := self species + new: stop - start + 1 + streamContents: [:aStream | + start to: stop do: [:index | + aStream nextPut: (self at: index)]]. + ^ self class newFrom: temporaryHolder \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyReplaceFrom.to.with..st b/repository/ImmutableObjects.package/Vector.class/instance/copyReplaceFrom.to.with..st new file mode 100644 index 00000000..40c827d2 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyReplaceFrom.to.with..st @@ -0,0 +1,19 @@ +copying +copyReplaceFrom: start to: stop with: replacementCollection + + | intermediateHolder endReplacement newSize | + newSize := self size - (stop - start + 1) + replacementCollection size. + endReplacement := start - 1 + replacementCollection size. + intermediateHolder := self species + new: newSize + streamContents: [:aStream | + start > 1 ifTrue: [ + 1 to: start - 1 do: [:index | + aStream nextPut: (self at: index)]]. + start <= endReplacement ifTrue: [ + 1 to: replacementCollection size do: [:index | + aStream nextPut: (replacementCollection at: index)]]. + endReplacement < newSize ifTrue: [ + stop + 1 to: self size do: [:index | + aStream nextPut: (self at: index)]]]. + ^ self class newFrom: intermediateHolder \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyWith..st b/repository/ImmutableObjects.package/Vector.class/instance/copyWith..st new file mode 100644 index 00000000..bf471e6a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyWith..st @@ -0,0 +1,4 @@ +copying +copyWith: newElement + + ^ self, { newElement } \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyWithFirst..st b/repository/ImmutableObjects.package/Vector.class/instance/copyWithFirst..st new file mode 100644 index 00000000..1619352e --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyWithFirst..st @@ -0,0 +1,4 @@ +copying +copyWithFirst: newElement + + ^ self class newFrom: { newElement }, self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyWithoutIndex..st b/repository/ImmutableObjects.package/Vector.class/instance/copyWithoutIndex..st new file mode 100644 index 00000000..06d8a160 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyWithoutIndex..st @@ -0,0 +1,4 @@ +copying +copyWithoutIndex: index + + ^ (self first: index -1), (self allButFirst: index) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/from.to.put..st b/repository/ImmutableObjects.package/Vector.class/instance/from.to.put..st new file mode 100644 index 00000000..e5285e31 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/from.to.put..st @@ -0,0 +1,4 @@ +unsupported mutation +from: startIndex to: endIndex put: anObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/grownBy..st b/repository/ImmutableObjects.package/Vector.class/instance/grownBy..st new file mode 100644 index 00000000..564e0919 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/grownBy..st @@ -0,0 +1,4 @@ +unsupported mutation +grownBy: length + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/integerAt.put..st b/repository/ImmutableObjects.package/Vector.class/instance/integerAt.put..st new file mode 100644 index 00000000..1c5d4663 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/integerAt.put..st @@ -0,0 +1,4 @@ +unsupported mutation +integerAt: index put: value + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/pvtAt.put..st b/repository/ImmutableObjects.package/Vector.class/instance/pvtAt.put..st new file mode 100644 index 00000000..0bbd76f7 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/pvtAt.put..st @@ -0,0 +1,5 @@ +private mutation +pvtAt: anIndex put: anObject + " Will fail if we are immutable. Only for mutable support" + + ^ super at: anIndex put: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/replace..st b/repository/ImmutableObjects.package/Vector.class/instance/replace..st new file mode 100644 index 00000000..2a6cdb4a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/replace..st @@ -0,0 +1,4 @@ +unsupported mutation +replace: aBlock + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/replaceAll.with..st b/repository/ImmutableObjects.package/Vector.class/instance/replaceAll.with..st new file mode 100644 index 00000000..d93975a6 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/replaceAll.with..st @@ -0,0 +1,4 @@ +unsupported mutation +replaceAll: oldObject with: newObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/replaceFrom.to.with.startingAt..st b/repository/ImmutableObjects.package/Vector.class/instance/replaceFrom.to.with.startingAt..st new file mode 100644 index 00000000..1daaa610 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/replaceFrom.to.with.startingAt..st @@ -0,0 +1,9 @@ +private mutation +replaceFrom: start to: stop with: replacement startingAt: repStart + " Use super with a private version of at:put:, as the actual one is not to be used" + + | index repOff | + repOff := repStart - start. + index := start - 1. + [(index := index + 1) <= stop] + whileTrue: [self pvtAt: index put: (replacement at: repOff + index)] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/reversed.st b/repository/ImmutableObjects.package/Vector.class/instance/reversed.st new file mode 100644 index 00000000..505317b5 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/reversed.st @@ -0,0 +1,6 @@ +converting +reversed + + ^ self class newFrom: + (self species new: self size streamContents: [:aStream| + self reverseDo: [:each | aStream nextPut: each]]) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/select..st b/repository/ImmutableObjects.package/Vector.class/instance/select..st new file mode 100644 index 00000000..4b5501a8 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/select..st @@ -0,0 +1,4 @@ +enumerating +select: aBlock + + ^ self class newFrom: (super select: aBlock) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sort..st b/repository/ImmutableObjects.package/Vector.class/instance/sort..st new file mode 100644 index 00000000..ec421574 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sort..st @@ -0,0 +1,4 @@ +unsupported mutation +sort: aBlock + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sort.st b/repository/ImmutableObjects.package/Vector.class/instance/sort.st new file mode 100644 index 00000000..7726e8aa --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sort.st @@ -0,0 +1,4 @@ +unsupported mutation +sort + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sorted..st b/repository/ImmutableObjects.package/Vector.class/instance/sorted..st new file mode 100644 index 00000000..e896798d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sorted..st @@ -0,0 +1,4 @@ +sorting +sorted: aBlock + + self flag: #topa. "what do?" \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sorted.st b/repository/ImmutableObjects.package/Vector.class/instance/sorted.st new file mode 100644 index 00000000..6aaf291d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sorted.st @@ -0,0 +1,4 @@ +sorting +sorted + + self flag: #topa. "what do?" \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/species.st b/repository/ImmutableObjects.package/Vector.class/instance/species.st new file mode 100644 index 00000000..79599a8f --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/species.st @@ -0,0 +1,4 @@ +private +species + + ^ Array \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/swap.with..st b/repository/ImmutableObjects.package/Vector.class/instance/swap.with..st new file mode 100644 index 00000000..b49a6246 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/swap.with..st @@ -0,0 +1,4 @@ +unsupported mutation +swap: oneIndex with: anotherIndex + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/methodProperties.json b/repository/ImmutableObjects.package/Vector.class/methodProperties.json new file mode 100644 index 00000000..9a6c5e99 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/methodProperties.json @@ -0,0 +1,46 @@ +{ + "class" : { + "new" : "topa 12/5/2016 09:32", + "new:" : "topa 12/5/2016 09:29", + "new:withAll:" : "topa 12/5/2016 09:33", + "newFrom:" : "topa 12/5/2016 09:40", + "newFromStream:" : "topa 12/5/2016 09:35", + "primImmutableFrom:" : "topa 12/5/2016 09:45", + "with:" : "topa 12/5/2016 09:37", + "with:with:" : "topa 12/5/2016 09:37", + "with:with:with:" : "topa 12/5/2016 09:37", + "with:with:with:with:" : "topa 12/5/2016 09:38", + "with:with:with:with:with:" : "topa 12/5/2016 09:38", + "with:with:with:with:with:with:" : "topa 12/5/2016 09:38", + "withAll:" : "topa 12/5/2016 09:41" }, + "instance" : { + "," : "topa 12/5/2016 15:53", + "at:incrementBy:" : "topa 12/5/2016 15:12", + "atAll:put:" : "topa 12/5/2016 15:12", + "atAll:putAll:" : "topa 12/5/2016 15:12", + "atAllPut:" : "topa 12/5/2016 15:12", + "atLast:put:" : "topa 12/5/2016 15:13", + "atWrap:put:" : "topa 12/5/2016 15:14", + "collect:" : "topa 12/5/2016 16:17", + "collect:from:to:" : "topa 12/5/2016 16:17", + "copyEmpty" : "topa 12/5/2016 15:39", + "copyFrom:to:" : "topa 12/5/2016 15:55", + "copyReplaceFrom:to:with:" : "topa 12/5/2016 16:03", + "copyWith:" : "topa 12/5/2016 16:06", + "copyWithFirst:" : "topa 12/5/2016 16:05", + "copyWithoutIndex:" : "topa 12/5/2016 16:07", + "from:to:put:" : "topa 12/5/2016 16:10", + "grownBy:" : "topa 12/5/2016 16:10", + "integerAt:put:" : "topa 12/5/2016 16:10", + "pvtAt:put:" : "topa 12/5/2016 15:35", + "replace:" : "topa 12/5/2016 16:12", + "replaceAll:with:" : "topa 12/5/2016 16:12", + "replaceFrom:to:with:startingAt:" : "topa 12/5/2016 15:34", + "reversed" : "topa 12/5/2016 16:14", + "select:" : "topa 12/5/2016 16:15", + "sort" : "topa 12/5/2016 15:36", + "sort:" : "topa 12/5/2016 15:36", + "sorted" : "topa 12/5/2016 15:36", + "sorted:" : "topa 12/5/2016 15:36", + "species" : "topa 12/5/2016 15:38", + "swap:with:" : "topa 12/5/2016 16:16" } } diff --git a/repository/ImmutableObjects.package/Vector.class/properties.json b/repository/ImmutableObjects.package/Vector.class/properties.json new file mode 100644 index 00000000..45083c5d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Structures", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "Vector", + "pools" : [ + ], + "super" : "ArrayedCollection", + "type" : "variable" } diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/README.md b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st new file mode 100644 index 00000000..1bcac077 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st @@ -0,0 +1,4 @@ +defaults +defaultProblemSize + + ^ 1000 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st new file mode 100644 index 00000000..f0892176 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st @@ -0,0 +1,4 @@ +benchmark hooks +classUnderBenching + + ^ Vector \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st new file mode 100644 index 00000000..274a21d1 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st @@ -0,0 +1,6 @@ +benchmark hooks +createCharacterListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self vectorWith: [($a to: $z) atRandom: rng] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st new file mode 100644 index 00000000..8a7a1105 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st @@ -0,0 +1,13 @@ +benchmark hooks +createMixedListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self + vectorWith: [ + | roll | + roll := 3 atRandom: rng. + roll = 1 ifTrue: [rng nextInt: aNumber] ifFalse: [ + roll = 2 ifTrue: [($a to: $z) atRandom: rng] ifFalse: [ + roll = 3 ifTrue: [SMarkBox new value: (rng nextInt: aNumber)]]]] + through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st new file mode 100644 index 00000000..17186f7c --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st @@ -0,0 +1,6 @@ +benchmark hooks +createNumberListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self vectorWith: [rng nextInt: aNumber] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st new file mode 100644 index 00000000..a6ceb6cd --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st @@ -0,0 +1,6 @@ +benchmark hooks +createObjectListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self vectorWith: [SMarkBox new value: (rng nextInt: aNumber)] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st new file mode 100644 index 00000000..7c70b45e --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st @@ -0,0 +1,6 @@ +set up +vector: aVector with: aBlock through: aNumber + + ^ aNumber = 0 + ifTrue: [aVector] + ifFalse: [self vector: (aVector copyWith: aBlock value) with: aBlock through: (aNumber - 1)] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st new file mode 100644 index 00000000..b6f441df --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st @@ -0,0 +1,4 @@ +set up +vectorWith: aBlock through: aNumber + + ^ self vector: Vector new with: aBlock through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/methodProperties.json b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/methodProperties.json new file mode 100644 index 00000000..0e08a91b --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/methodProperties.json @@ -0,0 +1,11 @@ +{ + "class" : { + "defaultProblemSize" : "jc 1/5/2017 16:29" }, + "instance" : { + "classUnderBenching" : "jc 1/5/2017 16:30", + "createCharacterListOfSize:" : "jc 1/5/2017 17:01", + "createMixedListOfSize:" : "jc 1/5/2017 17:02", + "createNumberListOfSize:" : "jc 1/5/2017 17:04", + "createObjectListOfSize:" : "jc 1/5/2017 17:05", + "vector:with:through:" : "jc 1/5/2017 16:57", + "vectorWith:through:" : "jc 1/5/2017 16:54" } } diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/properties.json b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/properties.json new file mode 100644 index 00000000..6c73403d --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-ListNanos", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "VectorNanoBenchmark", + "pools" : [ + ], + "super" : "SMarkCollectionNanoBenchmark", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/categories.st b/repository/ImmutableObjects.package/monticello.meta/categories.st new file mode 100644 index 00000000..e9a37e83 --- /dev/null +++ b/repository/ImmutableObjects.package/monticello.meta/categories.st @@ -0,0 +1,3 @@ +SystemOrganization addCategory: #'ImmutableObjects-ListNanos'! +SystemOrganization addCategory: #'ImmutableObjects-Structures'! +SystemOrganization addCategory: #'ImmutableObjects-Tests'! diff --git a/repository/ImmutableObjects.package/monticello.meta/initializers.st b/repository/ImmutableObjects.package/monticello.meta/initializers.st new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/monticello.meta/package b/repository/ImmutableObjects.package/monticello.meta/package new file mode 100644 index 00000000..cb0284ac --- /dev/null +++ b/repository/ImmutableObjects.package/monticello.meta/package @@ -0,0 +1 @@ +(name 'ImmutableObjects') \ No newline at end of file diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version new file mode 100644 index 00000000..0ef6583b --- /dev/null +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -0,0 +1 @@ +(name 'ImmutableObjects-jc.21' message 'categorization' id 'fbe5d9bf-4b63-4b9b-a5c1-0968226aa876' date '8 February 2017' time '6:06:51.260485 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.20' message 'categorization' id 'c4601ecc-c634-4e7b-a9ba-d7884b036196' date '8 February 2017' time '6:01:30.202538 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.19' message 'categorization' id 'b1f5d5d1-596c-47e3-b0b2-74fd4fb4c6b7' date '8 February 2017' time '4:33:54.634511 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/properties.json b/repository/ImmutableObjects.package/properties.json new file mode 100644 index 00000000..f037444a --- /dev/null +++ b/repository/ImmutableObjects.package/properties.json @@ -0,0 +1,2 @@ +{ + } diff --git a/rsqueakvm/display.py b/rsqueakvm/display.py index fbad0210..e0ca4d53 100644 --- a/rsqueakvm/display.py +++ b/rsqueakvm/display.py @@ -426,12 +426,14 @@ def get_next_event(self, time=0): return self.get_next_mouse_wheel_event(time, event) elif event_type == RSDL.KEYDOWN: self.handle_keyboard_event(event_type, event) - if not self.is_modifier_key(self.key) and ( - self.is_control_key(self.key) - or RSDL.GetModState() & ~RSDL.KMOD_SHIFT != 0): - # no TEXTINPUT event for this key will follow - # but Squeak needs a KeyStroke anyway - self._deferred_events.append(self.get_next_key_event(EventKeyChar, time)) + if not self.is_modifier_key(self.key): + # no TEXTINPUT event for this key will follow, but + # Squeak needs a KeyStroke anyway + if ((system.IS_LINUX and self.is_control_key(self.key)) or + (not system.IS_LINUX and + (self.is_control_key(self.key) or + RSDL.GetModState() & ~RSDL.KMOD_SHIFT != 0))): + self._deferred_events.append(self.get_next_key_event(EventKeyChar, time)) self.fix_key_code_case() return self.get_next_key_event(EventKeyDown, time) elif event_type == RSDL.TEXTINPUT: diff --git a/rsqueakvm/model/variable.py b/rsqueakvm/model/variable.py index ea3dd607..2341e041 100644 --- a/rsqueakvm/model/variable.py +++ b/rsqueakvm/model/variable.py @@ -4,8 +4,6 @@ from rpython.rlib import jit from rpython.rlib.rarithmetic import intmask, r_uint, r_uint32, r_int64 -from rpython.rlib.objectmodel import we_are_translated, always_inline, specialize -from rpython.rtyper.lltypesystem import lltype, rffi class W_BytesObject(W_AbstractObjectWithClassReference): @@ -38,7 +36,7 @@ def atput0(self, space, index0, w_value): raise error.PrimitiveFailedError def getchar(self, n0): - return self.bytes[n0] + return self._bytes()[n0] def setchar(self, n0, character): assert isinstance(character, str) @@ -66,7 +64,13 @@ def short_atput0(self, space, index0, w_value): self.setchar(byte_index0 + 1, chr(byte1)) def size(self): - return len(self.bytes) + return len(self._bytes()) + + def _bytes(self): + return self.bytes + + def _version(self): + return self.version def str_content(self): if self.getclass(None).has_space(): @@ -77,14 +81,14 @@ def str_content(self): (self.unwrap_string(None).replace('\r', '\n'))]) def unwrap_string(self, space): - return self._pure_as_string(self.version) + return self._pure_as_string(self._version()) @jit.elidable def _pure_as_string(self, version): - return "".join(self.bytes) + return "".join(self._bytes()) def getbytes(self): - return self.bytes + return self._bytes() @jit.dont_look_inside def setbytes(self, lst): @@ -143,7 +147,7 @@ def unwrap_long_untranslated(self, space): @elidable_for_version_iff(0, cond=lambda self: jit.isconstant(self)) def getrbigint(self): from rpython.rlib.rbigint import rbigint - return rbigint.frombytes(''.join(self.getbytes()), 'little', False) + return rbigint.frombytes(''.join(self._bytes()), 'little', False) def selector_string(self): return "#" + self.unwrap_string(None) @@ -151,7 +155,7 @@ def selector_string(self): def invariant(self): if not W_AbstractObjectWithClassReference.invariant(self): return False - for c in self.bytes: + for c in self._bytes(): if not isinstance(c, str) or len(c) != 1: return False return True @@ -159,7 +163,7 @@ def invariant(self): def clone(self, space): size = self.size() w_result = W_BytesObject(space, self.getclass(space), size) - w_result.bytes = list(self.bytes) + w_result.bytes = list(self._bytes()) return w_result def is_array_object(self): @@ -197,7 +201,7 @@ def atput0(self, space, index0, w_value): def getword(self, n): assert self.size() > n >= 0 - return self.words[n] + return self._words()[n] def setword(self, n, word): self.words[n] = r_uint(word) @@ -247,13 +251,16 @@ def setwords(self, lst): self.words = lst def size(self): - return len(self.words) + return len(self._words()) + + def _words(self): + return self.words @jit.look_inside_iff(lambda self, space: jit.isconstant(self.size())) def unwrap_string(self, space): # OH GOD! TODO: Make this sane! res = [] - for word in self.words: + for word in self._words(): res += [chr((word & r_uint(0x000000ff)) >> 0), chr((word & r_uint(0x0000ff00)) >> 8), chr((word & r_uint(0x00ff0000)) >> 16), @@ -262,12 +269,12 @@ def unwrap_string(self, space): def invariant(self): return (W_AbstractObjectWithClassReference.invariant(self) and - isinstance(self.words, list)) + isinstance(self._words(), list)) def clone(self, space): size = self.size() w_result = W_WordsObject(space, self.getclass(space), size) - w_result.words = list(self.words) + w_result.words = list(self._words()) return w_result def is_array_object(self): diff --git a/rsqueakvm/plugins/immutability/__init__.py b/rsqueakvm/plugins/immutability/__init__.py new file mode 100644 index 00000000..378d84dc --- /dev/null +++ b/rsqueakvm/plugins/immutability/__init__.py @@ -0,0 +1,48 @@ +""" +Base functions for ImmutabilityPlugin. + +.. data:: WRITE_OPERATIONS +A list of all write operations to be stubbed out by `immutable_class(cls)` +decorator. +""" + +from rsqueakvm.model.base import W_Object + +WRITE_OPERATIONS = [ + # W_Object + 'atput0', 'store', 'store_all', 'setword' '_become', 'fillin', + 'fillin_weak', 'fillin_finalize', + # W_PointersObject + 'pointers_become_one_way', + # W_BytesObject / W_WordsObject + 'setchar', 'short_atput0', 'setword', 'setwords', + 'convert_to_bytes_layout', 'setbytes', 'mutate' +] + + +def immutable_class(cls): + """ + This function decorates classes, so that `is_immutable` returns `True` and + all `WRITE_OPERATIONS` are implemented as NoOps. + + :param cls: The target class. + :returns: The decorated class. + + """ + def is_immutable(self): + return True + cls.is_immutable = is_immutable + + for method_name in WRITE_OPERATIONS: + if hasattr(cls, method_name): + def noop(self, *args): + pass + setattr(cls, method_name, noop) + return cls + + +def patch_w_object(): + """Add `W_Object.is_immutable` which by default returns `False`.""" + def is_immutable(self): + return False + W_Object.is_immutable = is_immutable diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py new file mode 100644 index 00000000..259fc2bd --- /dev/null +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -0,0 +1,44 @@ +"""Immutable W_BytesObject Implementation.""" + +from rsqueakvm.model.base import W_AbstractObjectWithClassReference +from rsqueakvm.model.variable import W_BytesObject +from rsqueakvm.plugins.immutability import immutable_class + + +@immutable_class +class W_Immutable_BytesObject(W_BytesObject): + """`W_BytesObject` subclass with immutable bytes.""" + _immutable_fields_ = ['immutable_bytes'] + repr_classname = '%s_Immutable' % W_BytesObject.repr_classname + + def __init__(self, space, w_cls, bytes): + """ + Initialize immutable bytes object and store its bytes in + `self.immutable_bytes` slot. + `W_BytesObject.__init__(self, space, w_class, size)` not called, + because there is no need to `self.mutate()` and set `self.bytes`. + """ + W_AbstractObjectWithClassReference.__init__(self, space, w_cls) + self.immutable_bytes = bytes + + # No need to make this jit.elidable, jit can prove return val is constant. + def _bytes(self): + """ + `W_BytesObject._bytes(self)` override. + + :returns: bytes from `self.immutable_bytes` slot. + """ + return self.immutable_bytes + + def _version(self): + """ + `W_BytesObject._version(self)` override. + + :returns: `None`. + """ + return None + + """ + No need to override other methods that reference self.bytes, because they + were stubbed out by @immutable_class. + """ diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py new file mode 100644 index 00000000..9716350e --- /dev/null +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -0,0 +1,146 @@ +""" +Immutable W_PointersObject Implementation. + +.. data:: POINTERS_CLASSES +A list of all immutable W_PointersObject subclasses. The position of each class +in the list correlates to its number of storage slots (`0` no storage, `1` has +one storage slot, ...). The last class in the list is an immutable +W_PointersObject subclass with variable storage size. + +.. data:: POINTERS_CLASS_ITER +Unrolling iterable of `POINTERS_CLASSES`. + +.. data:: STORAGE_ATTR_TEMPLATE +Storage attribute template. + +.. data:: MAX_FIXED_SLOTS +Number of immutable subclasses with fixed number of slots to generate. + +""" + +from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash +from rsqueakvm.model.pointers import W_PointersObject +from rsqueakvm.plugins.immutability import immutable_class +from rsqueakvm.storage_classes import ClassShadow + +from rpython.rlib import rerased +from rpython.rlib.unroll import unrolling_iterable + +STORAGE_ATTR_TEMPLATE = "storage_%d" + +MAX_FIXED_SLOTS = 9 + + +@immutable_class +class W_AbstractImmutable_PointersObject(W_PointersObject): + """Abstract `W_PointersObject` subclass for immutable pointers objects.""" + _attrs_ = [] + _immutable_fields_ = [] + repr_classname = ('%s_AbstractImmutable' % + W_PointersObject.repr_classname) + + def __init__(self, space, w_cls): + """ + Initialize immutable pointers object, but avoid initializing storage + by calling `W_AbstractObjectWithIdentityHash.__init__(self)` instead of + `W_PointersObject.__init__(self)`. + Additionally, reuse `self.strategy` slot to store class shadow. + + """ + W_AbstractObjectWithIdentityHash.__init__(self) + self.strategy = w_cls.as_class_get_shadow(space) + + def getclass(self, space): + """:returns: Class from class shadow stored in `self.strategy` slot.""" + return self.strategy.w_self() + + def class_shadow(self, space): + """:returns: Class shadow stored in `self.strategy` slot.""" + class_shadow = self.strategy + assert isinstance(class_shadow, ClassShadow) + return class_shadow + + def size(self): + """:raises: NotImplementedError""" + raise NotImplementedError('abstract base class') + + def fetch(self, space, n0): + """:raises: NotImplementedError""" + raise NotImplementedError('abstract base class') + + +class W_Immutable_PointersObject(W_AbstractImmutable_PointersObject): + """`W_PointersObject` subclass with immutable storage of variable size.""" + _immutable_fields_ = ['_storage[*]'] + repr_classname = '%s_Immutable_N' % W_PointersObject.repr_classname + erase, unerase = map( + staticmethod, rerased.new_erasing_pair('storage_eraser')) + + def __init__(self, space, w_cls, pointers_w): + W_AbstractImmutable_PointersObject.__init__(self, space, w_cls) + self._storage = self.erase(pointers_w) + + def size(self): + return len(self.unerase(self._storage)) + + def fetch(self, space, n0): + return self.unerase(self._storage)[n0] + + +def generate_fixed_immutable_subclass(n_storage): + """ + Generate `W_PointersObject` subclass with immutable storage of fixed size. + + :param n_storage: Number of storage slots. + :returns: Immutable `W_PointersObject` subclass with fixed slots. + """ + storage_iter = unrolling_iterable(range(n_storage)) + cls_name = '%s_Immutable_%s' % (W_PointersObject.repr_classname, n_storage) + + class W_FixedImmutable_PointersObject(W_AbstractImmutable_PointersObject): + """`W_PointersObject` subclass with immutable storage of fixed size.""" + _storages_ = [(STORAGE_ATTR_TEMPLATE % x) for x in storage_iter] + _attrs_ = _storages_ + _immutable_fields_ = _storages_ + repr_classname = cls_name + + def __init__(self, space, w_cls, pointers_w): + W_AbstractImmutable_PointersObject.__init__(self, space, w_cls) + for x in storage_iter: + setattr(self, STORAGE_ATTR_TEMPLATE % x, pointers_w[x]) + + def size(self): + return n_storage + + def fetch(self, space, n0): + for x in storage_iter: + if x == n0: + return getattr(self, STORAGE_ATTR_TEMPLATE % x) + raise IndexError + return self.storage[n0] + + W_FixedImmutable_PointersObject.__name__ = cls_name + + return W_FixedImmutable_PointersObject + +POINTERS_CLASSES = [] +for n_storage in range(0, MAX_FIXED_SLOTS + 1): + POINTERS_CLASSES.append(generate_fixed_immutable_subclass(n_storage)) +POINTERS_CLASSES.append(W_Immutable_PointersObject) +POINTERS_CLASS_ITER = unrolling_iterable(enumerate(POINTERS_CLASSES)) + + +def select_immutable_pointers_class(storage): + """ + Select immutable `W_PointersObject` subclass for a given pointers storage. + If there is no immutable `W_PointersObject` subclass with the right fixed + storage size, it returns the immutable subclass with variable storage size. + + :param storage: Pointers to store. + :returns: Immutable `W_PointersObject` subclass. + """ + length = len(storage) + for i, cls in POINTERS_CLASS_ITER: + if i == length: + return cls + return W_Immutable_PointersObject diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py new file mode 100644 index 00000000..2b3df6d9 --- /dev/null +++ b/rsqueakvm/plugins/immutability/words.py @@ -0,0 +1,36 @@ +"""Immutable W_WordsObject Implementation.""" + +from rsqueakvm.model.base import W_AbstractObjectWithClassReference +from rsqueakvm.model.variable import W_WordsObject +from rsqueakvm.plugins.immutability import immutable_class + + +@immutable_class +class W_Immutable_WordsObject(W_WordsObject): + """`W_WordsObject` subclass with immutable words.""" + _immutable_fields_ = ['immutable_words'] + repr_classname = '%s_Immutable' % W_WordsObject.repr_classname + + def __init__(self, space, w_cls, words): + """ + Initialize immutable words object and store its words in + `self.immutable_words` slot. + `W_Immutable_WordsObject.__init__(self, space, w_class, size)` not + called, because there is no need to initialize `self.words`. + """ + W_AbstractObjectWithClassReference.__init__(self, space, w_cls) + self.immutable_words = words + + # No need to make this jit.elidable, jit can prove return val is constant. + def _words(self): + """ + `W_WordsObject._words(self)` override. + + :returns: words from `self.immutable_words` slot. + """ + return self.immutable_words + + """ + No need to override other methods that reference self.words, because they + were stubbed out by @immutable_class. + """ diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py new file mode 100644 index 00000000..5bcd294e --- /dev/null +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -0,0 +1,101 @@ +""" +RSqueak/VM plugin which provides support for immutable objects. + +Immutable objects can be created as copy of existing objects +or from a list of arguments. The package `ImmutableObjects`, located in +`/repository`, needs to be loaded in the image. +""" + +from rsqueakvm.error import PrimitiveFailedError, UnwrappingError +from rsqueakvm.model.variable import W_BytesObject, W_WordsObject +from rsqueakvm.plugins.immutability import patch_w_object +from rsqueakvm.plugins.immutability.bytes import W_Immutable_BytesObject +from rsqueakvm.plugins.immutability.pointers import ( + select_immutable_pointers_class) +from rsqueakvm.plugins.immutability.words import W_Immutable_WordsObject +from rsqueakvm.plugins.plugin import Plugin +from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS + + +ImmutabilityPlugin = Plugin() +patch_w_object() + + +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) +def primitiveIsImmutable(interp, s_frame, w_recv): + """ + Tests if `w_recv` is an immutable object. + + :param interp: The interpreter proxy. + :param s_frame: The stack frame. + :param w_recv: The receiver object. + :returns: `w_true` if `w_recv` is immutable object, otherwise `w_false`. + """ + if w_recv.is_immutable(): + return interp.space.w_true + return interp.space.w_false + + +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) +def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): + """ + Creates an immutable copy of a given Smalltalk object. + + :param interp: The interpreter proxy. + :param s_frame: The stack frame. + :param w_cls: The imutable objects target class. + :param w_obj: The Smalltalk object to produce an immutable copy from. + :returns: An immutable copy of `w_obj` with class `w_cls`. + :raises: PrimitiveFailedError + """ + space = interp.space + instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() + + if instance_kind == POINTERS: + pointers = w_obj.fetch_all(space) + cls = select_immutable_pointers_class(pointers) + return cls(space, w_cls, pointers) + elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): + return W_Immutable_BytesObject(space, w_cls, w_obj.bytes) + elif instance_kind == WORDS and isinstance(w_obj, W_WordsObject): + return W_Immutable_WordsObject(space, w_cls, w_obj.words) + + raise PrimitiveFailedError + + +@ImmutabilityPlugin.expose_primitive(unwrap_spec=None) +def primitiveImmutableFromArgs(interp, s_frame, argcount): + """ + Returns an immutable instance of the receiver (which is a class) with + all fields initialized with the arguments given. + + :param interp: The interpreter proxy. + :param s_frame: The stack frame. + :param argcount: The number of arguments. + :returns: An immutable object. + :raises: PrimitiveFailedError + """ + if argcount == 0: + raise PrimitiveFailedError + w_args = s_frame.pop_and_return_n(argcount)[:] + w_cls = s_frame.pop() + space = interp.space + instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() + + if instance_kind == POINTERS: + cls = select_immutable_pointers_class(w_args) + return cls(space, w_cls, w_args) + elif instance_kind == BYTES: + try: + bytes = [chr(interp.space.unwrap_uint(b)) for b in w_args] + except (ValueError, TypeError, UnwrappingError): + raise PrimitiveFailedError + return W_Immutable_BytesObject(space, w_cls, bytes) + elif instance_kind == WORDS: + try: + words = [interp.space.unwrap_uint(b) for b in w_args] + except UnwrappingError: + raise PrimitiveFailedError + return W_Immutable_WordsObject(space, w_cls, words) + + raise PrimitiveFailedError diff --git a/rsqueakvm/test/test_display.py b/rsqueakvm/test/test_display.py index 4c9604f1..65647614 100644 --- a/rsqueakvm/test/test_display.py +++ b/rsqueakvm/test/test_display.py @@ -269,10 +269,22 @@ def test_keyboard_chords(sut, mocked_sdl_event_queue, stub_events, stub_mod_stat mocked_sdl_event_queue.append(a_down) sqADown = sut.get_next_event() # A entered + if system.IS_LINUX: + # on linux, we don't get this + a_stroke = stub_events.malloc(RSDL.TextInputEvent) + a_stroke.c_type = RSDL.TEXTINPUT + rffi.str2chararray('a\x00', a_stroke.c_text, RSDL.TEXTINPUTEVENT_TEXT_SIZE) + mocked_sdl_event_queue.append(a_stroke) sqAStroke = sut.get_next_event() # repeat A mocked_sdl_event_queue.append(a_down) sqADown2 = sut.get_next_event() + if system.IS_LINUX: + # on linux, we don't get this + a_stroke = stub_events.malloc(RSDL.TextInputEvent) + a_stroke.c_type = RSDL.TEXTINPUT + rffi.str2chararray('a\x00', a_stroke.c_text, RSDL.TEXTINPUTEVENT_TEXT_SIZE) + mocked_sdl_event_queue.append(a_stroke) sqAStroke2 = sut.get_next_event() # A up a_up = stub_events.malloc(RSDL.KeyboardEvent) diff --git a/rsqueakvm/test/test_immutability_plugin.py b/rsqueakvm/test/test_immutability_plugin.py new file mode 100644 index 00000000..65010d47 --- /dev/null +++ b/rsqueakvm/test/test_immutability_plugin.py @@ -0,0 +1,74 @@ +import py +import pytest + +from rsqueakvm import storage_classes +from rsqueakvm.plugins.immutability.bytes import W_Immutable_BytesObject +from rsqueakvm.plugins.immutability.pointers import ( + select_immutable_pointers_class) +from rsqueakvm.plugins.immutability.words import W_Immutable_WordsObject +from rsqueakvm.model.pointers import W_PointersObject + +from .util import create_space, cleanup_module + + +def test_space(): + return create_space(bootstrap=True) + +space = pytest.fixture(test_space) +bootstrap_class = None + + +def setup_module(): + global bootstrap_class, space + v_space = test_space() + space = v_space + bootstrap_class = space.bootstrap_class + + +def teardown_module(): + cleanup_module(__name__) + + +def test_W_Immutable_BytesObject(): + w_class = bootstrap_class(0, format=storage_classes.BYTES) + w_bytes = w_class.as_class_get_shadow(space).new(20) + w_ibytes = W_Immutable_BytesObject(space, w_class, w_bytes.bytes) + assert w_ibytes.is_immutable() + assert w_ibytes.getclass(space).is_same_object(w_class) + assert w_ibytes.size() == 20 + assert w_ibytes.getchar(3) == '\x00' + w_ibytes.setchar(3, '\xAA') + assert w_ibytes.getchar(3) == '\x00' + py.test.raises(IndexError, lambda: w_ibytes.getchar(20)) + + +def test_W_Immutable_PointersObjects(): + w_class = bootstrap_class(0) + for i in range(20): + w_pointers = W_PointersObject(space, w_class, i) + cls = select_immutable_pointers_class(w_pointers.fetch_all(space)) + assert (i == len(cls._immutable_fields_) or + cls._immutable_fields_ == ['_storage[*]']) + placeholder = object() + w_ipointers = cls(space, w_class, [placeholder] * i) + assert w_ipointers.is_immutable() + assert w_ipointers.getclass(space).is_same_object(w_class) + assert w_ipointers.size() == i + if i > 0: + assert w_ipointers.fetch(space, 0) is placeholder + w_ipointers.store(space, 0, space.w_true) + assert w_ipointers.fetch(space, 0) is placeholder + + +def test_W_Immutable_WordsObject(): + w_class = bootstrap_class(0, format=storage_classes.WORDS) + w_words = w_class.as_class_get_shadow(space).new(20) + w_iwords = W_Immutable_WordsObject(space, w_class, w_words.words) + assert w_iwords.is_immutable() + assert w_iwords.getclass(space).is_same_object(w_class) + assert w_iwords.size() == 20 + assert w_class.as_class_get_shadow(space).instsize() == 0 + assert w_iwords.getword(3) == 0 + w_iwords.setword(3, 42) + assert w_iwords.getword(3) == 0 + py.test.raises(AssertionError, lambda: w_iwords.getword(20)) diff --git a/rsqueakvm/test/test_model.py b/rsqueakvm/test/test_model.py index afb50837..d9750860 100644 --- a/rsqueakvm/test/test_model.py +++ b/rsqueakvm/test/test_model.py @@ -74,15 +74,15 @@ def test_bytes_object(): def test_word_object(): w_class = bootstrap_class(0, format=storage_classes.WORDS) - w_bytes = w_class.as_class_get_shadow(space).new(20) - assert w_bytes.getclass(space).is_same_object(w_class) - assert w_bytes.size() == 20 + w_words = w_class.as_class_get_shadow(space).new(20) + assert w_words.getclass(space).is_same_object(w_class) + assert w_words.size() == 20 assert w_class.as_class_get_shadow(space).instsize() == 0 - assert w_bytes.getword(3) == 0 - w_bytes.setword(3, 42) - assert w_bytes.getword(3) == 42 - assert w_bytes.getword(0) == 0 - py.test.raises(AssertionError, lambda: w_bytes.getword(20)) + assert w_words.getword(3) == 0 + w_words.setword(3, 42) + assert w_words.getword(3) == 42 + assert w_words.getword(0) == 0 + py.test.raises(AssertionError, lambda: w_words.getword(20)) def test_method_lookup(): class mockmethod(object):