├── .gdbinit ├── .github ├── labeler.yml └── workflows │ ├── ccpp.yml │ ├── doc-lyx.yml │ ├── greetings.yml │ └── label.yml ├── .gitignore ├── INTERNALS ├── LICENSE ├── Makefile ├── README ├── README.md ├── TAGS ├── TODO.org ├── common.mk ├── configure ├── doc ├── Makefile ├── object-format.txt ├── progman.bib ├── progman.lyx └── sysdesign.lyx ├── docs └── robots.txt ├── etc ├── Slate.tmbundle │ ├── Commands │ │ └── Run Script.plist │ ├── Preferences │ │ ├── Indentation.plist │ │ ├── Typing Pairs Default.plist │ │ └── Typing Pairs in Blocks.plist │ ├── Snippets │ │ ├── Block Header ([).plist │ │ ├── If-then (if).plist │ │ ├── If-then-else (ifte).plist │ │ ├── collect (collect).plist │ │ ├── define prototype (proto).plist │ │ ├── do (do).plist │ │ ├── doWithIndex (dowith).plist │ │ ├── inject into (inject).plist │ │ ├── reject (reject).plist │ │ ├── select (select).plist │ │ ├── until (until).plist │ │ └── while (while).plist │ ├── Syntaxes │ │ └── Slate.plist │ └── info.plist ├── slate-kate.xml ├── slate-mode.el ├── slate-startup.el ├── slate.1 ├── slate.lua └── slate.vim ├── images ├── kernel.new.little.32.1228690585383733.image ├── kernel.new.little.32.1229184847145515.image ├── kernel.new.little.32.1230788762134391.image ├── kernel.new.little.32.1231010885143086.image ├── kernel.new.little.32.1232382751905090.image ├── kernel.new.little.32.1234233045701141.image ├── kernel.new.little.32.1238346509933125.image ├── kernel.new.little.32.1240611319461001.image ├── kernel.new.little.32.1241193387532155.image ├── kernel.new.little.32.1241477863717373.image ├── kernel.new.little.64.1228690000224248.image ├── kernel.new.little.64.1229184296116084.image ├── kernel.new.little.64.1230787833037341.image ├── kernel.new.little.64.1231010025459516.image ├── kernel.new.little.64.1232382035091548.image ├── kernel.new.little.64.1234230732370510.image ├── kernel.new.little.64.1238343921968846.image ├── kernel.new.little.64.1240610406648483.image ├── kernel.new.little.64.1241194365593433.image ├── kernel.new.little.64.1241477300631417.image ├── slate.little.64.2010-04-10.image └── slate.little.64.2019-12-12.image ├── pkg ├── README ├── bsd │ └── Portfile ├── deb │ ├── build.sh │ ├── changelog │ └── control ├── osx │ └── Slate.packproj ├── rpm │ ├── prepare-rpm.sh │ └── slate-language.spec.template └── win │ └── setup.nsi ├── src ├── contrib │ └── st80.slate ├── core │ ├── array-bits.slate │ ├── array-bytes-extensible.slate │ ├── array-bytes.slate │ ├── array-extensible-sorted.slate │ ├── array-extensible.slate │ ├── array.slate │ ├── arrayed.slate │ ├── association.slate │ ├── boolean.slate │ ├── collection-extensible-noduplicates.slate │ ├── collection-extensible.slate │ ├── collection.slate │ ├── comparable.slate │ ├── condition-epilogue.slate │ ├── condition.slate │ ├── console.slate │ ├── debugger.slate │ ├── derivable.slate │ ├── dictionary.slate │ ├── external.slate │ ├── file.slate │ ├── integer.slate │ ├── mapping-extensible.slate │ ├── mapping.slate │ ├── method.slate │ ├── mixin.slate │ ├── namespace.slate │ ├── nil.slate │ ├── numeric.slate │ ├── print.slate │ ├── range.slate │ ├── root.slate │ ├── sequence-extensible.slate │ ├── sequence.slate │ ├── set.slate │ ├── stack.slate │ ├── stream-collections.slate │ ├── stream-positioner.slate │ ├── stream-terminals.slate │ ├── stream-transforms.slate │ ├── stream.slate │ ├── string.slate │ ├── symbol.slate │ └── types.slate ├── demo │ ├── life.slate │ ├── slate.cgi │ └── wc ├── i18n │ ├── Links1.data │ ├── Links2.data │ ├── README │ ├── TODO │ ├── UnicodeData.txt │ ├── conversion.slate │ ├── encodings-latin1.slate │ ├── encodings-unicode.slate │ ├── init.slate │ ├── layout-builder.slate │ ├── locale.slate │ ├── normalization.slate │ ├── print.slate │ ├── properties.slate │ ├── string.slate │ ├── unicodeTable.slate │ └── utils.slate ├── lib │ ├── array-words.slate │ ├── assert.slate │ ├── bag.slate │ ├── browse.slate │ ├── buffer.slate │ ├── character-collection.slate │ ├── complex.slate │ ├── concurrency.slate │ ├── continuation.slate │ ├── converter.slate │ ├── cord.slate │ ├── crossproduct.slate │ ├── database.slate │ ├── dataframe.slate │ ├── devsupport.slate │ ├── digraph.slate │ ├── dimensioned.slate │ ├── directory.slate │ ├── editor.slate │ ├── extlib.slate │ ├── format.slate │ ├── fraction.slate │ ├── glob.slate │ ├── graph.slate │ ├── group.slate │ ├── heap.slate │ ├── image.slate │ ├── immutable.slate │ ├── inspect.slate │ ├── linkedlist.slate │ ├── lookup.slate │ ├── macro.slate │ ├── mapping-compact.slate │ ├── mapping-epilogue.slate │ ├── mapping-ordered.slate │ ├── match.slate │ ├── matrix.slate │ ├── md5.slate │ ├── memoryarea.slate │ ├── method-query.slate │ ├── method.slate │ ├── module-compiled.slate │ ├── module.slate │ ├── multi-dimensional.slate │ ├── navigator.slate │ ├── numericMixin.slate │ ├── observer.slate │ ├── path.slate │ ├── pipe.slate │ ├── pipeline.slate │ ├── platform.slate │ ├── precedence.slate │ ├── predicate.slate │ ├── process.slate │ ├── profile.slate │ ├── queue.slate │ ├── random.slate │ ├── regex.slate │ ├── repetition.slate │ ├── repl.slate │ ├── ringbuffer.slate │ ├── segment.slate │ ├── sequence-insertable.slate │ ├── set-single.slate │ ├── set-sorted.slate │ ├── sharedqueue.slate │ ├── skiplist.slate │ ├── sourcedb.slate │ ├── struct.slate │ ├── subject.slate │ ├── subsequence.slate │ ├── suspension.slate │ ├── terminal.slate │ ├── test.slate │ ├── text.slate │ ├── time.slate │ ├── tokenizer.slate │ ├── trait.slate │ ├── traversal.slate │ ├── tree-binary.slate │ ├── tree.slate │ ├── trie.slate │ ├── tuple.slate │ ├── version.slate │ ├── vt220.slate │ └── xml.slate ├── llvm │ ├── compiler.slate │ ├── demo.slate │ ├── enumerations.slate │ ├── init.slate │ ├── internalcompiler.slate │ ├── irbuilder.slate │ ├── lib.slate │ ├── module.slate │ ├── name.slate │ ├── pointer.slate │ ├── type.slate │ └── value.slate ├── mobius │ ├── bootstrap-files.txt │ ├── bootstrap-final-loadable.slate │ ├── bootstrap-kernel.slate │ ├── bootstrap-post-to-load.slate │ ├── bootstrap.slate │ ├── build.slate │ ├── compiler-inlining.slate │ ├── compiler.slate │ ├── debug.slate │ ├── disassemble.slate │ ├── init.slate │ ├── map.slate │ ├── memory.slate │ ├── primitive-method.slate │ ├── rebootstrap.slate │ ├── role.slate │ └── types.slate ├── net │ ├── async.slate │ ├── http.slate │ ├── http │ │ └── status.slate │ ├── init.slate │ ├── sockets.slate │ └── uri.slate ├── old │ ├── net │ │ ├── http.slate │ │ ├── locator.slate │ │ └── socket.slate │ ├── promise.slate │ ├── promises.slate │ ├── regex.slate │ └── semaphore.slate ├── plugins │ ├── Makefile │ ├── cocoa-windows.m │ ├── gdk-wrapper.c │ ├── glib-wrapper.c │ ├── gtk-wrapper.c │ ├── llvm-lib.mk │ ├── llvm-wrapper.c │ ├── old │ │ ├── cairo.slate │ │ ├── curses.slate │ │ ├── init.slate │ │ ├── kernel.slate │ │ ├── ncurses │ │ │ ├── Makefile │ │ │ ├── configure.in │ │ │ ├── ncurses-console.c │ │ │ └── ncurses-console.h │ │ ├── posix.c │ │ ├── posix.slate │ │ ├── sc-windows.slate │ │ ├── sdl-ui.c │ │ ├── sdl-windows.c │ │ ├── sdl.c │ │ ├── sdl.h │ │ ├── slate-cairo.c │ │ ├── slate-windows.h │ │ ├── smart-console.slate │ │ ├── smart-repl.slate │ │ └── windows.slate │ └── x-windows.c ├── profiler │ ├── gprof2dot.py │ └── profpp.py ├── syntax │ ├── assignment.slate │ ├── binding.slate │ ├── cascade.slate │ ├── case.slate │ ├── inference.slate │ ├── init.slate │ ├── lexer.slate │ ├── macro.slate │ ├── node.slate │ ├── parser.slate │ ├── print.slate │ ├── quote.slate │ └── token.slate ├── text │ └── stream-processors.slate ├── ui │ ├── SDL │ │ ├── BUGS │ │ ├── CHANGES │ │ ├── README │ │ ├── core.slate │ │ ├── graphics.slate │ │ ├── init.slate │ │ ├── port.slate │ │ └── tests │ │ │ ├── evts.slate │ │ │ ├── paint.slate │ │ │ ├── test1.slate │ │ │ └── test2.slate │ ├── X11 │ │ ├── colors.slate │ │ └── port.slate │ ├── base-windows.slate │ ├── cocoa-windows.slate │ ├── color.slate │ ├── colors.slate │ ├── containers.slate │ ├── debugger.slate │ ├── demo.slate │ ├── event.slate │ ├── form.slate │ ├── gdk │ │ ├── atom.slate │ │ ├── enumerations.slate │ │ ├── event.slate │ │ ├── init.slate │ │ └── lib.slate │ ├── glib │ │ ├── boxed.slate │ │ ├── callbackdata.slate │ │ ├── callbackregistry.slate │ │ ├── closure.slate │ │ ├── enumerations.slate │ │ ├── init.slate │ │ ├── initiallyunowned.slate │ │ ├── interface.slate │ │ ├── lib.slate │ │ ├── object.slate │ │ ├── pointer.slate │ │ ├── slist.slate │ │ ├── type.slate │ │ └── value.slate │ ├── graphics.slate │ ├── gtk │ │ ├── accelerator.slate │ │ ├── accelgroup.slate │ │ ├── adjustment.slate │ │ ├── alignment.slate │ │ ├── bin.slate │ │ ├── box.slate │ │ ├── button.slate │ │ ├── cellrenderer.slate │ │ ├── cellrendererpixbuf.slate │ │ ├── cellrenderertext.slate │ │ ├── clipboard.slate │ │ ├── container.slate │ │ ├── debugger.slate │ │ ├── demo.slate │ │ ├── dialog.slate │ │ ├── enumerations.slate │ │ ├── filechooserdialog.slate │ │ ├── frame.slate │ │ ├── hbox.slate │ │ ├── hpaned.slate │ │ ├── image.slate │ │ ├── imagemenuitem.slate │ │ ├── init.slate │ │ ├── inspector.slate │ │ ├── item.slate │ │ ├── label.slate │ │ ├── lib.slate │ │ ├── liststore.slate │ │ ├── main.slate │ │ ├── menu.slate │ │ ├── menubar.slate │ │ ├── menuitem.slate │ │ ├── menushell.slate │ │ ├── messagedialog.slate │ │ ├── misc.slate │ │ ├── notebook.slate │ │ ├── object.slate │ │ ├── paned.slate │ │ ├── scrolledwindow.slate │ │ ├── separatormenuitem.slate │ │ ├── statusbar.slate │ │ ├── stockdemo.slate │ │ ├── stockitem.slate │ │ ├── textbuffer.slate │ │ ├── textiter.slate │ │ ├── textmark.slate │ │ ├── textview.slate │ │ ├── toolbar.slate │ │ ├── toolbutton.slate │ │ ├── toolitem.slate │ │ ├── treeiter.slate │ │ ├── treemodel.slate │ │ ├── treepath.slate │ │ ├── treeselection.slate │ │ ├── treestore.slate │ │ ├── treeview.slate │ │ ├── treeviewcolumn.slate │ │ ├── vbox.slate │ │ ├── vpaned.slate │ │ ├── widget.slate │ │ ├── window.slate │ │ └── workspace.slate │ ├── init.slate │ ├── inspector.slate │ ├── listbox.slate │ ├── old │ │ ├── README │ │ ├── activator.slate │ │ ├── button.slate │ │ ├── color.slate │ │ ├── colormap.slate │ │ ├── colors.slate │ │ ├── command.slate │ │ ├── contextsceneelement.slate │ │ ├── curve.slate │ │ ├── demo.slate │ │ ├── ellipse.slate │ │ ├── event.slate │ │ ├── focus.slate │ │ ├── form.slate │ │ ├── frame.slate │ │ ├── fundamental-mode.slate │ │ ├── graphics.slate │ │ ├── init.slate │ │ ├── inspector.slate │ │ ├── layout.slate │ │ ├── lines.slate │ │ ├── listbox.slate │ │ ├── listener.slate │ │ ├── medium.slate │ │ ├── menu.slate │ │ ├── morph.slate │ │ ├── path.slate │ │ ├── pen.slate │ │ ├── port.slate │ │ ├── presentation.slate │ │ ├── region.slate │ │ ├── scrollbar.slate │ │ ├── scrollpane.slate │ │ ├── spacerequirement.slate │ │ ├── text.slate │ │ ├── textbox.slate │ │ ├── theme.slate │ │ └── transform.slate │ ├── region.slate │ ├── repl.slate │ ├── textbox.slate │ └── x-windows.slate ├── unfinished │ ├── announcement.slate │ ├── build.slate │ ├── cc.slate │ ├── interval.slate │ ├── json.slate │ ├── language.slate │ ├── lazylist.slate │ ├── lzw.slate │ ├── monad.slate │ ├── objc │ │ ├── bridge.slate │ │ ├── generator.slate │ │ ├── syntax.slate │ │ ├── types.slate │ │ └── writer.slate │ ├── parsec.slate │ ├── quadtree.slate │ ├── relation.slate │ ├── rpn.slate │ ├── slot.slate │ ├── statemachine.slate │ ├── user.slate │ └── yaml.slate ├── vm │ ├── Makefile │ ├── debug.cpp │ ├── external-directory.cpp │ ├── external-files.cpp │ ├── external-library.cpp │ ├── external-memory.cpp │ ├── external-pipes.cpp │ ├── gc.cpp │ ├── gdk-wrapper.vcproj │ ├── glib-wrapper.vcproj │ ├── gtk-bindings.vcproj │ ├── gtk-wrapper.vcproj │ ├── inline.hpp │ ├── interpreter.cpp │ ├── method.cpp │ ├── misc.cpp │ ├── object.cpp │ ├── optimizer.cpp │ ├── primitives.cpp │ ├── profiler.cpp │ ├── slate.hpp │ ├── socket.cpp │ ├── vm.cpp │ ├── windows.readme.txt │ ├── windows.sln │ └── windows.vcproj └── web │ ├── cgi.slate │ ├── css.slate │ ├── dom.slate │ ├── html.slate │ ├── httpd.slate │ ├── init.slate │ ├── parsers.slate │ └── xml.slate └── tests ├── array-words.slate ├── benchmark ├── ackermann.slate ├── binarytrees.slate ├── fannkuch.slate ├── harmonic.slate ├── init.slate ├── mandelbrot.slate ├── nbody.slate ├── nsieve.slate ├── nsievebits.slate ├── pidigits.slate ├── random.slate ├── shootout.slate ├── spectralnorm.slate ├── startup.slate ├── sumfile.in ├── sumfile.slate └── takfp.slate ├── bytearray.slate ├── dictionary.slate ├── digraph.slate ├── extensibleSeq.slate ├── file.slate ├── i18n.slate ├── i18n ├── bom.utf16be.html ├── bom.utf16le.html ├── bom.utf32be.html ├── bom.utf32le.html ├── bom_utf16be.html ├── bom_utf16be.utf16.html ├── bom_utf16le.html ├── bom_utf16le.utf16.html ├── bom_utf32be.html ├── bom_utf32le.html ├── bom_utf32le.utf32.html ├── nobom.utf16be.html ├── nobom.utf16le.html ├── nobom.utf32be.html ├── nobom.utf32le.html ├── nobom_utf16be.html ├── nobom_utf16be.utf16.html ├── nobom_utf16le.html ├── nobom_utf16le.utf16.html ├── nobom_utf32be.html ├── nobom_utf32be.utf32.html ├── nobom_utf32le.html ├── nobom_utf32le.utf32.html ├── test-bom16be ├── test-bom16le ├── test-nobom16be ├── test-nobom16le └── utf8.html ├── init.slate ├── mapoverlay.slate ├── match.slate ├── matrix.slate ├── numeric.slate ├── path.slate ├── pidgin.slate ├── range.slate ├── regex.slate ├── regression ├── collection.slate ├── init.slate ├── mandelbrot.gold ├── pidigits.gold ├── shootout.slate └── wordcount.slate ├── rot13.sh ├── sequence.slate ├── skiplist.slate ├── smartconsole.slate ├── socket.slate ├── sorted.slate ├── srp.slate ├── stream.slate ├── syntax.slate ├── test.slate └── testuni.txt /.gdbinit: -------------------------------------------------------------------------------- 1 | define sym 2 | p print_symbol($arg0) 3 | end 4 | 5 | define obj 6 | p print_object(heap, $arg0) 7 | end 8 | 9 | define detail 10 | p print_detail(heap, $arg0) 11 | end 12 | 13 | define stack 14 | p print_stack($arg0) 15 | end 16 | 17 | define sl8bt 18 | p print_backtrace($arg0) 19 | end 20 | 21 | define sl8usage 22 | p print_objects($arg0) 23 | end 24 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | documentation: 2 | - 'doc/**' 3 | 4 | tools: 5 | - 'etc/**' 6 | 7 | core: 8 | - 'src/core/**' 9 | 10 | bootstrap: 11 | - 'src/bootstrap/**' 12 | 13 | test: 14 | - 'tests/**' 15 | -------------------------------------------------------------------------------- /.github/workflows/ccpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master # Push events on master branch 7 | paths: 8 | - 'src/vm/*' 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v1 17 | - name: configure 18 | run: ./configure 19 | # - name: make 20 | # run: make -I /usr/include -I /usr/local/include vm 21 | # - name: make check 22 | # run: make check 23 | -------------------------------------------------------------------------------- /.github/workflows/doc-lyx.yml: -------------------------------------------------------------------------------- 1 | name: LyX Docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | # file paths to consider in the event. Optional; defaults to all. 8 | paths: 9 | - 'doc/*' 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v1 18 | - name: Install LyX 19 | run: sudo apt-get install lyx latex2html 20 | - name: Build System Design Document 21 | run: make -C doc OUT=sysdesign 22 | - name: Build Reference Manual 23 | run: make -C doc OUT=progman 24 | -------------------------------------------------------------------------------- /.github/workflows/greetings.yml: -------------------------------------------------------------------------------- 1 | name: Greetings 2 | 3 | on: [pull_request, issues] 4 | 5 | jobs: 6 | greeting: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/first-interaction@v1 10 | with: 11 | repo-token: ${{ secrets.GITHUB_TOKEN }} 12 | issue-message: 'Thanks for paying attention to the project! We''ll try to attend to the issue appropriately and with kindness.' 13 | pr-message: 'Thanks for taking the time to request a change! We''ll try to attend to it appropriately and with kindness.' 14 | -------------------------------------------------------------------------------- /.github/workflows/label.yml: -------------------------------------------------------------------------------- 1 | # This workflow will triage pull requests and apply a label based on the 2 | # paths that are modified in the pull request. 3 | # 4 | # To use this workflow, you will need to set up a .github/labeler.yml 5 | # file with configuration. For more information, see: 6 | # https://github.com/actions/labeler/blob/master/README.md 7 | 8 | name: Pull Request Labeler 9 | on: [pull_request] 10 | 11 | jobs: 12 | label: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/labeler@v2 16 | with: 17 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 18 | configuration-path: .github/labeler.yml 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | slate 2 | .DS_Store 3 | src/vm/vm 4 | *~ 5 | *.image 6 | *.bz2 7 | *.dll 8 | *.pbx* 9 | *.perspectivev3 10 | *.exe 11 | *.ilk 12 | *.pdb 13 | *.o 14 | *.a 15 | *.la 16 | *.so 17 | .libs/ 18 | tmp/ 19 | etc/slate.1.gz 20 | etc/slate-mode.elc 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2010 Timmy Douglas, Brian T. Rice 2 | Copyright (c) 2002-2008 Lee Salzman, Brian T. Rice 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | true -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Generates new website documentation via LyX and latex2html 2 | 3 | HOST_SYSTEM := $(shell uname -s) 4 | 5 | LYX_BIN=lyx 6 | ifeq ($(HOST_SYSTEM), Darwin) 7 | LYX_BIN=/Applications/LyX.app/Contents/MacOS/lyx 8 | endif 9 | OUT=progman 10 | DIAGRAMS= #core-web collection-web stream-web 11 | DIAGRAM_OUTS=$(foreach dgm, $(DIAGRAMS), $(dgm).eps) 12 | HTML_CONVERT=latex2html -no_subdir -reuse 1 -local_icons -split 5 -show_section_numbers 13 | 14 | default: $(OUT) 15 | 16 | #Call Lyx to output LaTeX, then replace \tabularnewline's with \\'s but not 17 | #the first one (that creates a circularity which breaks TeX). 18 | $(OUT).tex: $(OUT).lyx 19 | $(LYX_BIN) -e latex $< -E latex $@ 20 | mv $@ $@.pre 21 | sed -e '24,30s/tabularnewline/ZANZIBAR/' \ 22 | -e 's/\\tabularnewline/\\\\/g' \ 23 | -e 's/ZANZIBAR/tabularnewline/1' $@.pre > $@ 24 | 25 | %.pdf: %.lyx 26 | $(LYX_BIN) -e pdf $< $@ 27 | 28 | %.ps: %.lyx 29 | $(LYX_BIN) -e ps $< $@ 30 | 31 | %.eps: %.fig %.png $(OUT)-dir 32 | fig2dev -L eps $< $@ 33 | cp $@ $(OUT)/$@ 34 | 35 | %.png: %.fig $(OUT)-dir 36 | fig2dev -L png $< $@ 37 | cp $@ $(OUT)/$@ 38 | 39 | $(OUT)-dir: 40 | install -d $(OUT)/ 41 | 42 | diagrams: $(DIAGRAM_OUTS) 43 | 44 | $(OUT): $(OUT).tex diagrams $(OUT)-dir 45 | cp $< $(OUT)/ 46 | -cp $(OUT).bib $(OUT)/ 47 | -cp $(OUT).aux $(OUT)/ 48 | $(HTML_CONVERT) $(OUT)/$< 49 | -rm $(OUT)/*.pl 50 | -rm $(OUT)/images.* 51 | -rm $(OUT)/*.tex 52 | -rm $(OUT)/WARNINGS 53 | -rm $(OUT).tar.gz 54 | tar czf $(OUT).tar.gz $(OUT)/ 55 | 56 | clean: 57 | -rm -Rf $(OUT)/ 58 | -rm $(DIAGRAM_OUTS) 59 | -rm $@.pre 60 | 61 | fullclean: clean 62 | -rm -Rf $(OUT).tex 63 | -------------------------------------------------------------------------------- /doc/object-format.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Object format (each line is a word): 4 | 5 | (object type = 0, object) 6 | 7 | [object header] 8 | [object size in words] 9 | [payload size in bytes] 10 | [pointer to map] 11 | <> 12 | 13 | (object type = 1, oop array) 14 | 15 | [object header] 16 | [object size in words] 17 | [payload size in bytes] 18 | [pointer to map] 19 | <> 20 | <> 21 | 22 | (object type = 2, byte array) 23 | 24 | [object header] 25 | [object size in words] 26 | [payload size in bytes] 27 | [pointer to map] 28 | <> 29 | <> 30 | 31 | 32 | 33 | [1] Object size in words has to be a minimum of four 34 | because it counts the header, obj size, obj payload, 35 | and map. 36 | 37 | 38 | Object header: 39 | 40 | header & 1 -> is it marked? 41 | (header>>1) & 0x7FFFFF -> object hash 42 | (header>>30) & 0x3 -> object type 43 | 44 | 45 | 46 | Object types: 47 | 48 | 0=object 49 | 1=oop array 50 | 2=byte array 51 | 52 | 53 | 54 | Pointers: 55 | 56 | If the least significant bit is 1, it's actually a smallint. 57 | Otherwise, it points to an object. 58 | 59 | The object size and payload size are not smallints because slate 60 | code cannot access them directly. 61 | -------------------------------------------------------------------------------- /doc/progman.bib: -------------------------------------------------------------------------------- 1 | 2 | @article{ ungar91organizing, 3 | author = "David Ungar and Craig Chambers and Bay-Wei Chang and Urs 4 | Holzle", 5 | title = "Organizing Programs Without Classes", 6 | journal = "Lisp and Symbolic Computation", 7 | volume = "4", 8 | number = "3", 9 | pages = "0-", 10 | year = "1991", 11 | url = "citeseer.nj.nec.com/ungar91organizing.html" } 12 | 13 | @inproceedings{ chambers92objectoriented, 14 | author = "Craig Chambers", 15 | title = "Object-oriented multi-methods in Cecil", 16 | booktitle = "Proceedings of the 6th European Conference on 17 | Object-Oriented Programming ({ECOOP})", 18 | volume = "615", 19 | publisher = "Springer-Verlag", 20 | address = "Berlin, Heidelberg, New York, Tokyo", 21 | editor = "Ole Lehrmann Madsen", 22 | isbn = "3-540-55668-0", 23 | pages = "33--56", 24 | year = "1992", 25 | url = "citeseer.nj.nec.com/174216.html" } 26 | 27 | @unpublished{ chambers95cecil, 28 | author = "Craig Chambers", 29 | title = "The {Cecil} Language Specification and Rationale: Version 30 | 2.0", 31 | year = "1995", 32 | url = "citeseer.nj.nec.com/chambers96cecil.html" } 33 | -------------------------------------------------------------------------------- /docs/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Commands/Run Script.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cd $TM_DIRECTORY ; $TM_FILEPATH 9 | input 10 | selection 11 | name 12 | Run Script 13 | output 14 | replaceSelectedText 15 | uuid 16 | 2E994C2A-2589-4198-8627-F0B82A8B594E 17 | 18 | 19 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Preferences/Indentation.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Indentation 7 | scope 8 | source.slate 9 | settings 10 | 11 | decreaseIndentPattern 12 | ^\s*(\]|\}|\))$ 13 | highlightPairs 14 | 15 | 16 | " 17 | " 18 | 19 | 20 | ( 21 | ) 22 | 23 | 24 | { 25 | } 26 | 27 | 28 | | 29 | | 30 | 31 | 32 | [ 33 | ] 34 | 35 | 36 | 37 | 38 | 39 | 40 | ' 41 | ' 42 | 43 | 44 | increaseIndentPattern 45 | ^.*(\(|\[|\{].*[^)]}"]$ 46 | shellVariables 47 | 48 | 49 | name 50 | TM_COMMENT_START 51 | value 52 | " 53 | 54 | 55 | name 56 | TM_COMMENT_END 57 | value 58 | " 59 | 60 | 61 | name 62 | TM_COMMENT_MODE 63 | value 64 | block 65 | 66 | 67 | 68 | uuid 69 | DCF79A2D-917F-4528-BC5F-4ACDF9891AB6 70 | 71 | 72 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Preferences/Typing Pairs Default.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Typing Pairs Default 7 | scope 8 | source.slate 9 | settings 10 | 11 | smartTypingPairs 12 | 13 | 14 | ' 15 | ' 16 | 17 | 18 | " 19 | " 20 | 21 | 22 | ( 23 | ) 24 | 25 | 26 | { 27 | } 28 | 29 | 30 | [ 31 | ] 32 | 33 | 34 | 35 | uuid 36 | 8B7EC0F3-2EFD-438E-AA61-0B2E9F5347FA 37 | 38 | 39 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Preferences/Typing Pairs in Blocks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Typing Pairs in Blocks 7 | scope 8 | source.slate meta.block.header.slate 9 | settings 10 | 11 | smartTypingPairs 12 | 13 | 14 | ' 15 | ' 16 | 17 | 18 | " 19 | " 20 | 21 | 22 | ( 23 | ) 24 | 25 | 26 | { 27 | } 28 | 29 | 30 | [ 31 | ] 32 | 33 | 34 | | 35 | | 36 | 37 | 38 | 39 | uuid 40 | C41BA7AC-7461-4109-A8F7-EA0D01E34616 41 | 42 | 43 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/Block Header ([).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | [${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/} ${1:variable} ${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:| )/}${2:$TM_SELECTED_TEXT} 7 | name 8 | Block Header ([) 9 | scope 10 | source.slate 11 | tabTrigger 12 | [ 13 | uuid 14 | B0B92D3F-EB78-4267-82FE-A7CCF007DEEF 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/If-then (if).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:condition} ifTrue: [$2:then] 7 | name 8 | If-then (if) 9 | scope 10 | source.slate 11 | tabTrigger 12 | if 13 | uuid 14 | 636E9DF2-03FF-41CA-B07D-75E852204BE5 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/If-then-else (ifte).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:condition} ifTrue: [$2:then] ifFalse: [$3:else] 7 | name 8 | If-then-else (ifte) 9 | scope 10 | source.slate 11 | tabTrigger 12 | ifte 13 | uuid 14 | 8EE1D866-4461-4F28-8BD7-44BC82A45ECB 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/collect (collect).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | collect: [| :${1:each}| $0] 7 | name 8 | collect (collect) 9 | scope 10 | source.slate 11 | tabTrigger 12 | collect 13 | uuid 14 | 1E3C3746-7890-4DA1-8EC1-00F7B4674611 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/define prototype (proto).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | define: #${1:NewName} &parents: {${2:parents}} 7 | &slots: {${3:slotSpecs}}. 8 | 9 | name 10 | define prototype (proto) 11 | scope 12 | source.slate 13 | tabTrigger 14 | proto 15 | uuid 16 | E66F7BD3-5916-42C3-8A4C-3A305D4B389A 17 | 18 | 19 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/do (do).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | do: [| :${1:each}| $0] 7 | name 8 | do (do) 9 | scope 10 | source.slate 11 | tabTrigger 12 | do 13 | uuid 14 | 7D1EAA3A-FEC5-450A-B905-96624F9B2182 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/doWithIndex (dowith).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | doWithIndex: [| :${1:each} :${2:index} | $0] 7 | name 8 | doWithIndex (dowith) 9 | scope 10 | source.slate 11 | tabTrigger 12 | dowith 13 | uuid 14 | 3565AA30-4471-4903-B6A0-7895F2FEA2FE 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/inject into (inject).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | inject: ${1:object} [| :${2:injection}, :${3:each}| $0] 7 | name 8 | inject into (inject) 9 | scope 10 | source.slate 11 | tabTrigger 12 | inject 13 | uuid 14 | 31B1632B-ED22-4AD7-A7CA-28297CD44DE4 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/reject (reject).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | reject: [| :${1:each}| $0] 7 | name 8 | reject (reject) 9 | scope 10 | source.slate 11 | tabTrigger 12 | reject 13 | uuid 14 | 8ABB354E-A6F2-49B0-A5EA-3A183EA32167 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/select (select).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | select: [| :${1:each}| $0] 7 | name 8 | select (select) 9 | scope 10 | source.slate 11 | tabTrigger 12 | select 13 | uuid 14 | 3A5B15C7-9B57-485F-A859-18B0E1324BD0 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/until (until).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | [${1:condition}] whileFalse: [$2:body] 7 | name 8 | until (until) 9 | scope 10 | source.slate 11 | tabTrigger 12 | until 13 | uuid 14 | 1D6BEAF5-0923-4578-A0F5-64FC579667B0 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/Snippets/while (while).plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | [${1:condition}] whileTrue: [$2:body] 7 | name 8 | while (while) 9 | scope 10 | source.slate 11 | tabTrigger 12 | while 13 | uuid 14 | D4C02FFC-D3A2-4059-B6B6-848FE1451431 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/Slate.tmbundle/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Slate 7 | ordering 8 | 9 | 2E994C2A-2589-4198-8627-F0B82A8B594E 10 | 636E9DF2-03FF-41CA-B07D-75E852204BE5 11 | 8EE1D866-4461-4F28-8BD7-44BC82A45ECB 12 | D4C02FFC-D3A2-4059-B6B6-848FE1451431 13 | 1D6BEAF5-0923-4578-A0F5-64FC579667B0 14 | 7D1EAA3A-FEC5-450A-B905-96624F9B2182 15 | 3565AA30-4471-4903-B6A0-7895F2FEA2FE 16 | 3A5B15C7-9B57-485F-A859-18B0E1324BD0 17 | 8ABB354E-A6F2-49B0-A5EA-3A183EA32167 18 | 1E3C3746-7890-4DA1-8EC1-00F7B4674611 19 | 31B1632B-ED22-4AD7-A7CA-28297CD44DE4 20 | B0B92D3F-EB78-4267-82FE-A7CCF007DEEF 21 | E66F7BD3-5916-42C3-8A4C-3A305D4B389A 22 | A7676F36-C7D2-4C3E-8519-944577C66C6A 23 | DCF79A2D-917F-4528-BC5F-4ACDF9891AB6 24 | 8B7EC0F3-2EFD-438E-AA61-0B2E9F5347FA 25 | C41BA7AC-7461-4109-A8F7-EA0D01E34616 26 | 27 | uuid 28 | C231E4DA-1A2F-4B18-8DF9-49C283D2E4C8 29 | 30 | 31 | -------------------------------------------------------------------------------- /etc/slate-startup.el: -------------------------------------------------------------------------------- 1 | (defconst slate-dir (or (getenv "SLATE_ROOT") 2 | (and load-file-name 3 | (concat (file-name-directory load-file-name) "..")) 4 | default-directory)) 5 | (if (not (boundp 'pushnew)) 6 | (defmacro pushnew (item list) 7 | (`(unless (memq (, item) (, list)) 8 | (push (, item) (, list)))))) 9 | (pushnew (concat slate-dir "/etc") load-path) 10 | (require 'slate-mode) 11 | (defconst slate-cmd (concat slate-dir "/slate")) 12 | (defconst slate-args (list "-q" "-i" (concat slate-dir "/slate.image"))) 13 | (cd slate-dir) 14 | (slate-workspace) 15 | (slate) 16 | -------------------------------------------------------------------------------- /etc/slate.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2010 Alex Suraci 2 | -- Slate LPeg Lexer 3 | 4 | module(..., package.seeall) 5 | local P, R, S = lpeg.P, lpeg.R, lpeg.S 6 | 7 | local ws = token('whitespace', space^1) 8 | 9 | -- comments 10 | local comment = token('comment', delimited_range('"', '\\')) 11 | 12 | -- strings 13 | local string = token('string', delimited_range("'", '\\')) 14 | 15 | -- chars 16 | local char = token('char', '$' * (('\\' * P(1)) + P(1))) 17 | 18 | -- numbers 19 | local number = token('number', float + integer) 20 | 21 | -- operators 22 | local op = punct - S('()"\'') + S('\\[]]') 23 | local operator = token('operator', op) 24 | 25 | -- identifiers 26 | local word = (alnum + S("._#"))^1 27 | local identifier = token('identifier', word + (':' * word)) 28 | 29 | -- symbols 30 | local symbol = token('symbol', '#' * word) 31 | 32 | -- keywords 33 | local keyword = token('slate_keyword', word * ':') 34 | 35 | -- optional keywords 36 | local optional_keyword = token('slate_optional_keyword', '&' * word * ':') 37 | 38 | -- constructors 39 | local constructor = token('type', upper * word) 40 | 41 | function LoadTokens() 42 | local slate = slate 43 | add_token(slate, 'whitespace', ws) 44 | add_token(slate, 'symbol', symbol) 45 | add_token(slate, 'slate_keyword', keyword) 46 | add_token(slate, 'slate_optional_keyword', optional_keyword) 47 | add_token(slate, 'type', constructor) 48 | add_token(slate, 'identifier', identifier) 49 | add_token(slate, 'string', string) 50 | add_token(slate, 'char', char) 51 | add_token(slate, 'comment', comment) 52 | add_token(slate, 'number', number) 53 | add_token(slate, 'operator', operator) 54 | add_token(slate, 'any_char', any_char) 55 | end 56 | 57 | function LoadStyles() 58 | add_style('symbol', style_symbol) 59 | add_style('slate_keyword', style_slate_keyword) 60 | add_style('slate_optional_keyword', style_slate_keyword) 61 | end 62 | -------------------------------------------------------------------------------- /images/kernel.new.little.32.1228690585383733.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1228690585383733.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1229184847145515.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1229184847145515.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1230788762134391.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1230788762134391.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1231010885143086.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1231010885143086.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1232382751905090.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1232382751905090.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1234233045701141.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1234233045701141.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1238346509933125.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1238346509933125.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1240611319461001.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1240611319461001.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1241193387532155.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1241193387532155.image -------------------------------------------------------------------------------- /images/kernel.new.little.32.1241477863717373.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.32.1241477863717373.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1228690000224248.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1228690000224248.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1229184296116084.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1229184296116084.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1230787833037341.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1230787833037341.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1231010025459516.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1231010025459516.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1232382035091548.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1232382035091548.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1234230732370510.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1234230732370510.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1238343921968846.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1238343921968846.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1240610406648483.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1240610406648483.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1241194365593433.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1241194365593433.image -------------------------------------------------------------------------------- /images/kernel.new.little.64.1241477300631417.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/kernel.new.little.64.1241477300631417.image -------------------------------------------------------------------------------- /images/slate.little.64.2010-04-10.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/slate.little.64.2010-04-10.image -------------------------------------------------------------------------------- /images/slate.little.64.2019-12-12.image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/images/slate.little.64.2019-12-12.image -------------------------------------------------------------------------------- /pkg/README: -------------------------------------------------------------------------------- 1 | fixme fill in the info 2 | 3 | bsd/ -> portfile 4 | 5 | win/ -> setup.nsi is for windows 6 | I think the NSIS file requires a visual C or mingw build beforehand 7 | 8 | 9 | osx/ -> packproj 10 | 11 | 12 | deb/ -> Debian packages 13 | 14 | 15 | rpm/ -> RPM packages 16 | -------------------------------------------------------------------------------- /pkg/bsd/Portfile: -------------------------------------------------------------------------------- 1 | # $Id: $ 2 | PortSystem 1.0 3 | name slate 4 | version 0.3.5 5 | categories lang 6 | platforms darwin 7 | maintainers bpt@tunes.org 8 | description A prototype-based object-oriented programming language 9 | long_description Slate is a prototype-based object-oriented \ 10 | programming language based on Self, CLOS, and \ 11 | Smalltalk-80. Slate syntax is intended to be as \ 12 | familiar as possible to a Smalltalker, for the \ 13 | clarity of messages as phrases. Unlike the Smalltalk \ 14 | family, methods within Slate can be assigned to a \ 15 | signature of objects, instead of being installed on \ 16 | one favored receiver. Slate has also many further \ 17 | expansions of the semantics which enable more \ 18 | concise and natural ways to express solutions to \ 19 | problems. 20 | homepage http://slate.tunes.org/ 21 | master_sites http://slate.tunes.org/downloads/ 22 | checksums md5 718630cd139b20081d4b6cfe0f4973d8 23 | 24 | extract.suffix .tgz 25 | configure {} 26 | #use_configure no 27 | destroot.destdir "prefix=${destroot}${prefix}" 28 | set bootstrap_image "${os.endian}.image" 29 | 30 | build.args prefix=${prefix} 31 | 32 | post-build { 33 | system "make -C ${worksrcpath}\" } 34 | 35 | destroot.destdir prefix=${destroot}${prefix} 36 | 37 | post-destroot { 38 | system "make -C ${worksrcpath} install" 39 | } 40 | -------------------------------------------------------------------------------- /pkg/deb/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo 'Building Slate package...' 4 | 5 | rm -rf slate/ 6 | 7 | mkdir -p slate/DEBIAN 8 | mkdir -p slate/usr/bin 9 | mkdir -p slate/usr/lib/slate 10 | mkdir -p slate/usr/share/man/man1 11 | mkdir -p slate/usr/share/doc/slate 12 | 13 | 14 | cp control slate/DEBIAN/ 15 | cp ../../LICENSE slate/usr/share/doc/slate/copyright 16 | cp changelog slate/usr/share/doc/slate/changelog 17 | cp ../../slate slate/usr/bin 18 | cp ../../etc/slate.1 slate/usr/share/man/man1 19 | cp ../../README slate/usr/share/doc/slate/README.Debian 20 | cp ../../full.image slate/usr/lib/slate/slate.image 21 | 22 | 23 | gzip --best slate/usr/share/man/man1/slate.1 24 | gzip --best slate/usr/share/doc/slate/changelog 25 | gzip --best slate/usr/share/doc/slate/README.Debian 26 | 27 | strip slate/usr/bin/* 28 | 29 | fakeroot dpkg-deb -b slate 30 | lintian --pedantic -v slate.deb 31 | -------------------------------------------------------------------------------- /pkg/deb/changelog: -------------------------------------------------------------------------------- 1 | slate (1.0.0) unstable; urgency=low 2 | 3 | * Initial Release. 4 | 5 | -- Timmy Douglas Wed, 21 Mar 2009 21:02:14 +0500 6 | -------------------------------------------------------------------------------- /pkg/deb/control: -------------------------------------------------------------------------------- 1 | Source: slate 2 | Section: devel 3 | Priority: optional 4 | Maintainer: Timmy Douglas 5 | Depends: libc6-dev | libc-dev 6 | Package: slate 7 | Architecture: amd64 8 | Version: 1.0.0 9 | Description: A prototype-based object-oriented programming language 10 | Slate is a prototype-based object-oriented programming language based 11 | on Self, CLOS, and Smalltalk-80. Slate syntax is intended to be as 12 | familiar as possible to a Smalltalker, for the clarity of messages as 13 | phrases. Unlike the Smalltalk family, methods within Slate can be 14 | assigned to a signature of objects, instead of being installed on one 15 | favored receiver. Slate has also many further expansions of the 16 | semantics which enable more concise and natural ways to express 17 | solutions to problems. 18 | 19 | -------------------------------------------------------------------------------- /src/contrib/st80.slate: -------------------------------------------------------------------------------- 1 | "Smalltalk-80 compatibility idioms. 2 | These exist for didactic / documentation purposes only, and should NOT be 3 | relied upon for any purpose and will NOT be supported in any way." 4 | 5 | "Globals:" 6 | 7 | #true alias: #True on: {prototypes}. 8 | #false alias: #False on: {prototypes}. 9 | #nil alias: #Nil on: {prototypes}. 10 | #Smalltalk alias: #lobby on: {lobby}. 11 | #ObjectMemory alias: #Image on: {prototypes}. "This isn't a real equivalent." 12 | 13 | "Methods:" 14 | 15 | #value alias: #do on: {Method traits}. 16 | #value: alias: #applyWith: on: {Method traits}. 17 | #value:value: alias: #applyWith:with: on: {Method traits}. 18 | #value:value:value: alias: #applyWith:with:with: on: {Method traits}. 19 | #values: alias: #applyTo: on: {Method traits}. 20 | 21 | #value: alias: #sendWith: on: {Symbol traits}. 22 | x@(Root traits) perform: selector [selector value: x]. 23 | 24 | "Collections:" 25 | 26 | #SequenceableCollection alias: #Sequence on: {collections}. 27 | #ArrayedCollection alias: #Sequence on: {collections}. 28 | #OrderedCollection alias: #ExtensibleArray on: {collections}. 29 | #SortedCollection alias: #SortedArray on: {collections}. 30 | 31 | #new: alias: #newSize: on: {collections}. 32 | 33 | c@(Collection traits) inject: init into: binBlock 34 | [c gather: binBlock &initial: init]. 35 | 36 | #reduce: alias: #gather: on: {collections}. 37 | 38 | c@(Collection traits) reduce: binBlock ifEmpty: emptyBlock 39 | [c isEmpty ifTrue: [emptyBlock do] ifFalse: [c gather: binBlock]]. 40 | -------------------------------------------------------------------------------- /src/core/array-bits.slate: -------------------------------------------------------------------------------- 1 | collections define: #BitArray &basedOn: ByteArray &parents: {ByteArray} &slots: {#bitSize -> 0}. 2 | "Uses byte-contents to implement an array of direct binary values (Booleans)." 3 | 4 | a@(BitArray traits) new &capacity: bitSize 5 | [ 6 | bitSize `defaultsTo: 0. 7 | byteSize ::= (n + 7) // 8. 8 | (a newSize: byteSize) `>> [bitSize := bitSize. ] 9 | ]. 10 | 11 | a@(BitArray traits) size [a bitSize]. 12 | a@(BitArray traits) arrayType [a]. 13 | _@(BitArray traits) elementType [Boolean]. 14 | _@(BitArray traits) defaultElement [False]. 15 | _@(BitArray traits) accepts: _ [False]. 16 | _@(BitArray traits) accepts: _@(Boolean traits) [True]. 17 | 18 | a@(BitArray traits) includesKey: i 19 | [ 20 | i < a bitSize 21 | ]. 22 | 23 | a@(BitArray traits) at: i 24 | [ 25 | (a includesKey: i) ifFalse: [^ (i keyNotFoundOn: a)]. 26 | ((a byteAt: i // 8) bitAnd: 1 << (i \\ 8)) isZero not 27 | ]. 28 | 29 | a@(BitArray traits) at: i put: bool@(Boolean traits) 30 | [ 31 | (a includesKey: i) ifFalse: [^ (i keyNotFoundOn: a)]. 32 | byteOffset ::= i // 8. 33 | bitMask ::= 1 << (i \\ 8). 34 | byte ::= a byteAt: byteOffset. 35 | a byteAt: byteOffset put: 36 | (bool 37 | ifTrue: [byte bitOr: bitMask] 38 | ifFalse: [byte bitAnd: bitMask bitNot]). 39 | bool 40 | ]. 41 | 42 | a@(BitArray traits) at: i put: obj 43 | [a cannotAccept: obj in: i]. 44 | 45 | a@(BitArray traits) at: i put: n@(Integer traits) 46 | [ 47 | n caseOf: { 48 | 0 -> [a at: i put: False]. 49 | 1 -> [a at: i put: True] 50 | } otherwise: [resend] 51 | ]. 52 | -------------------------------------------------------------------------------- /src/core/array-bytes-extensible.slate: -------------------------------------------------------------------------------- 1 | 2 | "this will call the correct #as function when converting to strings" 3 | collections define: #ExtensibleByteArray &parents: {ExtensibleArray}. 4 | ExtensibleByteArray contents := ByteArray new. 5 | 6 | es@(ExtensibleByteArray traits) elementType [SmallInteger]. 7 | 8 | es@(ExtensibleByteArray traits) as: s@(String traits) 9 | [ 10 | result ::= s newSizeOf: es. 11 | es doWithIndex: 12 | [| :each :index | result at: index put: (each as: s elementType)]. 13 | result 14 | ]. 15 | 16 | s@(ASCIIString traits) as: a@(ExtensibleByteArray traits) 17 | [ 18 | result ::= a new &capacity: s size. 19 | s do: [| :each | result add: (each as: a elementType)]. 20 | result 21 | ]. 22 | -------------------------------------------------------------------------------- /src/core/array.slate: -------------------------------------------------------------------------------- 1 | 2 | Array traitsWindow _delegates := {Mapping traits. Collection traits. Sequence traits. Array traits}. 3 | 4 | "Ensures that the primitive Array type has the behaviors and features of a 5 | Sequence." 6 | 7 | a@(Array traits) new &capacity: n 8 | "Array capacity is its size, and newSize: is a primitive." 9 | [a newSize: (n ifNil: [0])]. 10 | 11 | a@(Array traits) new* [| *rest | rest]. 12 | 13 | a@(Array traits) copy [a clone]. 14 | 15 | a@(Array traits) arrayType [a]. 16 | 17 | _@(Array traits) elementType [Root]. 18 | 19 | a@(Array traits) hasIndexedSlots [a ~== Array traits]. 20 | 21 | _@(Root traits) hasIndexedSlots [False]. 22 | -------------------------------------------------------------------------------- /src/core/arrayed.slate: -------------------------------------------------------------------------------- 1 | 2 | LexicalContext traitsWindow _delegates := 3 | {Cloneable. Root traits. Derivable traits. Cloneable traits. Mapping traits. Collection traits. Sequence traits. Array traits. LexicalContext traits}. 4 | 5 | Closure traitsWindow _delegates := 6 | {Cloneable. Root traits. Derivable traits. Cloneable traits. Mapping traits. Collection traits. Sequence traits. Array traits. Method traits. Closure traits}. 7 | 8 | "a float is a byte array, and we need to be able to call #newWithSize: to create floats in the bootstrapper." 9 | SingleFloat traitsWindow _delegates := 10 | {ByteArray traits. Sequence traits. CoercibleNumberMixin traits. Comparable traits. Number traits. Float traits. SingleFloat traits}. 11 | -------------------------------------------------------------------------------- /src/core/collection-extensible-noduplicates.slate: -------------------------------------------------------------------------------- 1 | collections define: #NoDuplicatesCollection &parents: {ExtensibleCollection}. 2 | "The collection type which holds at most one of any object as an element." 3 | "TODO: find out if some collections need to be non-extensible AND optimized 4 | for no-duplicates. (My guess is that the answer is 'no'.)" 5 | 6 | nd@(NoDuplicatesCollection traits) add: obj withOccurrences: _ 7 | [ 8 | nd include: obj 9 | ]. 10 | 11 | nd@(NoDuplicatesCollection traits) add: obj 12 | [ 13 | nd include: obj 14 | ]. 15 | 16 | nd@(NoDuplicatesCollection traits) include: obj 17 | "This is the default method for adding objects to NoDuplicatesCollection. 18 | It should be overridden in any case, but this implementation allows for any 19 | collection type to be treated as a NoDuplicatesCollection by mixing it in." 20 | [ 21 | nd add: obj ifPresent: [obj] 22 | ]. 23 | 24 | nd@(NoDuplicatesCollection traits) exclude: obj 25 | "This is the default method for removing objects from NoDuplicatesCollection. 26 | It should be overridden in any case, but this implementation allows for any 27 | collection type to be treated as a NoDuplicatesCollection by mixing it in." 28 | [nd remove: obj]. 29 | 30 | nd@(NoDuplicatesCollection traits) removeEvery: obj 31 | "Objects only occur once in these collections." 32 | [ 33 | nd remove: obj 34 | ]. 35 | 36 | nd@(NoDuplicatesCollection traits) includeAll: c 37 | [ 38 | c do: #(nd include: _) `er. 39 | ]. 40 | -------------------------------------------------------------------------------- /src/core/comparable.slate: -------------------------------------------------------------------------------- 1 | 2 | prototypes define: #Comparable &parents: {Cloneable}. 3 | "A Comparable is any object that compares linearly (<, =, >) with other like 4 | objects." 5 | 6 | "BUG: This conflicts with CoercibleNumberMixin < CoercibleNumberMixin. 7 | Some comparisons depend on the coercions to happen to see the relevant < definition. 8 | x@(Comparable traits) < y@(Comparable traits) [overrideThis]. 9 | " 10 | x@(Comparable traits) <= y@(Comparable traits) [(y < x) not]. 11 | x@(Comparable traits) >= y@(Comparable traits) [(x < y) not]. 12 | x@(Comparable traits) > y@(Comparable traits) [y < x]. 13 | 14 | x@(Comparable traits) <=> y@(Comparable traits) 15 | "Answer the sign of the difference between the two arguments." 16 | [ 17 | x < y ifTrue: [-1] 18 | ifFalse: [x = y ifTrue: [0] ifFalse: [1]] 19 | ]. 20 | 21 | x@(Comparable traits) sign 22 | "Answer the sign of the argument by comparing it with its zero element." 23 | [x <=> x zero]. 24 | 25 | x@(Comparable traits) between: min@(Comparable traits) and: max@(Comparable traits) 26 | "Return whether the first argument is between the other two." 27 | [ 28 | x >= min /\ [x <= max] 29 | ]. 30 | 31 | x@(Comparable traits) min: y@(Comparable traits) 32 | "Return the lesser argument." 33 | [ 34 | x < y ifTrue: [x] ifFalse: [y] 35 | ]. 36 | 37 | x@(Comparable traits) max: y@(Comparable traits) 38 | "Return the greater argument." 39 | [ 40 | x > y ifTrue: [x] ifFalse: [y] 41 | ]. 42 | 43 | x@(Comparable traits) min: y@(Comparable traits) max: z@(Comparable traits) 44 | [ 45 | (x min: y) max: z 46 | ]. 47 | -------------------------------------------------------------------------------- /src/core/mapping-extensible.slate: -------------------------------------------------------------------------------- 1 | collections define: #ExtensibleMapping &parents: {Mapping}. 2 | 3 | m@(ExtensibleMapping traits) add: assoc@(Association traits) 4 | "Adds a new key value pair to the ExtensibleMapping from an assocation. 5 | For example: ExtensibleMapping new `>> [ add: 'first' -> 'Joe Henry'. ]." 6 | [ 7 | m at: assoc key put: assoc value. 8 | assoc 9 | ]. 10 | 11 | m@(ExtensibleMapping traits) addAll: map@(Mapping traits) 12 | "Adds all of the key-value pairs to the ExtensibleMapping. Notice that this works 13 | for any Mapping, but that other collections will not do." 14 | [ 15 | m == map ifFalse: 16 | [map keysAndValuesDo: #(m at: _ put: _) `er]. 17 | map 18 | ]. 19 | 20 | m@(ExtensibleMapping traits) addAll: seq@(Sequence traits) 21 | [ 22 | seq doWithIndex: [| :assoc :index | 23 | (assoc isSameAs: Association) 24 | ifTrue: [m add: assoc] 25 | ifFalse: [m at: index put: assoc]]. 26 | seq 27 | ]. 28 | 29 | m@(ExtensibleMapping traits) declare: key from: e@(Mapping traits) 30 | "Add key to m, unless the key already exists. Remove key from e 31 | and move its association to m." 32 | [ 33 | (m includesKey: key) ifFalse: 34 | [(e includesKey: key) 35 | ifTrue: [m add: (e associationAt: key). 36 | e removeKey: key] 37 | ifFalse: [m add: key -> Nil]]. 38 | m 39 | ]. 40 | 41 | m@(ExtensibleMapping traits) removeKey: key ifAbsent: block 42 | [overrideThis]. 43 | 44 | m@(ExtensibleMapping traits) removeKey: key 45 | [ 46 | m removeKey: key ifAbsent: [key keyNotFoundOn: m] 47 | ]. 48 | 49 | m@(ExtensibleMapping traits) remove: key 50 | [ 51 | m removeKey: key 52 | ]. 53 | 54 | m@(ExtensibleMapping traits) remove: key ifAbsent: block 55 | [ 56 | m removeKey: key ifAbsent: block 57 | ]. 58 | -------------------------------------------------------------------------------- /src/core/mixin.slate: -------------------------------------------------------------------------------- 1 | lobby ensureNamespace: #Mixins &delegate: True. 2 | Mixins define: #Mixin &parents: {Cloneable}. 3 | 4 | Mixins define: #CollectionTypeMixin &parents: {Mixin}. 5 | CollectionTypeMixin addSlot: #kind valued: Root. 6 | "The kind of object are we specializing for." 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/core/nil.slate: -------------------------------------------------------------------------------- 1 | _@Nil isNil [True]. 2 | _@(Root traits) isNil [False]. 3 | 4 | _@Nil isNotNil [False]. 5 | _@(Root traits) isNotNil [True]. 6 | 7 | _@Nil ifNotNilDo: block [Nil]. 8 | obj@(Root traits) ifNotNilDo: block [block applyWith: obj]. 9 | 10 | _@Nil ifNil: block ifNotNil: _ [block do]. 11 | _@(Root traits) ifNil: _ ifNotNil: block [block do]. 12 | 13 | _@Nil ifNil: block ifNotNilDo: _ [block do]. 14 | obj@(Root traits) ifNil: _ ifNotNilDo: block [block applyWith: obj]. 15 | 16 | _@Nil ifNil: block [block do]. 17 | obj@(Root traits) ifNil: _ [obj]. 18 | 19 | _@Nil ifNotNil: _ [Nil]. 20 | _@(Root traits) ifNotNil: block [block do]. 21 | -------------------------------------------------------------------------------- /src/core/stack.slate: -------------------------------------------------------------------------------- 1 | collections define: #Stack &parents: {ExtensibleArray}. 2 | "An abstraction over ExtensibleArray implementations to follow the stack 3 | protocol. The convention is that the Sequence indices run least-to-greatest 4 | from bottom to top." 5 | "TODO: generalize to LIFO and abstract over the underlying implementation." 6 | 7 | s@(Stack traits) push: obj 8 | [s addLast: obj]. 9 | 10 | s@(Stack traits) pop 11 | [s removeLast]. 12 | 13 | s@(Stack traits) pop: n 14 | [s removeLast: n]. 15 | 16 | s@(Stack traits) top 17 | [s last]. 18 | 19 | s@(Stack traits) top: n 20 | [s last: n]. 21 | 22 | s@(Stack traits) bottom 23 | [s first]. 24 | 25 | s@(Stack traits) bottom: n 26 | [s first: n]. 27 | 28 | s@(Stack traits) position 29 | [s size]. 30 | 31 | s@(Stack traits) position: n 32 | [s lastIndex := s firstIndex + n - 1]. 33 | 34 | s@(Stack traits) fromTop: offset 35 | [s at: s position - offset - 1]. 36 | 37 | s@(Stack traits) fromTop: offset put: value 38 | [s at: s position - offset - 1 put: value]. 39 | 40 | s@(Stack traits) bottomToTopDo: block 41 | [s do: block]. 42 | 43 | s@(Stack traits) topToBottomDo: block 44 | [s reverseDo: block]. 45 | -------------------------------------------------------------------------------- /src/core/stream-positioner.slate: -------------------------------------------------------------------------------- 1 | streams define: #ReadStreamPositioner &parents: {ReadStream} 2 | &slots: {#buffer -> Buffer}. 3 | "Wraps a non-positionable stream and provides positioning capability by buffering read elements. Buffering strategy can be configured via different Buffer classes." 4 | 5 | s@(ReadStreamPositioner traits) isPositionable [True]. 6 | 7 | streams define: #WriteStreamPositioner &parents: {WriteStream} 8 | &slots: {#buffer -> Buffer}. 9 | "Wraps a non-positionable stream and provides positioning capability by buffering written elements. Buffering strategy can be configured via different Buffer classes." 10 | 11 | s@(WriteStreamPositioner traits) isPositionable [True]. 12 | -------------------------------------------------------------------------------- /src/demo/slate.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/slate 2 | 3 | 4 | 5 | Cgi out ; 'Content-type: text/html; charset=utf-8\r\n\r\n'. 6 | 7 | Cgi xhtml inDocumentDo: [|:w| 8 | 9 | [|:db| db connectTo: '127.0.0.1:5432'. 10 | [db loginAs: 'timmy' password: 'timmy' &database: 'mydb'. 11 | w inTag: 'p' do: [|:w| w nextPutAll: (db query: 'select * from users') printString]. 12 | 13 | ] ensure: [db close]] applyWith: DB Postgres new. 14 | 15 | 16 | w inTag: 'p' print: Cgi variables printString. 17 | 18 | w inTag: 'p' print: Cgi getValues printString. 19 | 20 | w inTag: 'p' print: Cgi postValues printString. 21 | 22 | w original ; '

'. 23 | w original ; '

' 24 | 25 | ] &head: [|:w| w inTag: 'title' print: 'No title'] 26 | &attributes: {#xmlns -> 'http://www.w3.org/1999/xhtml'. #lang -> 'en'. #xml:lang -> 'en'}. 27 | 28 | Cgi out ; '\n\n'. 29 | 30 | -------------------------------------------------------------------------------- /src/i18n/Links1.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/src/i18n/Links1.data -------------------------------------------------------------------------------- /src/i18n/Links2.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/src/i18n/Links2.data -------------------------------------------------------------------------------- /src/i18n/README: -------------------------------------------------------------------------------- 1 | 2 | To use the i18n code, first load 'src/i18n/init.slate'. Then run 3 | Unicode buildTable (which might take a few minutes). Don't forget to 4 | save the image. 5 | -------------------------------------------------------------------------------- /src/i18n/TODO: -------------------------------------------------------------------------------- 1 | 2 | * Integration to Slate 3 | * Proper hash for strings 4 | * Test normalization with the test suite provided by Unicode consortium 5 | * Full case mappings 6 | * In normalization: 7 | - isNormalizedTo: quick-checks 8 | - recomposeForForm: which trusts it's input being in NF(K)D, 9 | and not testing for isHangulLV, composing all three hangul in one pass 10 | - possibly NFC/NFKC normalization which decomposes only those that don't 11 | compose back 12 | - FCD 'normalization' (for faster collation)" 13 | * proper lexicographicallyCompare (should be renamed collateWith:) 14 | * Add more/refine Unicode subsets 15 | * Add CharacterCollection and some other things from (old) string.slate 16 | * Bidirectional rendering (probably after there is UI) 17 | * Enhance standard-compliance (x5) 18 | * Enhance efficiency 19 | 20 | Suggested reading list: 21 | 22 | Identifier and Pattern Syntax: http://www.unicode.org/reports/tr31/ 23 | Security Considerations: http://www.unicode.org/reports/tr36/ 24 | -------------------------------------------------------------------------------- /src/i18n/init.slate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/src/i18n/init.slate -------------------------------------------------------------------------------- /src/i18n/locale.slate: -------------------------------------------------------------------------------- 1 | 2 | globals ensureNamespace: #CurrentLocale. 3 | 4 | CurrentLocale define: #PrimaryLanguage -> #English. 5 | CurrentLocale define: #KanjiClass -> #Japanese. 6 | -------------------------------------------------------------------------------- /src/lib/assert.slate: -------------------------------------------------------------------------------- 1 | conditions define: #AssertionFailed &parents: {DescriptiveError}. 2 | AssertionFailed description: 'Assertion Failed'. 3 | 4 | c@(AssertionFailed traits) signalSaying: description 5 | [description ifNil: [c signal] ifNotNil: [resend]]. 6 | 7 | _ assert: m@(Method traits) &description [m do ifFalse: [AssertionFailed signalSaying: description]]. 8 | 9 | _ deny: m@(Method traits) &description [m do ifTrue: [AssertionFailed signalSaying: description]]. 10 | 11 | _ assert: _@False &description [AssertionFailed signalSaying: description]. 12 | 13 | _ assert: _@True []. 14 | 15 | x assert: expr@(Syntax Node traits) &description [x assert: expr evaluate &description: description]. 16 | 17 | node@(Syntax Node traits) assert: expr@(Syntax Node traits) 18 | "A macro which (TODO: conditionally) expands into a run-time assertion." 19 | [ 20 | Message sending: #assert: to: {node. expr} 21 | ]. 22 | -------------------------------------------------------------------------------- /src/lib/concurrency.slate: -------------------------------------------------------------------------------- 1 | 2 | "Slate based concurrency" 3 | 4 | prototypes ensureNamespace: #concurrency &delegate: True. 5 | 6 | concurrency define: #Process &parents: {Cloneable} 7 | &slots: {#pipes -> ExtensibleArray new}. 8 | 9 | 10 | p@(Process traits) forkAndDo: b 11 | [ | ret | 12 | ret := (lobby cloneSystem). 13 | ret first ifTrue: [p pipes addLast: ret second. ret second] 14 | ifFalse: [[p pipes clear. p pipes addLast: ret second. b applyWith: ret second] ensure: [lobby quit]] 15 | ]. 16 | 17 | 18 | concurrency addSlot: #currentProcess valued: Process new. 19 | -------------------------------------------------------------------------------- /src/lib/continuation.slate: -------------------------------------------------------------------------------- 1 | prototypes define: #Continuation &parents: {Cloneable} 2 | &slots: {#stackSlice -> {}}. 3 | 4 | _@(Continuation traits) current 5 | [bootstrapInterpreter stack]. 6 | -------------------------------------------------------------------------------- /src/lib/crossproduct.slate: -------------------------------------------------------------------------------- 1 | collections define: #CrossProduct &slots: {#rows -> #{}. #columns -> #{}}. 2 | 3 | rows@(Collection traits) <*> columns@(Collection traits) 4 | [ 5 | CrossProduct new `>> [rows := rows. columns := columns. ] 6 | ]. 7 | 8 | cross@(CrossProduct traits) do: block 9 | [ 10 | cross rows do: 11 | [| :row | 12 | cross columns do: 13 | [| :column | 14 | block apply*, row, column]] 15 | ]. 16 | -------------------------------------------------------------------------------- /src/lib/dataframe.slate: -------------------------------------------------------------------------------- 1 | define: #DataFrame &parents: {Cloneable} &slots: { 2 | #header -> OrderedDictionary new. 3 | #data -> ArrayMD new 4 | } 5 | -------------------------------------------------------------------------------- /src/lib/group.slate: -------------------------------------------------------------------------------- 1 | 2 | collections define: #Grouping &parents: {ExtensibleCollection} 3 | &slots: {#contents -> Dictionary new. 4 | #attributeBlock -> Method Identity}. 5 | "Similar to a Bag, storing elements given into bins keyed by the result of 6 | applying a attributeBlock to each." 7 | 8 | g@(Grouping traits) new &capacity: n 9 | [g clone `>> [contents := g contents new &capacity: n. ]]. 10 | 11 | c@(Collection traits) grouped 12 | [c groupedBy: Method Identity]. 13 | 14 | c@(Collection traits) groupedBy: keyBlock 15 | [Grouping new `>> [attributeBlock := keyBlock. addAll: c. ]]. 16 | 17 | g@(Grouping traits) add: obj 18 | [| key group | 19 | key := g attributeBlock applyWith: obj. 20 | group := g contents at: key ifAbsentPut: [Set new]. 21 | group include: obj. 22 | obj 23 | ]. 24 | 25 | g@(Grouping traits) remove: obj 26 | [| key group | 27 | key := g attributeBlock applyWith: obj. 28 | group := g contents at: key ifAbsent: [^ obj]. 29 | group remove: obj. 30 | group isEmpty ifTrue: [g contents removeKey: key]. 31 | obj 32 | ]. 33 | 34 | g@(Grouping traits) do: block 35 | "Perform the block for each occurrence of each element in the bag." 36 | [ 37 | g contents valuesDo: #(do: block) `er. 38 | g 39 | ]. 40 | 41 | collections define: #SequentialGrouping &parents: {Grouping}. 42 | "A Grouping that preserves the order of an original sequential ordering 43 | (whether from a WriteStream on the Grouping or an actual Sequence)." 44 | 45 | s@(Sequence traits) groupedBy: keyBlock 46 | [SequentialGrouping new `>> [attributeBlock := keyBlock. addAll: c. ]]. 47 | 48 | g@(SequentialGrouping traits) add: obj 49 | [| key group | 50 | key := g attributeBlock applyWith: obj. 51 | group := g contents at: key ifAbsentPut: [ExtensibleArray new]. 52 | group include: obj. 53 | obj 54 | ]. 55 | -------------------------------------------------------------------------------- /src/lib/immutable.slate: -------------------------------------------------------------------------------- 1 | x@(Root traits) immutablySettingSlots: slotArray to: valueArray 2 | "TODO: optimize this somehow to avoid the wasteful clone?" 3 | [ 4 | x isImmutable 5 | ifTrue: [x cloneSettingSlots: slotArray to: valueArray] 6 | ifFalse: [x immutably cloneSettingSlots: slotArray to: valueArray] 7 | ]. 8 | 9 | x@(Root traits) isFrozen 10 | "Whether the object and all its slot values recursively are immutable." 11 | [ 12 | x isImmutable /\ 13 | [x allSlotsDo: [| :obj | obj isImmutable ifFalse: [^ False]. True]] 14 | ]. 15 | 16 | "TODO: figure out a more systematic way to handle has-no-slots-and-never-will." 17 | x@(Oddball traits) immutably [x]. 18 | x@(Oddball traits) freeze [x]. 19 | x@(SmallInteger traits) isImmutable [True]. 20 | x@(SmallInteger traits) isFrozen [True]. 21 | 22 | x@(Root traits) freeze &seen 23 | "Make a frozen variant of the existing object, meaning an immutable version of 24 | the object with frozen variants of its slot values (and so it must recurse)." 25 | [ 26 | seen `defaultsTo: IdentityDictionary new. 27 | x isFrozen \/ [x restrictsDelegation] 28 | ifTrue: [x] 29 | ifFalse: [seen at: x ifAbsentPut: 30 | [x immutablySettingSlots: x slotNames to: 31 | (x slotValues collect: [| :obj | obj freeze &seen: seen])]] 32 | ]. 33 | -------------------------------------------------------------------------------- /src/lib/lookup.slate: -------------------------------------------------------------------------------- 1 | define: #LookupSequence &slots: {#source. #parents -> ExtensibleArray new}. 2 | "Describes the objects that the VM will consult in order when a method lookup 3 | happens. This allows introspection and interactive debugging of lookup issues. 4 | It also provides a reference implementation in Slate of the lookup algorithm 5 | without being obscured in underlying VM details and optimizations." 6 | 7 | s@(LookupSequence traits) newOn: obj 8 | [(s clone `setting: #{#source. #parents} to: {obj. s parents new}) refresh]. 9 | 10 | obj@(Root traits) lookupSequence 11 | [LookupSequence newOn: obj]. 12 | 13 | s@(LookupSequence traits) refresh 14 | [ 15 | s parents clear. 16 | (s source walker &traversal: DepthFirst &childrenVia: 17 | [| :obj | obj restrictsDelegation ifTrue: [obj delegateValues] ifFalse: [#{}]]) >> 18 | s parents writer. 19 | s 20 | ]. 21 | -------------------------------------------------------------------------------- /src/lib/match.slate: -------------------------------------------------------------------------------- 1 | _@Nil matches: _@(Root traits) [True]. 2 | _@(Root traits) matches: _@Nil [True]. 3 | 4 | _@NoRole matches: _@(Root traits) [True]. 5 | _@(Root traits) matches: _@NoRole [True]. 6 | 7 | x@(Root traits) matches: y@(Root traits) 8 | [ 9 | x == y \/ 10 | [(x isSameAs: y) 11 | /\ [x slotNames = y slotNames] 12 | /\ [x slotNames allSatisfy: 13 | [| :key | (y atSlotNamed: key) matches: (y atSlotNamed: key)]]] 14 | ]. 15 | 16 | x@(Mapping traits) matches: y@(Mapping traits) 17 | [ 18 | x == y \/ 19 | [x keySet allSatisfy: 20 | [| :key | (x at: key) matches: (y at: key)]] 21 | ]. 22 | -------------------------------------------------------------------------------- /src/lib/method.slate: -------------------------------------------------------------------------------- 1 | "Method functions that are not needed in the bootstrap process" 2 | 3 | m@(Method traits) applySome: args@(Sequence traits) 4 | "Apply a block with as many arguments as it expects." 5 | [ m applyTo: (args first: m arity) ]. 6 | -------------------------------------------------------------------------------- /src/lib/pipeline.slate: -------------------------------------------------------------------------------- 1 | streams define: #Pipeline &slots: 2 | {#components -> Set new "DiGraph?"}. 3 | 4 | "Pseudo-code derived from GStreamer, http://gstreamer.freedesktop.org." 5 | 6 | Pipeline traits define: #Element &slots: {#pads -> Dictionary new}. 7 | 8 | e1@(Pipeline Element traits) linkTo: e2@(Pipeline Element traits) 9 | [overrideThis]. 10 | 11 | e@(Pipeline Element traits) linkToAll: c 12 | [overrideThis]. 13 | 14 | e1@(Pipeline Element traits) unlink: e2@(Pipeline Element traits) 15 | [overrideThis]. 16 | 17 | e1@(Pipeline Element traits) linkPad: p1 toPad: p2 of: e2 18 | [overrideThis]. 19 | 20 | e1@(Pipeline Element traits) unlinkPad: p1 toPad: p2 of: e2 21 | [overrideThis]. 22 | 23 | e@(Pipeline Element traits) state 24 | [overrideThis]. 25 | 26 | e@(Pipeline Element traits) state: x 27 | [overrideThis]. 28 | 29 | Pipeline traits define: #Bin &parents: {OrderedTree}. 30 | "An aggregate of other Pipeline Elements." 31 | 32 | streams define: #Pad. 33 | 34 | streams define: #OutputPad &parents: {Pad}. 35 | streams define: #InputPad &parents: {Pad}. 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/lib/repetition.slate: -------------------------------------------------------------------------------- 1 | define: #Repetition &parents: {Sequence} 2 | "A Repetition is a Sequence of the same element repeated over its length." 3 | &slots: {#number. "The number of times the element occurs." 4 | #element. "The repeated element." }. 5 | 6 | r@(Repetition traits) new &capacity: n 7 | [r clone `setting: #{#number. #element} to: {n. Nil}]. 8 | 9 | r@(Repetition traits) newFor: obj sized: n 10 | [r clone `setting: #{#number. #element} to: {n. obj}]. 11 | 12 | obj@(Root traits) repeatedTimes: n 13 | "Convenient syntax to instantiate it." 14 | [Repetition newFor: obj sized: n]. 15 | 16 | r@(Repetition traits) size 17 | [r number]. 18 | 19 | r@(Repetition traits) at: index ifAbsent: block 20 | [(index between: 0 and: r number) ifTrue: [r element] ifFalse: [block do]]. 21 | 22 | r@(Repetition traits) at: index put: obj 23 | [ 24 | r element 25 | ifNil: [r element := obj] 26 | ifNotNil: [error: 'An attempt was made to modify a Repetition.'] 27 | ]. 28 | 29 | r@(Repetition traits) do: block 30 | [r number timesRepeat: [block applyWith: r element]]. 31 | 32 | r@(Repetition traits) collect: block 33 | [r collect: block into: (Array newSizeOf: r)]. 34 | 35 | c@(Repetition traits) printContentsOn: o@(PrettyPrinterMixin traits) separatedBy: block 36 | "Print out the element and occurrences like a faux multiplication." 37 | [ 38 | c element printOn: o. 39 | o ; ' x '. 40 | c number printOn: o. 41 | o 42 | ]. 43 | -------------------------------------------------------------------------------- /src/lib/set-single.slate: -------------------------------------------------------------------------------- 1 | collections define: #SingleSet &parents: {NoDuplicatesCollection} 2 | &slots: {#element -> Nil}. 3 | "SingleSets are collections which are only supposed to contain exactly one 4 | elements or be empty." 5 | 6 | ss@(SingleSet traits) accepts: _@Nil 7 | [False]. 8 | 9 | ss@(SingleSet traits) new 10 | [ss clone `setting: #{#element} to: {Nil}]. 11 | 12 | ss@(SingleSet traits) do: block 13 | [ 14 | block applyWith: ss element 15 | ]. 16 | 17 | ss@(SingleSet traits) reverseDo: block 18 | [ 19 | block applyWith: ss element 20 | ]. 21 | 22 | ss@(SingleSet traits) isEmpty 23 | [ 24 | ss element isNil 25 | ]. 26 | 27 | ss@(SingleSet traits) add: obj 28 | [ 29 | ss element ifNil: [ss element := obj] 30 | ]. 31 | 32 | ss@(SingleSet traits) remove: obj 33 | [ 34 | ss element = obj ifTrue: [ss element := Nil] 35 | ]. 36 | -------------------------------------------------------------------------------- /src/lib/set-sorted.slate: -------------------------------------------------------------------------------- 1 | define: #SortedSet &parents: {SortedArray. NoDuplicatesCollection}. 2 | 3 | s@(SortedSet traits) new 4 | [#new sendTo: {s} through: {SortedArray}]. 5 | 6 | s@(Set traits) sort 7 | [(SortedSet newSizeOf: s) `>> [addAll: s. ]]. 8 | 9 | s@(Set traits) sortBy: block 10 | "TODO: this scales up poorly." 11 | [(SortedSet newSizeOf: s) `>> [sortBlock := block. addAll: s. ]]. 12 | 13 | sc@(SortedSet traits) add: obj 14 | [ 15 | (sc includes: obj) 16 | ifFalse: [sc at: (sc indexForInserting: obj) insert: obj]. 17 | obj 18 | ]. 19 | -------------------------------------------------------------------------------- /src/lib/sharedqueue.slate: -------------------------------------------------------------------------------- 1 | collections define: #SharedQueue &parents: {ExtensibleSequence} 2 | &slots: {#mutex -> Nil. 3 | #waitq -> Nil. 4 | #inner -> Queue new}. 5 | 6 | s@(SharedQueue traits) copy 7 | [shouldNotImplement]. 8 | 9 | s@(SharedQueue traits) new 10 | [ 11 | s clone `setting: #{#mutex. #waitq. #inner} 12 | to: {Semaphore newMutex. 13 | Semaphore new. 14 | s inner new} 15 | ]. 16 | 17 | s@(SharedQueue traits) isEmpty 18 | [ 19 | s inner isEmpty 20 | ]. 21 | 22 | s@(SharedQueue traits) addLast: x 23 | [ 24 | s mutex critical: [s inner addLast: x]. 25 | s waitq signal. 26 | x 27 | ]. 28 | 29 | s@(SharedQueue traits) removeFirst 30 | [ 31 | s waitq wait. 32 | s mutex critical: [s inner removeFirst] 33 | ]. 34 | 35 | "TODO: change the Queue protocol to a mixin/trait and re-use it here:" 36 | "Queue-compatible protocol: " ( 37 | q@(Queue traits) remove [q removeFirst]. 38 | q@(Queue traits) remove: n [q removeFirst: n]. 39 | 40 | q@(Queue traits) push: obj [q add: obj]. 41 | q@(Queue traits) pop [q remove]. 42 | q@(Queue traits) pushAll: c [q addAll: c]. 43 | q@(Queue traits) pop: n [q remove: n]. 44 | ). 45 | 46 | "Producer/consumer." 47 | " 48 | load: 'src/lib/process.slate'. 49 | load: 'src/lib/semaphore.slate'. 50 | load: 'src/lib/sharedqueue.slate'. 51 | lobby define: #q -> SharedQueue new. 52 | [ 53 | [(1 to: 10) do: [|:i| q addLast: i. Scheduler yield. ]] spawn. 54 | [[q removeFirst print. Console ; '\n'] loop] spawn. 55 | ] do. 56 | " 57 | -------------------------------------------------------------------------------- /src/lib/sourcedb.slate: -------------------------------------------------------------------------------- 1 | 2 | _@lobby slurpSourceIn 3 | [ 4 | Image Definition bootstrapFilenames do: 5 | [| :fn | (File newNamed: fn) sessionDo: 6 | [| :file | 7 | inform: 'Parsing ' ; file locator printString. 8 | (Syntax Parser newOn: file reader) 9 | do: [| :tree | tree walk: 10 | [| :node | (node isSameAs: Syntax MethodDefinition) 11 | /\ [node parentScope = Syntax Lobby] ifTrue: 12 | [(node selector findOn: (node roles collect: #evaluate `er )) 13 | ifNil: [inform: node selector printString ; ' not found!'] 14 | ifNotNilDo: [| :m | m method sourceTree := node]]]]]]. 15 | ]. 16 | 17 | slurpSourceIn. 18 | -------------------------------------------------------------------------------- /src/lib/struct.slate: -------------------------------------------------------------------------------- 1 | 2 | "provides similar functionality to python's struct.pack" 3 | 4 | lobby define: #StructMixin &parents: {Cloneable} &slots: {#binaryDescription -> ExtensibleArray new}. 5 | 6 | "binaryDescription is a list of (slotName type), e.g. (width Int32)" 7 | 8 | struct@(StructMixin traits) littleEndian 9 | [ 10 | OverrideThis 11 | ]. 12 | 13 | struct@(StructMixin traits) packed &littleEndian: le 14 | [ 15 | le `defaultsTo: struct littleEndian. 16 | [| :out | 17 | struct binaryDescription do: 18 | [| :slotDescription type slot | 19 | slot := slotDescription first. 20 | type := slotDescription second. 21 | ({#Int8 -> [| :x | out next: 1 putInteger: x &littleEndian: le]. 22 | #Int16 -> [| :x | out next: 2 putInteger: x &littleEndian: le]. 23 | #Int32 -> [| :x | out next: 4 putInteger: x &littleEndian: le]. 24 | #Int64 -> [| :x | out next: 8 putInteger: x &littleEndian: le]. 25 | #CString -> [| :x | out ; (x as: out collectionType). out nextPut: 0]. 26 | #ByteArray -> [| :x | out ; x]. 27 | #Fixed -> [| :x | out ; (x as: out collectionType)]. 28 | #Struct -> [| :x | out ; (x packed &littleEndian: le)]. 29 | } firstSatisfying: [| :each | each key = type]) 30 | ifNil: [error: 'Could find method to serialize ' ; slotDescription printString] 31 | ifNotNilDo: [| :found | found value applyWith: 32 | (found key = #Fixed ifTrue: [slot] ifFalse: [struct atSlotNamed: slot])]] 33 | ] writingAs: ByteArray 34 | ]. 35 | -------------------------------------------------------------------------------- /src/lib/subject.slate: -------------------------------------------------------------------------------- 1 | 2 | "Defines some utilities and basic Subjects and Layers." 3 | 4 | m@(Method traits) layeredIn: layer seenFrom: subject 5 | "A simple composition of a Subject and a Layer." 6 | [layer layering: (m seenFrom: subject)]. 7 | 8 | m@(Method traits) objectively 9 | "A simple way to remove both Subject and Layer influences." 10 | [[m withoutSubject] withoutLayers]. 11 | -------------------------------------------------------------------------------- /src/lib/suspension.slate: -------------------------------------------------------------------------------- 1 | prototypes define: #Suspension &parents: {Cloneable} &slots: 2 | {#closure -> []. #value -> Nil}. 3 | "A suspension is a simple object that holds a closure for future evaluation. 4 | The force method returns its ultimate value transparently and immediately. 5 | This differs from the more complex Promise setup for eventual-sends." 6 | 7 | b@(Method traits) suspend 8 | "Create a new suspension to evaluate the Method." 9 | [Suspension clone `setting: #{#closure. #value} to: {b. Nil}]. 10 | 11 | s@(Suspension traits) hasEvaluated 12 | "The closure is wiped away once evaluation is successful, so we test that." 13 | [s closure isNil]. 14 | 15 | s@(Suspension traits) force 16 | "Depending on whether the Suspension has been evaluated, return the stored 17 | result or evaluate the closure and update the state before returning that 18 | result." 19 | [ 20 | s hasEvaluated 21 | ifTrue: [s value] 22 | ifFalse: 23 | [| result | 24 | result := s closure do. 25 | s closure := Nil. 26 | s value := result] 27 | ]. 28 | -------------------------------------------------------------------------------- /src/llvm/demo.slate: -------------------------------------------------------------------------------- 1 | load: 'src/llvm/init.slate'. 2 | 3 | define: #module -> (LLVM Module newWithID: 'myModule'). 4 | define: #engine -> (LLVM ExecutionEngine newWithModule: module provider). 5 | define: #builder -> LLVM IRBuilder new. 6 | define: #functionType -> (LLVM Type Function new &returnType: LLVM Type Integer32 ¶materTypes: { LLVM Type Integer32. LLVM Type Integer32 } ). 7 | define: #function -> (module addFunctionNamed: 'addFunction' type: functionType). 8 | define: #arg1 -> (function parameterAt: 0) `>> [name: 'arg1'. ]. 9 | define: #arg2 -> (function parameterAt: 1) `>> [name: 'arg2'. ]. 10 | define: #block -> (function addBlockNamed: 'entry') `>> [insertPoint: block. ]. 11 | define: #addtmp -> (builder add: arg1 <> arg2). 12 | builder ret &value: addtmp. 13 | function verify. 14 | module dump. 15 | 16 | arg1: (LLVM Type Integer32 genericValue: 7 signed: True). 17 | arg2: (LLVM Type Integer32 genericValue: 5 signed: True). 18 | inform: ((engine run: function arguments: {arg1. arg2} ) as: Integer signed: True) printString. 19 | 20 | builder dispose. 21 | engine dispose. 22 | module dispose. 23 | -------------------------------------------------------------------------------- /src/llvm/enumerations.slate: -------------------------------------------------------------------------------- 1 | ensureNamespace: #VerifierFailureAction. 2 | VerifierFailureAction AbortProcess ::= 0. 3 | VerifierFailureAction PrintMessage ::= 1. 4 | VerifierFailureAction ReturnStatus ::= 2. 5 | -------------------------------------------------------------------------------- /src/llvm/init.slate: -------------------------------------------------------------------------------- 1 | (ensureNamespace: #LLVM) `>> [ 2 | "Load LLVM library" 3 | load: 'src/llvm/lib.slate'. 4 | load: 'src/llvm/name.slate'. 5 | load: 'src/llvm/enumerations.slate'. 6 | load: 'src/llvm/pointer.slate'. 7 | load: 'src/llvm/type.slate'. 8 | load: 'src/llvm/value.slate'. 9 | load: 'src/llvm/irbuilder.slate'. 10 | load: 'src/llvm/module.slate'. 11 | 12 | "Now build the new compiler" 13 | "load: 'src/llvm/internalcompiler.slate'." 14 | load: 'src/llvm/compiler.slate'. 15 | ]. 16 | -------------------------------------------------------------------------------- /src/llvm/pointer.slate: -------------------------------------------------------------------------------- 1 | define: #Pointer &parents: {Cloneable} &slots: { 2 | #handle -> (ByteArray new &capacity: bytesPerWord) 3 | }. 4 | 5 | Pointer compareAndHashUsingSlots: #{#handle}. 6 | 7 | p@(Pointer traits) newNull [ 8 | p newWithHandle: (p handle new &capacity: bytesPerWord) 9 | ]. 10 | 11 | p@(Pointer traits) newWithHandle: h [ 12 | p cloneSettingSlots: #{#handle} to: {h} 13 | ]. 14 | 15 | -------------------------------------------------------------------------------- /src/mobius/bootstrap-files.txt: -------------------------------------------------------------------------------- 1 | src/mobius/bootstrap-kernel.slate 2 | src/core/root.slate 3 | src/core/nil.slate 4 | src/core/boolean.slate 5 | src/core/namespace.slate 6 | src/core/derivable.slate 7 | src/core/comparable.slate 8 | src/core/numeric.slate 9 | src/core/association.slate 10 | src/core/method.slate 11 | src/core/collection.slate 12 | src/core/collection-extensible.slate 13 | src/core/collection-extensible-noduplicates.slate 14 | src/core/set.slate 15 | src/core/mapping.slate 16 | src/core/sequence.slate 17 | src/core/array.slate 18 | src/core/array-bytes.slate 19 | src/core/arrayed.slate 20 | src/core/array-bits.slate 21 | src/core/integer.slate 22 | src/core/mapping-extensible.slate 23 | src/core/dictionary.slate 24 | src/core/string.slate 25 | src/core/symbol.slate 26 | src/core/range.slate 27 | src/core/sequence-extensible.slate 28 | src/core/array-extensible.slate 29 | src/core/array-bytes-extensible.slate 30 | src/core/array-extensible-sorted.slate 31 | src/core/mixin.slate 32 | src/core/stack.slate 33 | src/core/condition.slate 34 | src/core/condition-epilogue.slate 35 | src/core/stream.slate 36 | src/core/stream-collections.slate 37 | src/core/stream-transforms.slate 38 | src/core/external.slate 39 | src/core/console.slate 40 | src/core/file.slate 41 | src/core/print.slate 42 | src/core/types.slate 43 | src/syntax/init.slate 44 | src/syntax/node.slate 45 | src/syntax/token.slate 46 | src/syntax/lexer.slate 47 | src/syntax/parser.slate 48 | src/core/debugger.slate 49 | src/syntax/macro.slate 50 | src/syntax/inference.slate 51 | src/mobius/compiler.slate 52 | src/mobius/compiler-inlining.slate 53 | src/mobius/debug.slate 54 | src/mobius/bootstrap-post-to-load.slate 55 | -------------------------------------------------------------------------------- /src/mobius/init.slate: -------------------------------------------------------------------------------- 1 | #ns := ensureNamespace: #Bootstrap. 2 | ns addDelegate: globals. 3 | 4 | _@ns imports [lobby prototypes]. 5 | 6 | [| :x | ns import: x from: collections] for: { 7 | #IdentityDictionary. 8 | #ExtensibleArray. 9 | #Dictionary. 10 | }. 11 | 12 | [| :x | ns import: x from: lobby] for: { 13 | #Syntax. 14 | #VM. 15 | }. 16 | 17 | ns load: 'src/mobius/bootstrap.slate'. 18 | ns load: 'src/mobius/build.slate'. 19 | -------------------------------------------------------------------------------- /src/mobius/primitive-method.slate: -------------------------------------------------------------------------------- 1 | "Protocol for PrimitiveMethod to be usable in the same ways as CompiledMethod." 2 | 3 | m@(PrimitiveMethod traits) applyTo: args 4 | [ 5 | error: 'The Slate VM currently does not support #applyTo: calls on PrimitiveMethods.' 6 | ]. 7 | 8 | m@(PrimitiveMethod traits) method [m]. 9 | 10 | m@(PrimitiveMethod traits) acceptsAdditionalArguments [False]. 11 | "Primitives have no *rest parameters." 12 | 13 | m@(PrimitiveMethod traits) optionalKeywords [#{}]. 14 | "Primitives may take optionals, but we cannot currently communicate that." 15 | 16 | m@(PrimitiveMethod traits) arity 17 | "Use the fact that all PrimitiveMethods have selectors to determine their 18 | arity from the name." 19 | [m selector arity]. 20 | 21 | m@(PrimitiveMethod traits) literals [#{}]. 22 | m@(PrimitiveMethod traits) selectors [#{}]. 23 | m@(PrimitiveMethod traits) code [Nil]. 24 | m@(PrimitiveMethod traits) sourceTree [Nil]. 25 | m@(PrimitiveMethod traits) registerCount [m arity]. 26 | m@(PrimitiveMethod traits) inputVariables [m arity]. 27 | m@(PrimitiveMethod traits) restVariable [Nil]. 28 | m@(PrimitiveMethod traits) sourceTree [Nil]. 29 | m@(PrimitiveMethod traits) heapAllocate [False]. 30 | m@(PrimitiveMethod traits) environment [Nil]. 31 | 32 | m@(PrimitiveMethod traits) definitionLocation 33 | [ 34 | 'primitive:' ; m index printString 35 | ]. 36 | 37 | m@(PrimitiveMethod traits) allSelectorsSent [#{}]. 38 | "Answer an empty Collection since PrimitiveMethods obviously don't call any 39 | other methods, otherwise they wouldn't be primitive!" 40 | 41 | m@(PrimitiveMethod traits) allSelectorsSentToArg: _ [#{}]. 42 | "Answer an empty Collection since PrimitiveMethods obviously don't call any 43 | other methods, otherwise they wouldn't be primitive!" 44 | 45 | m@(PrimitiveMethod traits) allSelectorsSentImplicitly [#{}]. 46 | "Answer an empty Collection since PrimitiveMethods obviously don't call any 47 | other methods, otherwise they wouldn't be primitive!" 48 | -------------------------------------------------------------------------------- /src/net/init.slate: -------------------------------------------------------------------------------- 1 | load: 'src/text/regex.slate'. 2 | load: 'src/net/sockets.slate'. 3 | load: 'src/lib/converter.slate'. 4 | load: 'src/net/uri.slate'. 5 | load: 'src/net/async.slate'. 6 | load: 'src/net/http.slate'. 7 | load: 'src/lib/struct.slate'. 8 | load: 'src/lib/md5.slate'. 9 | load: 'src/lib/database.slate'. 10 | load: 'src/web/init.slate'. 11 | -------------------------------------------------------------------------------- /src/old/semaphore.slate: -------------------------------------------------------------------------------- 1 | prototypes define: #Semaphore &parents: {Cloneable} 2 | &slots: {#count -> 0. 3 | #waiters -> Queue new}. 4 | "Counting semaphore implementation. Use Semaphore new for a fresh 5 | empty semaphore, and Semaphore newMutex for a fresh semaphore for 6 | mutual-exclusion (with an initial signal)." 7 | 8 | s@(Semaphore traits) new 9 | [resend `>> [waiters: Queue new.]]. 10 | 11 | s@(Semaphore traits) newMutex 12 | [s new `>> [signal.]]. 13 | 14 | s@(Semaphore traits) signal 15 | [ 16 | Scheduler criticalSection: [ 17 | s count isZero ifTrue: [s waiters isEmpty ifFalse: [ 18 | Scheduler unblock: s waiters pop. ^ 0]]. 19 | s count: s count + 1] 20 | ]. 21 | 22 | s@(Semaphore traits) wait 23 | [ 24 | Scheduler criticalSection: [ 25 | s count isZero 26 | ifTrue: [SuspendedProcess createAndDo: [|:proc| s waiters push: proc]] 27 | ifFalse: [s count: s count - 1]]. 28 | Nil 29 | ]. 30 | 31 | s@(Semaphore traits) critical: aBlock 32 | [ 33 | s wait. 34 | aBlock ensure: [s signal] 35 | ]. 36 | 37 | "Simple example." 38 | " 39 | load: 'src/lib/process.slate'. 40 | load: 'src/lib/semaphore.slate'. 41 | [| sem | 42 | sem: Semaphore new. 43 | [ 'Hello!' print. sem signal. sem signal. ] spawn. 44 | 'Pre-first-wait.' print. 45 | sem wait. 46 | 'First!' print. 47 | sem wait. 48 | 'Second!' print. 49 | ] do. 50 | " 51 | -------------------------------------------------------------------------------- /src/plugins/Makefile: -------------------------------------------------------------------------------- 1 | 2 | slateroot=../.. 3 | 4 | include $(slateroot)/common.mk 5 | 6 | all: $(PLUGINS) 7 | $(SILENT) $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=finish $(libdir) 8 | 9 | clean: 10 | $(SILENT) rm -f $(libdir)/* *.a *.o .libs/* 11 | 12 | 13 | %.o: %.c 14 | $(SECHO) "Compiling src/plugins/$(BASENAME)/$< ($(MODE))" 15 | $(SILENT) $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=compile $(CC) $(CFLAGS) $(CFLAGS_$<) -o $@ -c $< 16 | 17 | %.o: %.m 18 | $(SECHO) "Compiling src/plugins/$(BASENAME)/$< ($(MODE))" 19 | $(SILENT) $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=compile $(CC) $(CFLAGS) $(CFLAGS_$<) -o $@ -c $< 20 | 21 | %$(LIB_SO_EXT): %.la 22 | $(SECHO) "Installing $(BASENAME) Plug-in ($(MODE))" 23 | mkdir -p `pwd`/$(libdir) 24 | $(SILENT) $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=install install $< `pwd`/$(libdir) $(SILENT_ERRORS) 25 | 26 | %.la: %.lo 27 | $(SECHO) "Linking src/plugins/$(BASENAME)/$< ($(MODE))" 28 | $(SILENT) $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=link $(CC) $(LIBS) $(LDFLAGS) $(LDFLAGS_$<) -module -o $@ $< -rpath `pwd` $(LDFLAGS) 29 | 30 | %.lo: %.c 31 | $(SECHO) "Compiling src/plugins/$(BASENAME)/$< ($(MODE))" 32 | $(SILENT) $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=compile $(CC) $(CFLAGS) $(CFLAGS_$<) -o $@ -c $< 33 | 34 | %.lo: %.m 35 | $(SECHO) "Compiling src/plugins/$(BASENAME)/$< ($(MODE))" 36 | $(SILENT) $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=compile $(CC) $(CFLAGS) $(CFLAGS_$<) -o $@ -c $< 37 | 38 | #%.o: %.c 39 | # $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=compile $(CC) $(CFLAGS) $(CFLAGS_$<) -fPIC -c -o $@ $< 40 | #$(CC) $(CFLAGS) $(CFLAGS_$<) -c -o $@ $< 41 | 42 | #%$(LIB_SO_EXT): %.o 43 | # $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=link $(CC) $(CFLAGS) -shared -fPIC $(LDFLAGS) $(LDFLAGS_$<) -o $@ $< 44 | # 45 | #clean: 46 | # $(LIBTOOL) $(LIBTOOL_FLAGS) --mode=clean rm -f *.o *.so ../../lib/*.$(LIB_SO_EXT) 47 | 48 | .PHONY: clean 49 | 50 | -------------------------------------------------------------------------------- /src/plugins/cocoa-windows.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/src/plugins/cocoa-windows.m -------------------------------------------------------------------------------- /src/plugins/gdk-wrapper.c: -------------------------------------------------------------------------------- 1 | #ifdef WIN32 2 | # define EXPORT __declspec(dllexport) 3 | #else 4 | # define EXPORT 5 | #endif 6 | 7 | #include 8 | #include _lib 9 | #include 10 | 11 | EXPORT void wrapper_gdk_lib_init( void ) { 12 | if( g_thread_supported() ) { 13 | printf("g_thread NOT supported\n"); 14 | exit(-1); 15 | } 16 | g_thread_init(NULL); 17 | gdk_threads_init(); 18 | } 19 | -------------------------------------------------------------------------------- /src/plugins/gtk-wrapper.c: -------------------------------------------------------------------------------- 1 | #ifdef WIN32 2 | # define EXPORT __declspec(dllexport) 3 | #else 4 | # define EXPORT 5 | #endif 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | EXPORT GtkTreeIter *wrapper_gtk_tree_iter_new(void) { 13 | return g_new0(GtkTreeIter, 1); 14 | } 15 | 16 | EXPORT GtkTextIter *wrapper_gtk_text_iter_new(void) { 17 | return g_new0(GtkTextIter, 1); 18 | } 19 | 20 | EXPORT GtkWidget *wrapper_gtk_dialog_get_vbox( GtkDialog *dialog ) { 21 | return dialog->vbox; 22 | } 23 | 24 | void wrapper_gtk_main( void ) { 25 | gdk_threads_enter(); //The book says to call this begore gtk_main 26 | gtk_main(); 27 | gdk_threads_leave(); 28 | } 29 | 30 | EXPORT void wrapper_gtk_lib_init( void ) { 31 | gtk_init ( 0, NULL); 32 | g_thread_create((GThreadFunc)wrapper_gtk_main, NULL, FALSE, NULL); 33 | } 34 | 35 | EXPORT gchar *wrapper_gtk_stock_item_get_stock_id( GtkStockItem *structOop ) { 36 | return structOop->stock_id; 37 | } 38 | 39 | EXPORT gchar *wrapper_gtk_stock_item_get_label( GtkStockItem *structOop ) { 40 | return structOop->label; 41 | } 42 | 43 | EXPORT gint wrapper_gtk_stock_item_get_keyval( GtkStockItem *structOop ) { 44 | return structOop->keyval; 45 | } 46 | 47 | EXPORT gint wrapper_gtk_stock_item_get_modifier( GtkStockItem *structOop ) { 48 | return structOop->modifier; 49 | } 50 | 51 | EXPORT GtkStockItem *wrapper_gtk_stock_item_new(void) { 52 | return g_new0(GtkStockItem, 1); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/plugins/llvm-lib.mk: -------------------------------------------------------------------------------- 1 | #Build llvm plugin 2 | 3 | PACKAGES = Analysis Core BitWriter 4 | 5 | lib/llvm-lib.so: 6 | g++ -shared -o lib/llvm-lib.so -Wl,-whole-archive `llvm-config --libfiles $(PACKAGES)` -Wl,-no-whole-archive 7 | 8 | clean: 9 | rm lib/llvm-lib.so 10 | -------------------------------------------------------------------------------- /src/plugins/llvm-wrapper.c: -------------------------------------------------------------------------------- 1 | #ifdef WIN32 2 | # define EXPORT __declspec(dllexport) 3 | #else 4 | # define EXPORT 5 | #endif 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "llvm-c/Analysis.h" 14 | #include "llvm-c/ExecutionEngine.h" 15 | 16 | -------------------------------------------------------------------------------- /src/plugins/old/init.slate: -------------------------------------------------------------------------------- 1 | load: 'src/plugins/smart-console/smart-console.slate'. 2 | 3 | Platform current name = 'Windows' 4 | ifTrue: [ 5 | load: 'src/plugins/windows/kernel.slate'. 6 | load: 'src/plugins/smart-console/windows.slate'. ] 7 | ifFalse: [ 8 | load: 'src/plugins/smart-console/curses.slate'. ]. 9 | 10 | load: 'src/lib/terminal.slate'. 11 | load: 'src/plugins/smart-console/smart-repl.slate'. 12 | -------------------------------------------------------------------------------- /src/plugins/old/ncurses/Makefile: -------------------------------------------------------------------------------- 1 | slateroot=../../../.. 2 | 3 | include $(slateroot)/common.mk 4 | 5 | LIBS+=-lncurses 6 | BASENAME=ncurses-console 7 | OBJS=$(BASENAME).lo 8 | 9 | include $(pluginsdir)/common.mk 10 | -------------------------------------------------------------------------------- /src/plugins/old/ncurses/configure.in: -------------------------------------------------------------------------------- 1 | # This dummy file is required for the cygwin libtool to work 2 | 3 | #AC_REQUIRE(2.52) 4 | #set path = /usr/autotool/devel/bin 5 | 6 | -------------------------------------------------------------------------------- /src/plugins/old/ncurses/ncurses-console.h: -------------------------------------------------------------------------------- 1 | #ifndef __SLATE_NCURSES_CONSOLE_H__ 2 | #define __SLATE_NCURSES_CONSOLE_H__ 3 | 4 | #include "env.h" 5 | 6 | extern int sc_isAvailable(); 7 | 8 | extern int sc_enterStructuredMode(); 9 | extern int sc_leaveStructuredMode(); 10 | 11 | extern char *sc_keySequenceOf(char *keyName); 12 | 13 | extern int sc_columns(); 14 | extern int sc_rows(); 15 | 16 | extern int sc_write(void *buffer, int size, int start); 17 | extern int sc_clear(); 18 | extern int sc_clearToEOS(); 19 | extern int sc_clearToEOL(); 20 | extern int sc_scroll(int lines); 21 | extern int sc_moveToXY(int x, int y); 22 | extern int sc_nextEvent(int blockingMillisecs); 23 | extern int sc_hasEvent(); 24 | extern int sc_flush(); 25 | extern int sc_deleteChar(); // delete char and move the rest of the line one left 26 | extern int sc_deleteLines(int lines); 27 | extern int sc_insertLines(int lines); 28 | extern int sc_hideCursor(); 29 | extern int sc_showCursor(); 30 | 31 | extern int sc_maxColorPairs(); 32 | extern int sc_initColorPair(int colorPair, int fg, int bg); 33 | extern void sc_setAttributes(int mode, int colorPair); 34 | 35 | #endif /* __SLATE_NCURSES_CONSOLE_H__ */ 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/plugins/old/posix.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int slate_CreateDirectory(const char* dirname) { 7 | //TODO: permissions. 8 | return !mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 9 | } 10 | 11 | int slate_DeleteDirectory(const char* dirname) { 12 | return !rmdir(dirname); 13 | } 14 | 15 | int slate_LinkFile(const char* pathExisting, const char* pathNew) { 16 | return !link(pathExisting, pathNew); 17 | } 18 | 19 | int slate_UnlinkFile(const char* path) { 20 | return !unlink(path); 21 | } 22 | 23 | int slate_SymbolicLinkFile(const char* pathExisting, const char* pathNew) { 24 | return !symlink(pathExisting, pathNew); 25 | } 26 | 27 | int slate_ReadSymbolicLinkInto(const char* path, char* buffer, int bufferSize) { 28 | return readlink(path, buffer, bufferSize); 29 | } 30 | 31 | int slate_RenameFile(const char* pathExisting, const char* pathNew) { 32 | return !rename(pathExisting, pathNew); 33 | } 34 | 35 | int slate_RemoveFile(const char* path) { 36 | return !remove(path); 37 | } 38 | 39 | int slate_CreateFIFO(const char* path) { 40 | return !mkfifo(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 41 | } 42 | 43 | int slate_CreateFSNode(const char* path, mode_t mode, dev_t dev) { 44 | //TODO: Make slate aware of dev_t; maybe remove other mk* API's? 45 | return !mknod(path, mode, dev); 46 | } 47 | 48 | int slate_ChangeFileModes(const char* path, mode_t mode) { 49 | return !chmod(path, mode); 50 | } 51 | 52 | int state_GetFileInfo(const char* path) { 53 | struct stat buffer; 54 | int status = stat(path, &buffer); 55 | //TODO: Decide how to pass the stat struct info. Use a ByteArray arg? 56 | return !status; 57 | } 58 | -------------------------------------------------------------------------------- /src/syntax/case.slate: -------------------------------------------------------------------------------- 1 | 2 | node@(nodes Node traits) conditions: testsToActions@(nodes CompoundStatement traits) otherwise: fallbackAction@(nodes Block traits) 3 | [| result | 4 | result := fallbackAction. 5 | (testsToActions statements copyWith: fallbackAction) reverseReduce: 6 | [| :result :assocExpr test action | 7 | test := assocExpr arguments first. 8 | action := assocExpr arguments second. 9 | (test `unquote do ifTrue: action `unquote ifFalse: 10 | (((result isSameAs: nodes Block) 11 | ifTrue: [result] 12 | ifFalse: [nodes Block newFor: result]) `unquote)) `quote] 13 | ]. 14 | 15 | node@(nodes Node traits) conditions: testsToActions@(nodes CompoundStatement traits) 16 | [node conditions: testsToActions otherwise: `[Nil]]. 17 | 18 | x@(Root traits) isCaseOf: y@(Root traits) 19 | [x = y]. 20 | 21 | x isCaseOf: y@(Collection traits) 22 | [y includes: x]. 23 | 24 | x isCaseOf: y@(Method traits) 25 | [y apply*, x]. 26 | 27 | node@(nodes Node traits) handleFirstCaseOf: casesToActions@(nodes CompoundStatement traits) otherwise: fallbackAction@(nodes Block traits) &environment: env 28 | [| tmpVar result | 29 | env ifNil: [error: 'Cannot handle cases outside of a method']. 30 | tmpVar := env addVariable. 31 | result := fallbackAction. 32 | {tmpVar store: node. 33 | (casesToActions statements copyWith: fallbackAction) reverseReduce: 34 | [| :result :assocExpr case action | 35 | case := assocExpr arguments first. 36 | action := assocExpr arguments second. 37 | (tmpVar load `unquote isCaseOf: case `unquote ifTrue: action `unquote ifFalse: 38 | (((result isSameAs: nodes Block) 39 | ifTrue: [result] 40 | ifFalse: [nodes Block newFor: result]) `unquote)) `quote]} parenthesize 41 | ]. 42 | 43 | node@(nodes Node traits) handleFirstCaseOf: casesToActions@(nodes CompoundStatement traits) &environment: env 44 | [node handleFirstCaseOf: casesToActions otherwise: `[Nil] &environment: env]. 45 | -------------------------------------------------------------------------------- /src/syntax/init.slate: -------------------------------------------------------------------------------- 1 | ensureNamespace: #Syntax &delegate: True. 2 | 3 | ns@Syntax isUnarySelector: s@(String traits) 4 | [ 5 | s isEmpty not 6 | /\ [s first isLetter 7 | \/ [s first = $_] 8 | /\ [s last ~= $:]] 9 | ]. 10 | 11 | ns@Syntax isBinarySelector: s@(String traits) 12 | [ 13 | s isEmpty not 14 | /\ [(s first `cache isLetter 15 | \/ [#{$_. $&. $%} includes: s first] 16 | \/ [s last = $:]) not] 17 | ]. 18 | 19 | ns@Syntax isKeywordSelector: s@(String traits) 20 | [s first ~= $& /\ [s last = $:]]. 21 | 22 | ns@Syntax isOptionalSelector: s@(String traits) 23 | [s first = $&]. 24 | 25 | ns@Syntax isReturnSelector: s@(String traits) 26 | [ 27 | s first = $^ /\ [s size = 1 \/ [s size = 2 /\ ['123456789^' includes: s second]]] 28 | ]. 29 | 30 | ns@Syntax keywordsOf: s@(String traits) 31 | "Answers a Sequence of substrings of the argument which are the keywords of it 32 | considered as a Slate selector." 33 | [ 34 | (ns isKeywordSelector: s) 35 | ifTrue: [(s as: '') splitWith: $:] 36 | ifFalse: [#{}] 37 | ]. 38 | 39 | ns@Syntax arityOf: s@(String traits) 40 | "Answers in a relatively safe way the number of arguments that such a Symbol 41 | would take if used as a selector. 42 | Keyword selectors take one argument per colon." 43 | [ 44 | (ns isBinarySelector: s) 45 | ifTrue: [2] 46 | ifFalse: [1 + ((ns isKeywordSelector: s) 47 | ifTrue: [s count: [| :c | c = $:]] ifFalse: [0])] 48 | ]. 49 | -------------------------------------------------------------------------------- /src/ui/SDL/BUGS: -------------------------------------------------------------------------------- 1 | Known problems 2 | -------------- 3 | -none known for now (you can help by telling me the ones 4 | I forget, like I have the feeling colors are not always correct) 5 | 6 | Concerns 7 | -------- 8 | -On Windows, names of the dll files seems different than on my 9 | Debian machine (seems to have just one file: SDL.dll, where on 10 | Debian I have many: libSDL_gfx.so, libSDL_sge.so, etc.). 11 | It is still unclear if that unique SDL.dlll file contains the 12 | functions that are in libSDL_gfx.so. 13 | I did not try to find a solution to this 'problem' yet. 14 | 15 | -------------------------------------------------------------------------------- /src/ui/SDL/init.slate: -------------------------------------------------------------------------------- 1 | load: 'src/ui/SDL/core.slate'. 2 | load: 'src/ui/SDL/graphics.slate'. 3 | 4 | SDL initModules: SDL INIT_VIDEO. 5 | 6 | SDL currentSurf: (SDL setVideoModeWithWidth: 300 height: 200 7 | bpp: 24 flags: SDL SWSURFACE). 8 | SDL screen: SDL currentSurf. 9 | -------------------------------------------------------------------------------- /src/ui/SDL/tests/paint.slate: -------------------------------------------------------------------------------- 1 | Graphics define: #Painter 2 | &slots: {#state -> #init}. 3 | 4 | Painter traits define: #states -> {#init. #up. #down. #quit}. 5 | 6 | paint@(Painter traits) start 7 | [| event | 8 | [paint state = #quit] 9 | whileFalse: 10 | [event: SDL Port next. 11 | paint handle: event]. 12 | ]. 13 | 14 | paint@(Painter traits) handle: otherEvent 15 | []. 16 | 17 | paint@(Painter traits) handle: event@(KeyboardPressEvent traits) 18 | [| sdlkey modifiers unicode | 19 | sdlkey: event key. 20 | "modifiers: event ..." 21 | sdlkey 22 | caseOf: 23 | {27 -> [paint state: #quit]}. 24 | ]. 25 | 26 | paint@(Painter traits) handle: event@(MouseButtonPressEvent traits) 27 | [paint state: #up. ]. 28 | 29 | paint@(Painter traits) handle: event@(MouseButtonReleaseEvent traits) 30 | [paint state: #down. ]. 31 | 32 | paint@(Painter traits) handle: event@(MouseMotionEvent traits) 33 | [ 34 | paint state = #down ifTrue: 35 | [event position drawOn: SDL Medium. 36 | SDL Port flush] 37 | ]. 38 | 39 | inform: 'Press Esc in the drawing window (be sure it is active) to stop'. 40 | 41 | Painter start. 42 | -------------------------------------------------------------------------------- /src/ui/SDL/tests/test1.slate: -------------------------------------------------------------------------------- 1 | sdl@(SDL traits) line1 2 | "works fine" 3 | [ 4 | sdl lineX1: 10 y1: 10 x2: 297 y2: 197. 5 | sdl lineRGBAx1: 14 y1: 10 x2: 290 y2: 197. 6 | sdl updateFullSurface: SDL currentSurf. 7 | ]. 8 | 9 | sdl@(SDL traits) box1 10 | "works fine" 11 | [ 12 | sdl boxRGBAx1: 80 y1: 10 x2: 97 y2: 97. 13 | sdl boxX1: 80 y1: 100 x2: 97 y2: 150. 14 | sdl updateFullSurface: SDL currentSurf. 15 | ]. 16 | 17 | sdl@(SDL traits) rectangle2 18 | "works fine" 19 | [ 20 | sdl rectangleRGBAx1: 10 y1: 10 x2: 97 y2: 97. 21 | sdl updateFullSurface: SDL currentSurf. 22 | ]. 23 | 24 | sdl@(SDL traits) rectangle1 25 | "works fine" 26 | [ 27 | sdl rectangleX1: 7 y1: 7 x2: 90 y2: 90. 28 | sdl updateFullSurface: SDL currentSurf. 29 | ]. 30 | 31 | sdl@(SDL traits) vline2 32 | "works fine" 33 | [ 34 | sdl vlineRGBAx: 80 y1: 10 y2: 50. 35 | sdl updateFullSurface: SDL currentSurf. 36 | ]. 37 | 38 | sdl@(SDL traits) vline1 39 | "works fine" 40 | [ 41 | sdl vlineX: 70 y1: 10 y2: 50. 42 | sdl updateFullSurface: SDL currentSurf. 43 | ]. 44 | 45 | sdl@(SDL traits) hline2 46 | "works fine" 47 | [ 48 | sdl hlineRGBAx1: 20 x2: 180 y: 15. 49 | sdl updateFullSurface: SDL currentSurf. 50 | ]. 51 | 52 | sdl@(SDL traits) hline1 53 | "works fine" 54 | [ 55 | sdl hlineX1: 20 x2: 180 y: 10. 56 | sdl updateFullSurface: SDL currentSurf. 57 | ]. 58 | 59 | sdl@(SDL traits) tryPixel1 60 | "works fine" 61 | [ 62 | sdl pixelX: 1 y: 1. 63 | sdl updateFullSurface: SDL currentSurf. 64 | ]. 65 | 66 | sdl@(SDL traits) tryCircle1 67 | "works fine" 68 | [ 69 | sdl circleRGBAx: 50 y: 50 rad: 30 &on: (sdl currentSurf) 70 | &r: 255 &g: 255 &b: 255 &a: 255. 71 | sdl updateFullSurface: SDL currentSurf. 72 | ]. 73 | 74 | sdl@(SDL traits) tryCircle2 75 | "works fine" 76 | [ 77 | sdl circleRGBAx: 60 y: 50 rad: 30. 78 | sdl updateFullSurface: SDL currentSurf. 79 | ]. 80 | -------------------------------------------------------------------------------- /src/ui/cocoa-windows.slate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/src/ui/cocoa-windows.slate -------------------------------------------------------------------------------- /src/ui/gdk/atom.slate: -------------------------------------------------------------------------------- 1 | Gdk define: #Atom &parents: {GLib Boxed}. 2 | Gdk Atom traits atSlotNamed: #printName put: 'Gdk Atom'. 3 | 4 | a@(Gdk Atom traits) new [ 5 | a shouldNotImplement 6 | ]. 7 | 8 | a@(Gdk Atom traits) newIntern: atomName@(String traits) &onlyIfExists: onlyIfExists [ 9 | onlyIfExists `defaultsTo: True. 10 | a newWithHandle: (Gdk Lib protectedDo: [ 11 | Gdk Lib primitives gdk_atom_intern applyTo: { atomName. onlyIfExists }. 12 | ]) 13 | ]. 14 | 15 | -------------------------------------------------------------------------------- /src/ui/gdk/enumerations.slate: -------------------------------------------------------------------------------- 1 | Gdk ensureNamespace: #ModifierType &delegate: False. 2 | 3 | { #ShiftMask -> 0. 4 | #LockMask -> 1. 5 | #ControlMask -> 2. 6 | #Mod1Mask -> 3. 7 | #Mod2Mask -> 4. 8 | #Mod3Mask -> 5. 9 | #Mod4Mask -> 6. 10 | #Mod5Mask -> 7. 11 | #Button1Mask -> 8. 12 | #Button2Mask -> 9. 13 | #Button3Mask -> 10. 14 | #Button4Mask -> 11. 15 | #Button5Mask -> 12. 16 | #SuperMask -> 26. 17 | #HyperMask -> 27. 18 | #MetaMask -> 28. 19 | #ReleaseMask -> 30 20 | } do: [ | :assoc | 21 | Gdk ModifierType addImmutableSlot: assoc key valued: (1 << (assoc value)) 22 | ]. 23 | 24 | Gdk ModifierType addImmutableSlot: #ModifierMask valued: 16r5c001fff. 25 | -------------------------------------------------------------------------------- /src/ui/gdk/event.slate: -------------------------------------------------------------------------------- 1 | Gdk define: #Event &parents: {GLib Boxed}. 2 | Gdk Event traits atSlotNamed: #printName put: 'Gdk Event'. 3 | 4 | e@(Gdk Event traits) new [ 5 | e shouldNotImplement 6 | ]. 7 | 8 | -------------------------------------------------------------------------------- /src/ui/gdk/init.slate: -------------------------------------------------------------------------------- 1 | "First Load GLib library" 2 | load: 'src/ui/glib/init.slate'. 3 | 4 | "Load GDK library" 5 | lobby ensureNamespace: #Gdk &delegate: False. 6 | 7 | load: 'src/ui/gdk/lib.slate'. 8 | 9 | "Load gdk" 10 | load: 'src/ui/gdk/enumerations.slate'. 11 | load: 'src/ui/gdk/atom.slate'. 12 | load: 'src/ui/gdk/event.slate'. 13 | -------------------------------------------------------------------------------- /src/ui/gdk/lib.slate: -------------------------------------------------------------------------------- 1 | 2 | Gdk define: #LibNames &builder: 3 | [Dictionary new*, 4 | 'Win32' -> (Dictionary new* 5 | , 'gdk-wrapper' -> 'gdk-wrapper' 6 | , 'gdk' -> 'libgdk-win32-2.0-0'). 7 | 'Linux' -> (Dictionary new* 8 | , 'gdk-wrapper' -> 'gdk-wrapper' 9 | , 'gdk' -> 'libgdk-x11-2.0')]. 10 | 11 | Gdk define: #LibWrapper -> ( 12 | ExternalInterface newForLibrary: ((Gdk LibNames at: Platform current name) at: 'gdk-wrapper') primitives: q{ 13 | (Void wrapper_gdk_lib_init()) 14 | 15 | } 16 | ). 17 | 18 | Gdk LibWrapper enable. 19 | 20 | l@(Gdk LibWrapper traits) init [ 21 | l primitives wrapper_gdk_lib_init do. 22 | ]. 23 | 24 | Gdk define: #Lib -> ( 25 | ExternalInterface newForLibrary: ((Gdk LibNames at: Platform current name) at: 'gdk') primitives: q{ 26 | 27 | (Void gdk_threads_enter()) 28 | (Void gdk_threads_leave()) 29 | (Void gdk_flush()) 30 | 31 | (Pointer gdk_atom_intern(CString Boolean)) 32 | } 33 | ). 34 | 35 | Gdk Lib enable. 36 | 37 | l@(Gdk Lib traits) protectedDo: block 38 | [| r | 39 | l primitives gdk_threads_enter do. 40 | r := block do. 41 | l primitives gdk_flush do. 42 | l primitives gdk_threads_leave do. 43 | r 44 | ]. 45 | -------------------------------------------------------------------------------- /src/ui/glib/boxed.slate: -------------------------------------------------------------------------------- 1 | GLib define: #Boxed &parents: {GLib Pointer}. 2 | GLib Boxed traits atSlotNamed: #printName put: 'GLib Boxed'. 3 | 4 | _@(GLib Boxed traits) gType [ 5 | GLib FundamentalType Boxed 6 | ]. 7 | 8 | -------------------------------------------------------------------------------- /src/ui/glib/callbackdata.slate: -------------------------------------------------------------------------------- 1 | GLib define: #CallbackData &parents: {GLib Pointer}. 2 | GLib CallbackData traits atSlotNamed: #printName put: 'GLib CallbackData'. 3 | " 4 | struct: CallbackData 5 | gint blockID; 6 | gint parameterCount; 7 | GValue* parameters[]; 8 | " 9 | cd@(GLib CallbackData traits) blockID [ 10 | GLib LibWrapper primitives wrapper_g_callback_data_get_block_id applyTo: { cd handle } 11 | ]. 12 | 13 | cd@(GLib CallbackData traits) parameterCount [ 14 | GLib LibWrapper primitives wrapper_g_callback_data_get_parameter_count applyTo: { cd handle } 15 | ]. 16 | 17 | cd@(GLib CallbackData traits) parameterAt: index [ 18 | GLib Value newWithHandle: ( 19 | GLib LibWrapper primitives wrapper_g_callback_data_get_parameter_at applyTo: { cd handle. index } 20 | ) 21 | ]. 22 | 23 | cd@(GLib CallbackData traits) parameterArray [ 24 | | size array param | 25 | size: cd parameterCount. 26 | array: (Array newSize: size). 27 | 0 below: size do: [ | :i | 28 | param: (cd parameterAt: i). 29 | array at: i put: param value. 30 | ]. 31 | array 32 | ]. 33 | 34 | cd@(GLib CallbackData traits) waitNext [ 35 | cd newWithHandle: GLib LibWrapper primitives wrapper_g_callback_wait_next do 36 | ]. 37 | 38 | cd@(GLib CallbackData traits) end [ 39 | GLib LibWrapper primitives wrapper_g_callback_end applyTo: { cd handle } 40 | ]. 41 | 42 | 43 | _@(GLib CallbackData traits) initQueue [ 44 | GLib LibWrapper primitives wrapper_g_callback_queue_init do. 45 | ]. 46 | 47 | _@(GLib CallbackData traits) shutdownQueue [ 48 | GLib LibWrapper primitives wrapper_g_callback_queue_shutdown do. 49 | ]. -------------------------------------------------------------------------------- /src/ui/glib/closure.slate: -------------------------------------------------------------------------------- 1 | GLib define: #Closure &parents: {GLib Pointer}. 2 | GLib Closure traits atSlotNamed: #printName put: 'GLib Closure'. 3 | 4 | c@(GLib Closure traits) newWithID: id@(Number traits) [ 5 | c newWithHandle: ( GLib LibWrapper primitives wrapper_g_cclosure_new applyTo: { id } ) 6 | ]. 7 | 8 | c@(GLib Closure traits) newWithBlock: aBlock [ 9 | c newWithID: (GLib CallbackRegistry register: aBlock) 10 | ]. 11 | -------------------------------------------------------------------------------- /src/ui/glib/enumerations.slate: -------------------------------------------------------------------------------- 1 | 2 | GLib ensureNamespace: #FundamentalType &delegate: False. 3 | 4 | GLib GObjectLib primitives g_type_init do. 5 | 6 | { #Invalid -> 0. 7 | #None -> 1. 8 | #Interface -> 2. 9 | #Char -> 3. 10 | #UChar -> 4. 11 | #Boolean -> 5. 12 | #Int -> 6. 13 | #UInt -> 7. 14 | #Long -> 8. 15 | #ULong -> 9. 16 | #Int64 -> 10. 17 | #UInt64 -> 11. 18 | #Enum -> 12. 19 | #Flags -> 13. 20 | #Float -> 14. 21 | #Double -> 15. 22 | #String -> 16. 23 | #Pointer -> 17. 24 | #Boxed -> 18. 25 | #Param -> 19. 26 | #Object -> 20. 27 | #Type -> (GLib GObjectLib primitives g_gtype_get_type do) 28 | } do: [ | :assoc | 29 | GLib FundamentalType addImmutableSlot: assoc key valued: (GLib Type newWithType: ((assoc value) << 2 "G_TYPE_FUNDAMENTAL_SHIFT")) 30 | ]. 31 | 32 | "define type conversions for library traits" 33 | 34 | _@(Integer traits) gType [ 35 | GLib FundamentalType Int 36 | ]. 37 | 38 | _@(Float traits) gType [ 39 | GLib FundamentalType Float 40 | ]. 41 | 42 | _@(Boolean traits) gType [ 43 | GLib FundamentalType Boolean 44 | ]. 45 | 46 | _@(String traits) gType [ 47 | GLib FundamentalType String 48 | ]. 49 | 50 | _@(ASCIICharacter traits) gType [ 51 | GLib FundamentalType Char 52 | ]. 53 | -------------------------------------------------------------------------------- /src/ui/glib/init.slate: -------------------------------------------------------------------------------- 1 | "Expand slate world" 2 | load: 'src/lib/array-words.slate'. 3 | 4 | "Load Glib library" 5 | lobby ensureNamespace: #GLib &delegate: False. 6 | 7 | load: 'src/ui/glib/lib.slate'. 8 | load: 'src/ui/glib/type.slate'. 9 | load: 'src/ui/glib/enumerations.slate'. 10 | load: 'src/ui/glib/pointer.slate'. 11 | load: 'src/ui/glib/closure.slate'. 12 | load: 'src/ui/glib/object.slate'. 13 | load: 'src/ui/glib/initiallyunowned.slate'. 14 | load: 'src/ui/glib/interface.slate'. 15 | load: 'src/ui/glib/boxed.slate'. 16 | load: 'src/ui/glib/value.slate'. 17 | load: 'src/ui/glib/slist.slate'. 18 | load: 'src/ui/glib/callbackdata.slate'. 19 | load: 'src/ui/glib/callbackregistry.slate'. 20 | 21 | -------------------------------------------------------------------------------- /src/ui/glib/initiallyunowned.slate: -------------------------------------------------------------------------------- 1 | GLib define: #InitiallyUnowned &parents: {GLib Object}. 2 | GLib InitiallyUnowned traits atSlotNamed: #printName put: 'GLib InitiallyUnowned'. 3 | 4 | -------------------------------------------------------------------------------- /src/ui/glib/interface.slate: -------------------------------------------------------------------------------- 1 | GLib define: #Interface &parents: {GLib Pointer}. 2 | GLib Interface traits atSlotNamed: #printName put: 'GLib Interface'. 3 | 4 | _@(GLib Interface traits) gType [ 5 | GLib FundamentalType Interface 6 | ]. 7 | -------------------------------------------------------------------------------- /src/ui/glib/pointer.slate: -------------------------------------------------------------------------------- 1 | GLib define: #Pointer &parents: {Cloneable} &slots: {#handle}. 2 | GLib Pointer traits atSlotNamed: #printName put: 'GLib Pointer'. 3 | 4 | "GLib Pointer traits define: #registry &builder: [IdentitySet new]." 5 | GLib Pointer compareAndHashUsingSlots: #{#handle}. 6 | 7 | p@(GLib Pointer traits) newNull [ 8 | p newWithHandle: (ByteArray new &capacity: bytesPerWord) 9 | ]. 10 | 11 | p@(GLib Pointer traits) newWithHandle: h [ 12 | p cloneSettingSlots: #{#handle} to: {h} 13 | ]. 14 | 15 | _@(GLib Pointer traits) gType [ 16 | GLib FundamentalType Pointer 17 | ]. 18 | " 19 | p@(GLib Pointer traits) register [ 20 | p registry addLast: 21 | ]. 22 | " 23 | p@(GLib Pointer traits) as: _@(String traits) [ 24 | GLib LibWrapper primitives wraper_g_pointer_as_string applyTo: {p handle} 25 | ]. 26 | 27 | p@(GLib Pointer traits) free [ 28 | GLib Lib primitives g_free applyTo: {p handle} 29 | ]. 30 | -------------------------------------------------------------------------------- /src/ui/glib/slist.slate: -------------------------------------------------------------------------------- 1 | GLib define: #SList &parents: {GLib Pointer}. 2 | GLib SList traits atSlotNamed: #printName put: 'GLib SList'. 3 | 4 | sl@(GLib SList traits) free [ 5 | GLib Lib primitives g_slist_free applyTo: { sl handle }. 6 | ]. 7 | 8 | sl@(GLib SList traits) at: index@(Number traits) [ 9 | GLib Pointer newWithHandle: ( 10 | GLib Lib primitives g_slist_nth_data applyTo: { sl handle. index } 11 | ) 12 | ]. 13 | 14 | sl@(GLib SList traits) size [ 15 | GLib Lib primitives g_slist_length applyTo: { sl handle } 16 | ]. 17 | 18 | -------------------------------------------------------------------------------- /src/ui/glib/type.slate: -------------------------------------------------------------------------------- 1 | GLib define: #Type &parents: {Cloneable} &slots: {#type}. 2 | GLib Type traits atSlotNamed: #printName put: 'GLib Type'. 3 | 4 | GLib Type compareAndHashUsingSlots: #{#type}. 5 | 6 | t@(GLib Type traits) newWithType: arg 7 | [ 8 | t cloneSettingSlots: #{#type} to: {arg} 9 | ]. 10 | 11 | t@(GLib Type traits) newWithType: arg value: _ 12 | [ 13 | t cloneSettingSlots: #{#type} to: {arg} 14 | ]. 15 | 16 | _@(GLib Type traits) gType 17 | [ 18 | GLib FundamentalType Type 19 | ]. 20 | 21 | t@(GLib Type traits) isFundamentalType 22 | [ 23 | GLib LibWrapper primitives wrapper_g_type_is_fundamental applyTo: {t type} 24 | ]. 25 | 26 | t@(GLib Type traits) fundamentalType 27 | [| aType | 28 | t isFundamentalType 29 | ifTrue: [t] 30 | ifFalse: [ 31 | aType: (GLib LibWrapper primitives wrapper_g_type_fundamental applyTo: {t type} ). 32 | GLib Type newWithType: aType 33 | ] 34 | ]. 35 | 36 | t@(GLib Type traits) name 37 | [ 38 | GLib GObjectLib primitives g_type_name applyTo: {t type} 39 | ]. 40 | -------------------------------------------------------------------------------- /src/ui/gtk/accelerator.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Accelerator &builder: [Oddball clone]. 2 | _@(Gtk Accelerator) printName [ 'Gtk Accelerator' ]. 3 | 4 | a@(Gtk Accelerator) nameFromKey: key@(Number traits) modifier: modifier@(Number traits) [ 5 | Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_accelerator_name applyTo: {key. modifier} 7 | ] 8 | ]. 9 | 10 | a@(Gtk Accelerator) labelFromKey: key@(Number traits) modifier: modifier@(Number traits) [ 11 | Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_accelerator_get_label applyTo: {key. modifier} 13 | ] 14 | ]. 15 | 16 | a@(Gtk Accelerator) defaultModifierMask [ 17 | Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_accelerator_get_default_mod_mask do 19 | ] 20 | ]. 21 | 22 | a@(Gtk Accelerator) defaultModifierMask: modifier@(Number traits) [ 23 | Gdk Lib protectedDo: [ 24 | Gtk Lib primitives gtk_accelerator_set_default_mod_mask applyTo: {modifier} 25 | ] 26 | ]. 27 | -------------------------------------------------------------------------------- /src/ui/gtk/accelgroup.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #AccelGroup &parents: {GLib Object}. 2 | Gtk AccelGroup traits atSlotNamed: #printName put: 'Gtk AccelGroup'. 3 | 4 | ag@(Gtk AccelGroup traits) new [ 5 | ag newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_accel_group_new do 7 | ]) 8 | ]. 9 | 10 | ag@(Gtk AccelGroup traits) connectKey: key@(Number traits) modifier: modifier@(Number traits) flags: flags@(Number traits) closure: closure@(GLib Closure traits) [ 11 | (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_accel_group_connect applyTo: { ag handle. key. modifier. flags. closure handle } 13 | ]). 14 | ag 15 | ]. 16 | 17 | ag@(Gtk AccelGroup traits) connectKey: key@(Number traits) modifier: modifier@(Number traits) flags: flags@(Number traits) do: block [ 18 | ag connectKey: key modifier: modifier flags: flags closure: (GLib Closure newWithBlock: block) 19 | ]. 20 | 21 | ag@(Gtk AccelGroup traits) connectKey: key@(Number traits) modifier: modifier@(Number traits) flags: flags@(Number traits) send: selector to: object [ 22 | ag connectKey: key modifier: modifier flags: flags do: [ | *parameters | selector sendTo: ( {object} ; parameters ) ] 23 | ]. 24 | -------------------------------------------------------------------------------- /src/ui/gtk/adjustment.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Adjustment &parents: {Gtk Object}. 2 | Gtk Adjustment traits atSlotNamed: #printName put: 'Gtk Adjustment'. 3 | 4 | a@(Gtk Adjustment traits) new [ 5 | a shouldNotImplement 6 | ]. 7 | 8 | a@(Gtk Adjustment traits) newWithValue: value lower: lower upper: upper step_increment: step_increment page_increment: page_increment page_size: page_size [ 9 | a newWithHandle: (Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_adjustment_new applyTo: {value. lower. upper. step_increment. page_increment. page_size } 11 | ]) 12 | ]. 13 | 14 | -------------------------------------------------------------------------------- /src/ui/gtk/alignment.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Alignment &parents: {Gtk Bin}. 2 | Gtk Alignment traits atSlotNamed: #printName put: 'Gtk Alignment'. 3 | 4 | a@(Gtk Alignment traits) new [ 5 | a shouldNotImplement 6 | ]. 7 | 8 | a@(Gtk Alignment traits) newWithAlign: align@(Tuple traits) &scale: scale [ 9 | scale `defaultsTo: (0.0 <> 0.0). 10 | a newWithHandle: (Gdk Lib protectedDo: [ 11 | Gtk Lib primitives gtk_alignment_new applyTo: {align first. align second. scale first. scale second} 12 | ]) 13 | ]. 14 | 15 | -------------------------------------------------------------------------------- /src/ui/gtk/bin.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Bin &parents: {Gtk Container}. 2 | Gtk Bin traits atSlotNamed: #printName put: 'Gtk Bin'. 3 | 4 | b@(Gtk Bin traits) new [ 5 | b shouldNotImplement 6 | ]. 7 | -------------------------------------------------------------------------------- /src/ui/gtk/button.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Button &parents: {Gtk Bin}. 2 | Gtk Button traits atSlotNamed: #printName put: 'Gtk Button'. 3 | 4 | b@(Gtk Button traits) new [ 5 | f newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_button_new do 7 | ]) 8 | ]. 9 | 10 | b@(Gtk Button traits) newWithLabel: label [ 11 | b newWithHandle: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_button_new_with_label applyTo: {label} 13 | ]) 14 | ]. 15 | 16 | b@(Gtk Button traits) newFromStock: stockId@(String traits) [ 17 | b newWithHandle: (Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_button_new_from_stock applyTo: {stockId} 19 | ]) 20 | ]. 21 | -------------------------------------------------------------------------------- /src/ui/gtk/cellrenderer.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #CellRenderer &parents: {Gtk Object}. 2 | Gtk CellRenderer traits atSlotNamed: #printName put: 'Gtk CellRenderer'. 3 | 4 | cr@(Gtk CellRenderer traits) new [ 5 | cr shouldNotImplement 6 | ]. 7 | 8 | -------------------------------------------------------------------------------- /src/ui/gtk/cellrendererpixbuf.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #CellRendererPixbuf &parents: {Gtk CellRenderer}. 2 | Gtk CellRendererPixbuf traits atSlotNamed: #printName put: 'Gtk CellRendererPixbuf'. 3 | 4 | crp@(Gtk CellRendererPixbuf traits) new [ 5 | crp newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_cell_renderer_pixbuf_new do 7 | ]) 8 | ]. 9 | -------------------------------------------------------------------------------- /src/ui/gtk/cellrenderertext.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #CellRendererText &parents: {Gtk CellRenderer}. 2 | Gtk CellRendererText traits atSlotNamed: #printName put: 'Gtk CellRendererText'. 3 | 4 | crt@(Gtk CellRendererText traits) new [ 5 | crt newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_cell_renderer_text_new do 7 | ]) 8 | ]. 9 | -------------------------------------------------------------------------------- /src/ui/gtk/clipboard.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Clipboard &parents: {GLib Object}. 2 | Gtk Clipboard traits atSlotNamed: #printName put: 'Gtk Clipboard'. 3 | 4 | c@(Gtk Clipboard traits) new [ 5 | c shouldNotImplement 6 | ]. 7 | 8 | c@(Gtk Clipboard traits) newWith: selection@(Gdk Atom traits) [ 9 | c newWithHandle: (Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_clipboard_get applyTo: {selection handle} 11 | ]) 12 | ]. 13 | -------------------------------------------------------------------------------- /src/ui/gtk/container.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Container &parents: {Gtk Widget}. 2 | Gtk Container traits atSlotNamed: #printName put: 'Gtk Container'. 3 | 4 | c@(Gtk Container traits) new [ 5 | c shouldNotImplement 6 | ]. 7 | 8 | c@(Gtk Container traits) borderWidth: width [ 9 | Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_container_set_border_width applyTo: {c handle. width} 11 | ]. 12 | c 13 | ]. 14 | 15 | c@(Gtk Container traits) add: widget@(Gtk Widget traits) [ 16 | Gdk Lib protectedDo: [ 17 | Gtk Lib primitives gtk_container_add applyTo: {c handle. widget handle} 18 | ]. 19 | c 20 | ]. 21 | 22 | -------------------------------------------------------------------------------- /src/ui/gtk/demo.slate: -------------------------------------------------------------------------------- 1 | load: 'src/ui/gtk/init.slate'. 2 | Gtk Main sessionDo: [ Gtk Workspace new show ]. 3 | -------------------------------------------------------------------------------- /src/ui/gtk/dialog.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Dialog &parents: {Gtk Window}. 2 | Gtk Dialog traits atSlotNamed: #printName put: 'Gtk Dialog'. 3 | 4 | d@(Gtk Dialog traits) new [ 5 | d newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_dialog_new do 7 | ]) 8 | ]. 9 | 10 | d@(Gtk Dialog traits) newWithFlags: flags &title: title &parent: parent [ 11 | | parentHandle | 12 | parentHandle: (parent ifNil: [ Nil ] ifNotNil: [ parent handle ]). 13 | d newWithHandle: (Gdk Lib protectedDo: [ 14 | Gtk Lib primitives gtk_dialog_new_with_buttons applyTo: {title. parentHandle. flags. Nil } 15 | ]) 16 | ]. 17 | 18 | "This method is not compatible with the way that the wrapper is implemented 19 | d@(Gtk Dialog traits) run [ 20 | Gdk Lib protectedDo: [ 21 | Gtk Lib primitives gtk_dialog_run applyTo: { d handle }. 22 | ] 23 | ]." 24 | 25 | d@(Gtk Dialog traits) addButton: text@(String traits) responseId: responseId@(Integer traits) [ 26 | Gtk Button newWithHandle: (Gdk Lib protectedDo: [ 27 | Gtk Lib primitives gtk_dialog_add_button applyTo: { d handle. text. responseId }. 28 | ]) 29 | ]. 30 | 31 | d@(Gtk Dialog traits) vBox [ 32 | Gtk VBox newWithHandle: (Gdk Lib protectedDo: [ 33 | Gtk LibWrapper primitives wrapper_gtk_dialog_get_vbox applyTo: { d handle } 34 | ]) 35 | ]. 36 | 37 | -------------------------------------------------------------------------------- /src/ui/gtk/filechooserdialog.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #FileChooserDialog &parents: {Gtk Dialog}. 2 | Gtk FileChooserDialog traits atSlotNamed: #printName put: 'Gtk FileChooserDialog'. 3 | 4 | fcd@(Gtk FileChooserDialog traits) new [ 5 | fcd shouldNotImplement 6 | ]. 7 | 8 | fcd@(Gtk FileChooserDialog traits) newWithAction: action &title: title &parent: parent [ 9 | | parentHandle | 10 | parentHandle: (parent ifNil: [ Nil ] ifNotNil: [ parent handle ]). 11 | fcd newWithHandle: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_file_chooser_dialog_new applyTo: {title. parentHandle. action. Nil } 13 | ]) 14 | ]. 15 | 16 | fcd@(Gtk FileChooserDialog traits) newOpen &title: title &parent: parent [ 17 | fcd newWithAction: Gtk FileChooserAction Open &title: title &parent: parent 18 | ]. 19 | 20 | fcd@(Gtk FileChooserDialog traits) newSave &title: title &parent: parent [ 21 | fcd newWithAction: Gtk FileChooserAction Save &title: title &parent: parent 22 | ]. 23 | 24 | fcd@(Gtk FileChooserDialog traits) newSelectFolder &title: title &parent: parent [ 25 | fcd newWithAction: Gtk FileChooserAction SelectFolder &title: title &parent: parent 26 | ]. 27 | 28 | fcd@(Gtk FileChooserDialog traits) newCreateFolder &title: title &parent: parent [ 29 | fcd newWithAction: Gtk FileChooserAction CreateFolder &title: title &parent: parent 30 | ]. 31 | 32 | fcd@(Gtk FileChooserDialog traits) fileName [ 33 | Gdk Lib protectedDo: [ 34 | Gtk Lib primitives gtk_file_chooser_get_filename applyTo: {fcd handle } 35 | ] 36 | ]. 37 | 38 | fcd@(Gtk FileChooserDialog traits) fileName: fileName@(String traits) [ 39 | Gdk Lib protectedDo: [ 40 | Gtk Lib primitives gtk_file_chooser_set_filename applyTo: {fcd handle. fileName } 41 | ] 42 | ]. 43 | -------------------------------------------------------------------------------- /src/ui/gtk/frame.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Frame &parents: {Gtk Bin}. 2 | Gtk Frame traits atSlotNamed: #printName put: 'Gtk Frame'. 3 | 4 | f@(Gtk Frame traits) new [ 5 | f newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_frame_new do 7 | ]) 8 | ]. 9 | 10 | f@(Gtk Frame traits) label: label@(String traits) [ 11 | (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_frame_set_label applyTo: { f handle. label } 13 | ]). 14 | f 15 | ]. 16 | 17 | f@(Gtk Frame traits) newWithLabel: label@(String traits) child: child@(Gtk Widget traits) [ 18 | (f new label: label) add: child 19 | ]. 20 | -------------------------------------------------------------------------------- /src/ui/gtk/hbox.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #HBox &parents: {Gtk Box}. 2 | Gtk HBox traits atSlotNamed: #printName put: 'Gtk HBox'. 3 | 4 | hb@(Gtk HBox traits) new &homogeneous: homogeneous &spacing: spacing [ 5 | | hBox | 6 | "Creates a new GtkHBox. 7 | homogeneous: true if all children are to be given equal space allotments. 8 | spacing: the number of pixels to place by default between children." 9 | homogeneous `defaultsTo: False. 10 | spacing `defaultsTo: 0. 11 | hb newWithHandle: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_hbox_new applyTo: { homogeneous. spacing } 13 | ]) 14 | ]. 15 | 16 | -------------------------------------------------------------------------------- /src/ui/gtk/hpaned.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #HPaned &parents: {Gtk Paned}. 2 | Gtk HPaned traits atSlotNamed: #printName put: 'Gtk HPaned'. 3 | 4 | hp@(Gtk HPaned traits) new [ 5 | hp newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_hpaned_new do 7 | ]) 8 | ]. 9 | -------------------------------------------------------------------------------- /src/ui/gtk/image.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Image &parents: {Gtk Misc}. 2 | Gtk Image traits atSlotNamed: #printName put: 'Gtk Image'. 3 | 4 | i@(Gtk Image traits) new [ 5 | i newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_image_new do 7 | ]) 8 | ]. 9 | 10 | i@(Gtk Image traits) newFromStock: stockId@(String traits) size: size@(Number traits) [ 11 | i newWithHandle: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_image_new_from_stock applyTo: {stockId. size} 13 | ]) 14 | ]. 15 | 16 | i@(Gtk Image traits) stock: stockId@(String traits) size: size@(Number traits) [ 17 | i newWithHandle: (Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_image_set_from_stock applyTo: {i handle. stockId. size} 19 | ]). 20 | i 21 | ]. 22 | -------------------------------------------------------------------------------- /src/ui/gtk/imagemenuitem.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #ImageMenuItem &parents: {Gtk MenuItem}. 2 | Gtk ImageMenuItem traits atSlotNamed: #printName put: 'Gtk ImageMenuItem'. 3 | 4 | imi@(Gtk ImageMenuItem traits) new [ 5 | imi newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_image_menu_item_new do 7 | ]) 8 | ]. 9 | 10 | imi@(Gtk ImageMenuItem traits) newWithMnemonic: mnemonic@(String traits) [ 11 | "Creates a new GtkMenuItem containing a label. The label will be created using 12 | gtk_label_new_with_mnemonic(), so underscores in label indicate the mnemonic for the menu item." 13 | imi newWithHandle: (Gdk Lib protectedDo: [ 14 | Gtk Lib primitives gtk_image_menu_item_new_with_mnemonic applyTo: {mnemonic} 15 | ]) 16 | ]. 17 | 18 | imi@(Gtk ImageMenuItem traits) newWithLabel: label@(String traits) [ 19 | imi newWithHandle: (Gdk Lib protectedDo: [ 20 | Gtk Lib primitives gtk_image_menu_item_new_with_label applyTo: {label} 21 | ]) 22 | ]. 23 | 24 | imi@(Gtk ImageMenuItem traits) newFromStock: stockID@(String traits) &accelGroup: accelGroup [ 25 | | accelGroupHandle | 26 | accelGroup ifNotNil: [ accelGroupHandle: accelGroup handle ]. 27 | imi newWithHandle: (Gdk Lib protectedDo: [ 28 | Gtk Lib primitives gtk_image_menu_item_new_from_stock applyTo: { stockID. accelGroupHandle } 29 | ]) 30 | ]. 31 | 32 | -------------------------------------------------------------------------------- /src/ui/gtk/item.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Item &parents: {Gtk Bin}. 2 | Gtk Item traits atSlotNamed: #printName put: 'Gtk Item'. 3 | 4 | i@(Gtk Item traits) new [ 5 | i shouldNotImplement 6 | ]. 7 | 8 | -------------------------------------------------------------------------------- /src/ui/gtk/label.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Label &parents: {Gtk Misc}. 2 | Gtk Label traits atSlotNamed: #printName put: 'Gtk Label'. 3 | 4 | l@(Gtk Label traits) new &text: text [ 5 | l newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_label_new applyTo: {text} 7 | ]) 8 | ]. 9 | 10 | l@(Gtk Label traits) newWithMnemonic: mnemonic [ 11 | l newWithHandle: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_label_new_with_mnemonic applyTo: {mnemonic} 13 | ]) 14 | ]. 15 | 16 | l@(Gtk Label traits) useUnderline: useUnderline@(Boolean traits) [ 17 | Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_label_set_use_underline applyTo: {l handle. useUnderline} 19 | ]. 20 | l 21 | ]. 22 | 23 | l@(Gtk Label traits) useUnderline [ 24 | Gdk Lib protectedDo: [ 25 | Gtk Lib primitives gtk_label_get_use_underline applyTo: {l handle} 26 | ] 27 | ]. 28 | 29 | l@(Gtk Label traits) label: label@(String traits) [ 30 | Gdk Lib protectedDo: [ 31 | Gtk Lib primitives gtk_label_set_label applyTo: {l handle. label} 32 | ]. 33 | l 34 | ]. 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/ui/gtk/menu.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Menu &parents: {Gtk MenuShell}. 2 | Gtk Menu traits atSlotNamed: #printName put: 'Gtk Menu'. 3 | 4 | m@(Gtk Menu traits) new [ 5 | m newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_menu_new do 7 | ]) 8 | ]. 9 | 10 | m@(Gtk Menu traits) createMenuItem: mnemonic [ 11 | | menuItem | 12 | "Creates a menu item with the given label and attach self as its submenu" 13 | menuItem: (Gtk MenuItem newWithMnemonic: mnemonic). 14 | menuItem submenu: m. 15 | menuItem 16 | ]. 17 | 18 | m@(Gtk Menu traits) appendSeparator [ 19 | m append: Gtk SeparatorMenuItem new. 20 | ]. 21 | 22 | -------------------------------------------------------------------------------- /src/ui/gtk/menubar.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #MenuBar &parents: {Gtk MenuShell}. 2 | Gtk MenuBar traits atSlotNamed: #printName put: 'Gtk MenuBar'. 3 | 4 | mb@(Gtk MenuBar traits) new [ 5 | mb newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_menu_bar_new do 7 | ]) 8 | ]. 9 | -------------------------------------------------------------------------------- /src/ui/gtk/menuitem.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #MenuItem &parents: {Gtk Item}. 2 | Gtk MenuItem traits atSlotNamed: #printName put: 'Gtk MenuItem'. 3 | 4 | mi@(Gtk MenuItem traits) new [ 5 | mi newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_menu_item_new do 7 | ]) 8 | ]. 9 | 10 | mi@(Gtk MenuItem traits) newWithMnemonic: mnemonic [ 11 | "Creates a new GtkMenuItem containing a label. The label will be created using 12 | gtk_label_new_with_mnemonic(), so underscores in label indicate the mnemonic for the menu item." 13 | mi newWithHandle: (Gdk Lib protectedDo: [ 14 | Gtk Lib primitives gtk_menu_item_new_with_mnemonic applyTo: {mnemonic} 15 | ]) 16 | ]. 17 | 18 | mi@(Gtk MenuItem traits) submenu: submenu [ 19 | (Gdk Lib protectedDo: [ 20 | Gtk Lib primitives gtk_menu_item_set_submenu applyTo: { mi handle. submenu handle } 21 | ]). 22 | ]. 23 | 24 | -------------------------------------------------------------------------------- /src/ui/gtk/menushell.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #MenuShell &parents: {Gtk Container}. 2 | Gtk MenuShell traits atSlotNamed: #printName put: 'Gtk MenuShell'. 3 | 4 | ms@(Gtk MenuShell traits) new [ 5 | ms shouldNotImplement 6 | ]. 7 | 8 | ms@(Gtk MenuShell traits) append: child [ 9 | (Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_menu_shell_append applyTo: { ms handle. child handle } 11 | ]). 12 | ]. 13 | 14 | -------------------------------------------------------------------------------- /src/ui/gtk/messagedialog.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #MessageDialog &parents: {Gtk Dialog}. 2 | Gtk MessageDialog traits atSlotNamed: #printName put: 'Gtk MessageDialog'. 3 | 4 | md@(Gtk MessageDialog traits) new [ 5 | md shouldNotImplement 6 | ]. 7 | 8 | md@(Gtk MessageDialog traits) newWithFlags: flags type: type buttons: buttons &message: message &parent: parent [ 9 | | parentHandle | 10 | parentHandle: (parent ifNil: [ Nil ] ifNotNil: [ parent handle ]). 11 | md newWithHandle: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_message_dialog_new applyTo: {parentHandle. flags. type. buttons. message } 13 | ]) 14 | ]. 15 | 16 | md@(Gtk MessageDialog traits) newErrorMessage: message &parent: parent [ 17 | md newWithFlags: Gtk DialogFlags Modal 18 | type: Gtk MessageType Error 19 | buttons: Gtk ButtonsType Ok 20 | &message: message &parent: parent 21 | ]. 22 | 23 | md@(Gtk MessageDialog traits) newInfoMessage: message &parent: parent [ 24 | md newWithFlags: Gtk DialogFlags Modal 25 | type: Gtk MessageType Info 26 | buttons: Gtk ButtonsType Ok 27 | &message: message &parent: parent 28 | ]. 29 | 30 | md@(Gtk MessageDialog traits) newQuestionMessage: message &parent: parent [ 31 | md newWithFlags: Gtk DialogFlags Modal 32 | type: Gtk MessageType Question 33 | buttons: Gtk ButtonsType YesNo 34 | &message: message &parent: parent 35 | ]. 36 | 37 | md@(Gtk MessageDialog traits) newWarningMessage: message &parent: parent [ 38 | md newWithFlags: Gtk DialogFlags Modal 39 | type: Gtk MessageType Warning 40 | buttons: Gtk ButtonsType Ok 41 | &message: message &parent: parent 42 | ]. 43 | -------------------------------------------------------------------------------- /src/ui/gtk/misc.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Misc &parents: {Gtk Widget}. 2 | Gtk Misc traits atSlotNamed: #printName put: 'Gtk Misc'. 3 | 4 | -------------------------------------------------------------------------------- /src/ui/gtk/notebook.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Notebook &parents: {Gtk Container}. 2 | Gtk Notebook traits atSlotNamed: #printName put: 'Gtk Notebook'. 3 | 4 | n@(Gtk Notebook traits) new [ 5 | n newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_notebook_new do 7 | ]) 8 | ]. 9 | 10 | n@(Gtk Notebook traits) appendPage: child@(Gtk Widget traits) label: tabLabel@(Gtk Widget traits) [ 11 | Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_notebook_append_page applyTo: {n handle. child handle. tabLabel handle } 13 | ] 14 | ]. 15 | 16 | n@(Gtk Notebook traits) appendPage: child@(Gtk Widget traits) [ 17 | Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_notebook_append_page applyTo: {n handle. child handle. Nil } 19 | ] 20 | ]. 21 | 22 | n@(Gtk Notebook traits) appendPage: child@(Gtk Widget traits) label: tabLabel@(String traits) [ 23 | n appendPage: child label: (Gtk Label newWithMnemonic: tabLabel) 24 | ]. 25 | -------------------------------------------------------------------------------- /src/ui/gtk/object.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Object &parents: {GLib InitiallyUnowned}. 2 | Gtk Object traits atSlotNamed: #printName put: 'Gtk Object'. 3 | 4 | o@(Gtk Object traits) new [ 5 | o shouldNotImplement 6 | ]. 7 | 8 | -------------------------------------------------------------------------------- /src/ui/gtk/paned.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Paned &parents: {Gtk Container}. 2 | Gtk Paned traits atSlotNamed: #printName put: 'Gtk Paned'. 3 | 4 | p@(Gtk Paned traits) new [ 5 | p shouldNotImplement 6 | ]. 7 | 8 | p@(Gtk Paned traits) packFirst: child resize: resize shrink: shrink [ 9 | Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_paned_pack1 applyTo: {p handle. child handle. resize. shrink} 11 | ]. 12 | p 13 | ]. 14 | 15 | p@(Gtk Paned traits) packSecond: child resize: resize shrink: shrink [ 16 | Gdk Lib protectedDo: [ 17 | Gtk Lib primitives gtk_paned_pack2 applyTo: {p handle. child handle. resize. shrink} 18 | ]. 19 | p 20 | ]. 21 | 22 | p@(Gtk Paned traits) addFirst: child [ 23 | Gdk Lib protectedDo: [ 24 | Gtk Lib primitives gtk_paned_add1 applyTo: {p handle. child handle } 25 | ]. 26 | p 27 | ]. 28 | 29 | p@(Gtk Paned traits) addSecond: child [ 30 | Gdk Lib protectedDo: [ 31 | Gtk Lib primitives gtk_paned_add2 applyTo: {p handle. child handle} 32 | ]. 33 | p 34 | ]. 35 | 36 | p@(Gtk Paned traits) first: first second: second [ 37 | p addFirst: first. 38 | p addSecond: second. 39 | p 40 | ]. 41 | -------------------------------------------------------------------------------- /src/ui/gtk/scrolledwindow.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #ScrolledWindow &parents: {Gtk Bin}. 2 | Gtk ScrolledWindow traits atSlotNamed: #printName put: 'Gtk ScrolledWindow'. 3 | 4 | sw@(Gtk ScrolledWindow traits) new &hAdjustment: hAdjustment &vAdjustment: vAdjustment [ 5 | | scrolledWindow hAdjustmentHandle vAdjustmentHandle | 6 | hAdjustment `defaultsTo: Nil. 7 | hAdjustmentHandle: (hAdjustment ifNil: [Nil] ifNotNil: [ hAdjustment handle ]). 8 | vAdjustment `defaultsTo: Nil. 9 | vAdjustmentHandle: (vAdjustment ifNil: [Nil] ifNotNil: [ vAdjustment handle ]). 10 | sw newWithHandle: (Gdk Lib protectedDo: [ 11 | Gtk Lib primitives gtk_scrolled_window_new applyTo: {hAdjustmentHandle. vAdjustmentHandle } 12 | ]) 13 | ]. 14 | 15 | sw@(Gtk ScrolledWindow traits) hScrollbarPolicy: aGtkHPolicyType vScrollbarPolicy: aGtkVPolicyType [ 16 | (Gdk Lib protectedDo: [ 17 | Gtk Lib primitives gtk_scrolled_window_set_policy applyTo: { sw handle. aGtkHPolicyType. aGtkVPolicyType } 18 | ]) 19 | ]. 20 | 21 | sw@(Gtk ScrolledWindow traits) newWithChild: child [ 22 | | scrolledWindow | 23 | scrolledWindow: sw new. 24 | scrolledWindow hScrollbarPolicy: Gtk PolicyType Automatic vScrollbarPolicy: Gtk PolicyType Automatic. 25 | scrolledWindow add: child. 26 | scrolledWindow 27 | ]. 28 | 29 | -------------------------------------------------------------------------------- /src/ui/gtk/separatormenuitem.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #SeparatorMenuItem &parents: {Gtk MenuItem}. 2 | Gtk SeparatorMenuItem traits atSlotNamed: #printName put: 'Gtk SeparatorMenuItem'. 3 | 4 | smi@(Gtk SeparatorMenuItem traits) new [ 5 | smi newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_separator_menu_item_new do 7 | ]) 8 | ]. 9 | 10 | -------------------------------------------------------------------------------- /src/ui/gtk/statusbar.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Statusbar &parents: {Gtk HBox}. 2 | Gtk Statusbar traits atSlotNamed: #printName put: 'Gtk Statusbar'. 3 | 4 | sb@(Gtk Statusbar traits) new [ 5 | sb newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_statusbar_new do 7 | ]) 8 | ]. 9 | 10 | -------------------------------------------------------------------------------- /src/ui/gtk/textiter.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TextIter &parents: {GLib Pointer}. 2 | Gtk TextIter traits atSlotNamed: #printName put: 'Gtk TextIter'. 3 | 4 | ti@(Gtk TextIter traits) new [ 5 | ti newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk LibWrapper primitives wrapper_gtk_text_iter_new do 7 | ]) 8 | ]. 9 | 10 | ti@(Gtk TextIter traits) line [ 11 | Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_text_iter_get_line applyTo: { ti handle } 13 | ] 14 | ]. 15 | 16 | ti@(Gtk TextIter traits) offset [ 17 | Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_text_iter_get_offset applyTo: { ti handle } 19 | ] 20 | ]. 21 | 22 | ti@(Gtk TextIter traits) line: line [ 23 | Gdk Lib protectedDo: [ 24 | Gtk Lib primitives gtk_text_iter_set_line applyTo: { ti handle. line } 25 | ]. 26 | ti 27 | ]. 28 | 29 | ti@(Gtk TextIter traits) forwardToEnd [ 30 | Gdk Lib protectedDo: [ 31 | Gtk Lib primitives gtk_text_iter_forward_to_end applyTo: { ti handle } 32 | ]. 33 | ti 34 | ]. 35 | 36 | ti@(Gtk TextIter traits) forwardToLineEnd [ 37 | Gdk Lib protectedDo: [ 38 | Gtk Lib primitives gtk_text_iter_forward_to_line_end applyTo: { ti handle } 39 | ]. 40 | ti 41 | ]. 42 | 43 | -------------------------------------------------------------------------------- /src/ui/gtk/textmark.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TextMark &parents: {GLib Object}. 2 | Gtk TextMark traits atSlotNamed: #printName put: 'Gtk TextMark'. 3 | 4 | tm@(Gtk TextMark traits) new &name: name &leftGravity: leftGravity [ 5 | leftGravity `defaultsTo: False. 6 | tm newWithHandle: (Gdk Lib protectedDo: [ 7 | Gtk Lib primitives gtk_text_mark_new applyTo: { name. leftGravity } 8 | ]) 9 | ]. 10 | 11 | -------------------------------------------------------------------------------- /src/ui/gtk/textview.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TextView &parents: {Gtk Container}. 2 | Gtk TextView traits atSlotNamed: #printName put: 'Gtk TextView'. 3 | 4 | tv@(Gtk TextView traits) new [ 5 | tv newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_text_view_new do 7 | ]) 8 | ]. 9 | 10 | tv@(Gtk TextView traits) newWithBuffer: buffer [ 11 | tv newWithHandle: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_text_view_new_with_buffer applyTo: {buffer handle} 13 | ]) 14 | ]. 15 | 16 | tv@(Gtk TextView traits) buffer [ 17 | Gtk TextBuffer newWithHandle: (Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_text_view_get_buffer applyTo: {tv handle} 19 | ]) 20 | ]. 21 | 22 | tv@(Gtk TextView traits) wrapMode: wrapMode [ 23 | Gdk Lib protectedDo: [ 24 | Gtk Lib primitives gtk_text_view_set_wrap_mode applyTo: {tv handle. wrapMode} 25 | ]. 26 | tv 27 | ]. 28 | 29 | tv@(Gtk TextView traits) scrollOnScreen: mark@(Gtk TextMark) [ 30 | Gdk Lib protectedDo: [ 31 | Gtk Lib primitives gtk_text_view_scroll_mark_onscreen applyTo: {tv handle. mark handle } 32 | ]. 33 | tv 34 | ]. 35 | 36 | tv@(Gtk TextView traits) scrollTo: iter@(Gtk TextIter) &withinMargin: margin &useAlign: useAlign &xAlign: xAlign &yAlign: yAlign [ 37 | margin `defaultsTo: 0.0 . 38 | useAlign `defaultsTo: False. 39 | xAlign `defaultsTo: 0.0 . 40 | yAlign `defaultsTo: 0.0 . 41 | Gdk Lib protectedDo: [ 42 | Gtk Lib primitives gtk_text_view_scroll_to_iter applyTo: {tv handle. iter handle. margin. useAlign. xAlign. yAlign } 43 | ] 44 | ]. 45 | -------------------------------------------------------------------------------- /src/ui/gtk/toolbar.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Toolbar &parents: {Gtk Container}. 2 | Gtk Toolbar traits atSlotNamed: #printName put: 'Gtk Toolbar'. 3 | 4 | tb@(Gtk Toolbar traits) new [ 5 | tb newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_toolbar_new do 7 | ]) 8 | ]. 9 | 10 | tb@(Gtk Toolbar traits) insert: item &position: position [ 11 | "position: 0=preppend, -1=append" 12 | position `defaultsTo: -1. 13 | (Gdk Lib protectedDo: [ 14 | Gtk Lib primitives gtk_toolbar_insert applyTo: { tb handle. item handle. position } 15 | ]). 16 | ]. 17 | 18 | -------------------------------------------------------------------------------- /src/ui/gtk/toolbutton.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #ToolButton &parents: {Gtk ToolItem}. 2 | Gtk ToolButton traits atSlotNamed: #printName put: 'Gtk ToolButton'. 3 | 4 | tb@(Gtk ToolButton traits) new [ 5 | tb shouldNotImplement 6 | ]. 7 | 8 | tb@(Gtk ToolButton traits) newFromStock: stockID@(String traits) [ 9 | tb newWithHandle: (Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_tool_button_new_from_stock applyTo: {stockID} 11 | ]) 12 | ]. 13 | 14 | -------------------------------------------------------------------------------- /src/ui/gtk/toolitem.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #ToolItem &parents: {Gtk Bin}. 2 | Gtk ToolItem traits atSlotNamed: #printName put: 'Gtk ToolItem'. 3 | 4 | ti@(Gtk ToolItem traits) new [ 5 | ti newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_tool_item_new do 7 | ]) 8 | ]. 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/ui/gtk/treeiter.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TreeIter &parents: {GLib Boxed}. 2 | Gtk TreeIter traits atSlotNamed: #printName put: 'Gtk TreeIter'. 3 | 4 | ti@(Gtk TreeIter traits) new [ 5 | ti newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk LibWrapper primitives wrapper_gtk_tree_iter_new do 7 | ]) 8 | ]. 9 | -------------------------------------------------------------------------------- /src/ui/gtk/treemodel.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TreeModel &parents: {GLib Interface}. 2 | Gtk TreeModel traits atSlotNamed: #printName put: 'Gtk TreeModel'. 3 | 4 | tm@(Gtk TreeModel traits) new [ 5 | tm shouldNotImplement 6 | ]. 7 | 8 | tm@(Gtk TreeModel traits) columnsCount [ 9 | Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_tree_model_get_n_columns applyTo: { tm handle } 11 | ] 12 | ]. 13 | 14 | tm@(Gtk TreeModel traits) pathFromIter: iter [ 15 | Gtk TreePath newWithHandle: (Gdk Lib protectedDo: [ 16 | Gtk Lib primitives gtk_tree_model_get_path applyTo: { tm handle. iter handle } 17 | ]) 18 | ]. 19 | 20 | tm@(Gtk TreeModel traits) stringFromIter: iter [ 21 | Gdk Lib protectedDo: [ 22 | Gtk Lib primitives gtk_tree_model_get_string_from_iter applyTo: { tm handle. iter handle } 23 | ] 24 | ]. 25 | 26 | tm@(Gtk TreeModel traits) at: iter@(Gtk TreeIter traits) [ 27 | "Returns a collection of values on the given row" 28 | | values columnsCount | 29 | columnsCount: tm columnsCount. 30 | values: (Array new &capacity: columnsCount). 31 | 0 below: tm columnsCount do: [ | :column | 32 | values at: column put: (tm at: iter column: column) 33 | ]. 34 | values 35 | ]. 36 | 37 | tm@(Gtk TreeModel traits) at: iter@(Gtk TreeIter traits) column: column [ 38 | "Gets the value at the given column index of the given GtkTreeIter." 39 | (tm isValid: iter) 40 | ifTrue: [ 41 | | value | 42 | value: GLib Value new. 43 | (Gdk Lib protectedDo: [ 44 | Gtk Lib primitives gtk_tree_model_get_value applyTo: { tm handle. iter handle. column. value handle } 45 | ]). 46 | value value 47 | ] 48 | ifFalse: [ Nil ] 49 | ]. 50 | -------------------------------------------------------------------------------- /src/ui/gtk/treepath.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TreePath &parents: {GLib Boxed}. 2 | Gtk TreePath traits atSlotNamed: #printName put: 'Gtk TreePath'. 3 | 4 | tp@(Gtk TreePath traits) new [ 5 | tp newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_tree_path_new do 7 | ]) 8 | ]. 9 | 10 | tp@(Gtk TreePath traits) as: s@(String traits) [ 11 | Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_tree_path_to_string applyTo: { tp handle } 13 | ] 14 | ]. 15 | 16 | tp@(Gtk TreePath traits) free [ 17 | Gdk Lib protectedDo: [ 18 | Gtk Lib primitives gtk_tree_path_free applyTo: { tp handle } 19 | ] 20 | ]. 21 | 22 | -------------------------------------------------------------------------------- /src/ui/gtk/treeselection.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TreeSelection &parents: {GLib Object}. 2 | Gtk TreeSelection traits atSlotNamed: #printName put: 'Gtk TreeSelection'. 3 | 4 | ts@(Gtk TreeSelection traits) new [ 5 | ts shouldNotImplement 6 | ]. 7 | 8 | ts@(Gtk TreeSelection traits) selected [ 9 | | iter selectionAvailable | 10 | iter: Gtk TreeIter new. 11 | selectionAvailable: (Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_tree_selection_get_selected applyTo: { ts handle. Nil. iter handle } 13 | ]). 14 | selectionAvailable ifTrue: [ iter ] ifFalse: [ Nil ] 15 | ]. 16 | 17 | ts@(Gtk TreeSelection traits) treeView [ 18 | Gtk TreeView newWithHandle: (Gdk Lib protectedDo: [ 19 | Gtk Lib primitives gtk_tree_selection_get_tree_view applyTo: {ts handle} 20 | ]) 21 | ]. 22 | 23 | ts@(Gtk TreeSelection traits) selectedRow [ 24 | ts treeView selectedRow 25 | ] 26 | -------------------------------------------------------------------------------- /src/ui/gtk/treeviewcolumn.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #TreeViewColumn &parents: {Gtk Object}. 2 | Gtk TreeViewColumn traits atSlotNamed: #printName put: 'Gtk TreeViewColumn'. 3 | 4 | tvc@(Gtk TreeViewColumn traits) new [ 5 | tvc newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_tree_view_column_new do 7 | ]) 8 | ]. 9 | 10 | tvc@(Gtk TreeViewColumn traits) title: title@(String traits) [ 11 | Gdk Lib protectedDo: [ 12 | Gtk Lib primitives gtk_tree_view_column_set_title applyTo: {tvc handle. title} 13 | ]. 14 | tvc 15 | ]. 16 | 17 | tvc@(Gtk TreeViewColumn traits) title: title@(String traits) text: text@(Number traits) [ 18 | | cell | 19 | tvc title: title. 20 | cell: Gtk CellRendererText new. 21 | tvc packStart: cell. 22 | tvc addAttributes: { #text -> text } on: cell. 23 | tvc 24 | ]. 25 | 26 | tvc@(Gtk TreeViewColumn traits) packStart: cell &expand: expand [ 27 | expand `defaultsTo: True. 28 | Gdk Lib protectedDo: [ 29 | Gtk Lib primitives gtk_tree_view_column_pack_start applyTo: {tvc handle. cell handle. expand} 30 | ]. 31 | tvc 32 | ]. 33 | 34 | tvc@(Gtk TreeViewColumn traits) addAttribute: attribute column: column on: cell [ 35 | Gdk Lib protectedDo: [ 36 | Gtk Lib primitives gtk_tree_view_column_add_attribute applyTo: {tvc handle. cell handle. attribute. column} 37 | ]. 38 | tvc 39 | ]. 40 | 41 | tvc@(Gtk TreeViewColumn traits) addAttributes: attributeArray on: cell [ 42 | attributeArray do: [ | :each | 43 | tvc addAttribute: each key column: each value on: cell 44 | ]. 45 | tvc 46 | ]. 47 | -------------------------------------------------------------------------------- /src/ui/gtk/vbox.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #VBox &parents: {Gtk Box}. 2 | Gtk VBox traits atSlotNamed: #printName put: 'Gtk VBox'. 3 | 4 | vb@(Gtk VBox traits) new &homogeneous: homogeneous &spacing: spacing [ 5 | "Creates a new GtkVBox. 6 | homogeneous: true if all children are to be given equal space allotments. 7 | spacing: the number of pixels to place by default between children." 8 | homogeneous `defaultsTo: False. 9 | spacing `defaultsTo: 0. 10 | vb newWithHandle: (Gdk Lib protectedDo: [ 11 | Gtk Lib primitives gtk_vbox_new applyTo: { homogeneous. spacing } 12 | ]) 13 | ]. 14 | 15 | -------------------------------------------------------------------------------- /src/ui/gtk/vpaned.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #VPaned &parents: {Gtk Paned}. 2 | Gtk VPaned traits atSlotNamed: #printName put: 'Gtk VPaned'. 3 | 4 | vp@(Gtk VPaned traits) new [ 5 | vp newWithHandle: (Gdk Lib protectedDo: [ 6 | Gtk Lib primitives gtk_vpaned_new do 7 | ]) 8 | ]. 9 | -------------------------------------------------------------------------------- /src/ui/gtk/widget.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Widget &parents: {Gtk Object}. 2 | Gtk Widget traits atSlotNamed: #printName put: 'Gtk Widget'. 3 | 4 | w@(Gtk Widget traits) new [ 5 | w shouldNotImplement 6 | ]. 7 | 8 | w@(Gtk Widget traits) show [ 9 | Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_widget_show applyTo: {w handle} 11 | ] 12 | ]. 13 | 14 | w@(Gtk Widget traits) showAll [ 15 | Gdk Lib protectedDo: [ 16 | Gtk Lib primitives gtk_widget_show_all applyTo: {w handle} 17 | ] 18 | ]. 19 | 20 | w@(Gtk Widget traits) destroy [ 21 | Gdk Lib protectedDo: [ 22 | Gtk Lib primitives gtk_widget_destroy applyTo: {w handle} 23 | ] 24 | ]. 25 | 26 | w@(Gtk Widget traits) sizeRequest: size@(Tuple traits) [ 27 | Gdk Lib protectedDo: [ 28 | Gtk Lib primitives gtk_widget_set_size_request applyTo: {w handle. size at: 0. size at: 1} 29 | ]. 30 | w 31 | ]. 32 | 33 | w@(Gtk Widget traits) addAccelerator: signal@(String traits) to: accelGroup@(Gtk AccelGroup traits) key: key@(Number traits) modifier: modifier@(Number traits) flags: flags@(Number traits) [ 34 | Gdk Lib protectedDo: [ 35 | Gtk Lib primitives gtk_widget_add_accelerator applyTo: {w handle. signal. accelGroup handle. key. modifier. flags } 36 | ]. 37 | w 38 | ]. 39 | -------------------------------------------------------------------------------- /src/ui/gtk/window.slate: -------------------------------------------------------------------------------- 1 | Gtk define: #Window &parents: {Gtk Bin}. 2 | Gtk Window traits atSlotNamed: #printName put: 'Gtk Window'. 3 | 4 | w@(Gtk Window traits) new [ 5 | w shouldNotImplement 6 | ]. 7 | 8 | w@(Gtk Window traits) newWithType: type [ 9 | w newWithHandle: (Gdk Lib protectedDo: [ 10 | Gtk Lib primitives gtk_window_new applyTo: {type} 11 | ]) 12 | ]. 13 | 14 | w@(Gtk Window traits) newTopLevel [ 15 | w newWithType: Gtk WindowType TopLevel 16 | ]. 17 | 18 | w@(Gtk Window traits) title: title [ 19 | Gdk Lib protectedDo: [ 20 | Gtk Lib primitives gtk_window_set_title applyTo: {w handle. title} 21 | ] 22 | ]. 23 | 24 | w@(Gtk Window traits) defaultSizeWidth: width height: height [ 25 | Gdk Lib protectedDo: [ 26 | Gtk Lib primitives gtk_window_set_default_size applyTo: {w handle. width. height} 27 | ] 28 | ]. 29 | 30 | w@(Gtk Window traits) isModal: isModal@(Boolean traits) [ 31 | Gdk Lib protectedDo: [ 32 | Gtk Lib primitives gtk_window_set_modal applyTo: {w handle. isModal} 33 | ]. 34 | w 35 | ]. 36 | 37 | w@(Gtk Window traits) add: accelGroup@(Gtk AccelGroup traits) [ 38 | Gdk Lib protectedDo: [ 39 | Gtk Lib primitives gtk_window_add_accel_group applyTo: {w handle. accelGroup handle} 40 | ]. 41 | w 42 | ]. 43 | 44 | -------------------------------------------------------------------------------- /src/ui/init.slate: -------------------------------------------------------------------------------- 1 | 2 | [ 3 | load: 'src/lib/array-words.slate'. 4 | load: 'src/lib/memoryarea.slate'. 5 | 6 | lobby ensureNamespace: #Graphics &delegate: True. 7 | 8 | load: 'src/ui/event.slate'. 9 | load: 'src/ui/color.slate'. 10 | load: 'src/ui/colors.slate'. 11 | load: 'src/lib/tuple.slate'. 12 | load: 'src/ui/region.slate'. 13 | load: 'src/ui/form.slate'. 14 | ] do. 15 | 16 | "you might want to save your image here. 17 | 18 | Image saveNamed: 'demo.image'. 19 | 20 | 21 | " 22 | [ 23 | 24 | [ 25 | load: 'src/ui/graphics.slate'. 26 | load: 'src/ui/listbox.slate'. 27 | load: 'src/lib/editor.slate'. 28 | load: 'src/ui/textbox.slate'. 29 | load: 'src/ui/containers.slate'. 30 | load: 'src/ui/inspector.slate'. 31 | load: 'src/ui/debugger.slate'. 32 | load: 'src/ui/repl.slate'. 33 | ] do. 34 | "or save it here 35 | 36 | Image saveNamed: 'd2.image'. 37 | 38 | " 39 | [ 40 | load: 'src/ui/base-windows.slate'. 41 | load: 'src/ui/x-windows.slate'. 42 | WindowSceneElement nativeSessionType start. 43 | Image startupActions at: WindowSceneElement nativeSessionType put: [ WindowSceneElement nativeSessionType start ]. 44 | load: 'src/ui/demo.slate'. 45 | ] do. 46 | 47 | 48 | ] do. 49 | 50 | [ 51 | inform: '****************************'. 52 | inform: '*** Start the demo with: ***'. 53 | inform: '****************************'. 54 | inform: '*** Demo start.'. 55 | inform: '****************************'. 56 | ] do. 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/ui/old/activator.slate: -------------------------------------------------------------------------------- 1 | Graphics define: #Activator &parents: {Cloneable} &slots: 2 | { 3 | #targetObject -> Nil. "Nil will be itself by default" 4 | #actionSelector -> #do. 5 | #arguments -> #{} 6 | }. 7 | 8 | 9 | 10 | se@(Activator traits) target 11 | [ 12 | se targetObject ifNil: [se] 13 | ]. 14 | 15 | 16 | se@(Activator traits) newTarget: t 17 | [ 18 | se newTarget: t actionSelector: #do 19 | ]. 20 | 21 | 22 | se@(Activator traits) newTarget: t actionSelector: sel@(Symbol traits) &arguments: args 23 | [ 24 | args `defaultsTo: #{}. 25 | (se cloneSettingSlots: #{#targetObject. #actionSelector. #arguments} 26 | to: {t. sel. args}) 27 | ]. 28 | 29 | se@(Activator traits) activate 30 | [ 31 | se actionSelector sendTo: ({se target} ; se arguments) 32 | ]. 33 | 34 | -------------------------------------------------------------------------------- /src/ui/old/button.slate: -------------------------------------------------------------------------------- 1 | Graphics define: #SimpleButtonElement &parents: {SceneElement. Activator. PaintSolidBackground. Text}. 2 | 3 | Graphics define: #SimpleBorderedButtonElement &parents: {SimpleButtonElement. PaintBorder}. 4 | 5 | se@(SimpleButtonElement traits) textXOffset [ 0 ]. 6 | 7 | se@(SimpleButtonElement traits) textYOffset [ se boundingRect height // 2 - (se fontSize // 2)]. 8 | 9 | se@(SimpleButtonElement traits) handle: event@(LeftMouseButtonPressEvent traits) 10 | [ 11 | (event is: LeftMouseButtonPressEvent) not ifTrue: [break]. 12 | se actionSelector sendTo: ({se target} ; se arguments) 13 | ]. 14 | 15 | se@(SimpleButtonElement traits) handle: event@(PaintEvent traits) 16 | [ 17 | se textOffset: se textXOffset <> (0 - se textYOffset). 18 | resend 19 | ]. 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/ui/old/ellipse.slate: -------------------------------------------------------------------------------- 1 | Graphics define: #Ellipse &parents: {Area} &slots: 2 | {#center. #xRadius. #yRadius}. 3 | "An Ellipse has a major and minor axis. Use a transformation to rotate it, 4 | and set the radius: to make it a Circle." 5 | 6 | e@(Ellipse traits) center: c@(Point traits) xRadius: x yRadius: y 7 | [e cloneSettingSlots: #{#center. #xRadius. #yRadius} to: {c. x. y}]. 8 | 9 | e@(Ellipse traits) center: c@(Point traits) radius: r 10 | [e cloneSettingSlots: #{#center. #xRadius. #yRadius} to: {c. r. r}]. 11 | 12 | e@(Ellipse traits) radius 13 | [e xRadius = e yRadius ifTrue: [e xRadius]]. 14 | 15 | e@(Ellipse traits) radius: r 16 | [e xRadius = e yRadius ifTrue: [e xRadius: r. e yRadius: r]]. 17 | 18 | e@(Ellipse traits) isCircle 19 | [e xRadius = e yRadius]. 20 | 21 | "Graphics define: #EllipticalArc &parents: {Trace}." 22 | -------------------------------------------------------------------------------- /src/ui/old/focus.slate: -------------------------------------------------------------------------------- 1 | Graphics define: #Focus &parents: {Cloneable}. 2 | 3 | 4 | se@(SceneElement) hasFocus 5 | [ 6 | True 7 | ]. 8 | 9 | -------------------------------------------------------------------------------- /src/ui/old/init.slate: -------------------------------------------------------------------------------- 1 | "lobby ensureNamespace: #Graphics &delegate: True. 2 | 3 | load: 'src/ui/color.slate'. 4 | load: 'src/ui/colors.slate'. 5 | load: 'src/ui/event.slate'. 6 | load: 'src/ui/region.slate'. 7 | load: 'src/ui/ellipse.slate'. 8 | load: 'src/ui/transform.slate'. 9 | load: 'src/ui/graphics.slate'. 10 | load: 'src/ui/form.slate'. 11 | load: 'src/ui/text.slate'. 12 | load: 'src/ui/morph.slate'. 13 | load: 'src/ui/layout.slate'. 14 | load: 'src/ui/presentation.slate'. 15 | load: 'src/ui/command.slate'. 16 | load: 'src/ui/medium.slate'. 17 | load: 'src/ui/port.slate'. 18 | " 19 | 20 | [ 21 | ExternalMethod. 22 | lobby ensureNamespace: #Graphics &delegate: True. 23 | load: 'src/lib/tree.slate'. 24 | load: 'src/ui/region.slate'. 25 | load: 'src/ui/transform.slate'. 26 | load: 'src/ui/color.slate'. 27 | load: 'src/ui/colors.slate'. 28 | load: 'src/ui/event.slate'. 29 | load: 'src/lib/memoryarea.slate'. 30 | load: 'src/lib/array-words.slate'. 31 | load: 'src/ui/form.slate'. 32 | load: 'src/lib/print.slate'. 33 | load: 'src/ui/spacerequirement.slate'. 34 | load: 'src/ui/theme.slate'. 35 | load: 'src/ui/graphics.slate'. 36 | load: 'src/ui/layout.slate'. 37 | load: 'src/ui/frame.slate'. 38 | load: 'src/ui/inspector.slate'. 39 | load: 'src/ui/contextsceneelement.slate'. 40 | load: 'src/ui/activator.slate'. 41 | load: 'src/ui/button.slate'. 42 | load: 'src/ui/scrollbar.slate'. 43 | load: 'src/ui/scrollpane.slate'. 44 | load: 'src/ui/listbox.slate'. 45 | load: 'src/ui/menu.slate'. 46 | load: 'src/ui/command.slate'. 47 | load: 'src/lib/text.slate'. 48 | load: 'src/ui/focus.slate'. 49 | load: 'src/ui/fundamental-mode.slate'. 50 | load: 'src/ui/textbox.slate'. 51 | ] do. 52 | 53 | " 54 | Image saveNamed: 'sdl.image'. 55 | " 56 | 57 | [ 58 | load: 'src/plugins/windows.slate'. 59 | load: 'src/plugins/cairo.slate'. 60 | load: 'src/ui/demo.slate'. 61 | ] do. 62 | -------------------------------------------------------------------------------- /src/ui/old/listener.slate: -------------------------------------------------------------------------------- 1 | "A program providing an interactive read-eval-print loop on some Stream pair. 2 | This does not require being in a terminal medium or emulation." 3 | 4 | "See CLIM Spec ch. 24" 5 | 6 | Graphics define: #InputEditingStream &parents: {ReadWriteStream}. 7 | {#buffer -> ExtensibleArray new. "The editable contents for the target's input." 8 | #position -> 0. "The index into the buffer Sequence where the `cursor' is." 9 | #scanPosition -> 0. "The index into the buffer Sequence where the next input is." 10 | #performRescan -> False "Whether the buffer should be rescanned before the next input."}. 11 | "Overrides a target stream's operations in order to provide input-editing 12 | semantics, but otherwise delegates primarily to that target." 13 | InputEditingStream addDelegate: #target valued: Stream clone. 14 | "The target Stream." 15 | "TODO: include a semaphore or lock/mutex or something for rescan periods." 16 | 17 | "NOTE: Invariant: `scanPosition <= position' at all times." 18 | "NOTE: Optional slots: an accumulator or a most-recently-used presentation 19 | history, or others." 20 | 21 | s@(InputEditingStream traits) newOn: s 22 | [ 23 | e clone on: s 24 | ]. 25 | 26 | s@(InputEditingStream traits) on: s 27 | [ 28 | e target: s. 29 | e 30 | ]. 31 | 32 | s@(InputEditingStream traits) rescanBuffer 33 | "Resets the scanPosition to its original state and reparses the buffer's 34 | contents before reading any more input." 35 | [ 36 | s scanPosition: 0. 37 | "TODO: Perform re-parsing." 38 | s 39 | ]. 40 | 41 | s@(InputEditingStream traits) next 42 | [| gesture | 43 | s rescanIfNecessary. 44 | [s scanPosition < s buffer size 45 | ifTrue: [gesture: s next. s scanPosition: s scanPosition + 1] 46 | ifFalse: [s buffer at: s scanPosition insert: (gesture: s target next)]. 47 | s process: gesture. 48 | gesture is: InputEditingCommand] whileTrue 49 | ]. 50 | 51 | s@(InputEditingStream traits) x 52 | [ 53 | 54 | ]. 55 | 56 | "TODO: CLIM Spec 24.2-5" 57 | -------------------------------------------------------------------------------- /src/ui/old/medium.slate: -------------------------------------------------------------------------------- 1 | Graphics define: #Medium &parents: {Cloneable} &slots: 2 | {#foreground -> Colors White. "The foreground Color." 3 | #background -> Colors Black. "The background Color." 4 | #ink . 5 | #transformation -> IdentityTransform. "What transformation is applied." 6 | #clipper -> Everywhere "The clipping Region in the target coordinates." 7 | }. 8 | "A Medium is a group of encapsulated drawing options." 9 | -------------------------------------------------------------------------------- /src/ui/old/port.slate: -------------------------------------------------------------------------------- 1 | Graphics define: #Port &parents: {Cloneable} &slots: {#scene}. 2 | "The type of object representing a particular display system hosting the Slate 3 | interface." 4 | 5 | p@(Port traits) findForType: serverType properties: properties 6 | "Returns a new or existing port for a given type with some specified 7 | properties." 8 | [overrideThis]. 9 | 10 | p@(Port traits) serverType 11 | "The name of the server type." 12 | [overrideThis]. 13 | 14 | p@(Port traits) name 15 | "The name of the server; defaults to serverType." 16 | [p serverType]. 17 | 18 | p@(Port traits) properties 19 | "A Mapping from property names to values for the server." 20 | [overrideThis]. 21 | 22 | p@(Port traits) restart 23 | [overrideThis]. 24 | 25 | p@(Port traits) destroy 26 | [overrideThis]. 27 | 28 | p@(Port traits) next 29 | "Answer the next input event." 30 | [overrideThis]. 31 | 32 | se@(SceneElement traits) port 33 | [ 34 | se treeParent port 35 | ]. 36 | 37 | Port traits define: #SceneRoot &parents: {SceneElement}. 38 | Port SceneRoot removeSlot: #boundingRect. 39 | 40 | se@(Port SceneRoot traits) boundingRect 41 | [Rectangle origin: Point origin corner: se treeParent width <> se treeParent height]. 42 | 43 | se@(Port SceneRoot traits) port 44 | [se treeParent]. 45 | 46 | Graphics ensureNamespace: #ports &delegate: True. 47 | "The namespace for the various ports supported." 48 | 49 | Graphics define: #Portlist &builder: [ExtensibleArray new]. 50 | 51 | Graphics define: #NullPort &parents: {Port}. 52 | "The Port that renders nothing." 53 | 54 | _@(NullPort traits) name ['Null']. 55 | _@(NullPort traits) serverType ['Null']. 56 | _@(NullPort traits) restart []. 57 | _@(NullPort traits) destroy []. 58 | _ renderOn: _@(NullPort traits) []. 59 | -------------------------------------------------------------------------------- /src/ui/old/theme.slate: -------------------------------------------------------------------------------- 1 | 2 | " a location for storing visual/audio/size/color/text/etc properties " 3 | 4 | Graphics define: #Theme &parents: {Cloneable}. 5 | 6 | Graphics define: #BaseTheme &parents: {Theme}. 7 | 8 | 9 | { 10 | #foregroundColor -> Colors Black. 11 | #foregroundAlpha -> 1.0. 12 | #backgroundColor -> Colors White. 13 | #backgroundAlpha -> 1.0. 14 | #borderColor -> Colors Black. 15 | #borderWidth -> 2. 16 | #borderAlpha -> 1.0. 17 | #selectionColor -> Colors Blue. 18 | #selectionInverseColor -> Colors White. "things drawn over the selection like text" 19 | #selectionInverseAlpha -> 1.0. 20 | #selectionAlpha -> 1.0. 21 | #font -> 'Courier'. 22 | #bold -> False. 23 | #italic -> False. 24 | #underline -> False. 25 | #strikethrough -> False. 26 | #fontSize -> 12. 27 | #textColor -> Colors Black. 28 | #textAlpha -> 1.0. 29 | #scrollbarForegroundColor -> Colors LightGray. 30 | #scrollbarForegroundAlpha -> 1.0. 31 | #scrollbarBackgroundColor -> Colors DarkGray. 32 | #scrollbarBackgroundAlpha -> 1.0. 33 | #vScrollbarWidth -> 10. 34 | #hScrollbarWidth -> 10 35 | 36 | 37 | } do: [|:each | 38 | 39 | BaseTheme addDynamicSlot: each key valued: each value. 40 | 41 | ]. 42 | 43 | 44 | se@(Cloneable traits) useTheme: theme@(Theme traits) 45 | "Add the following theme propertie to an object." 46 | [ 47 | (se hasSlotNamed: #theme) 48 | ifTrue: 49 | [se traitsWindow _delegates replaceAll: se theme with: theme. 50 | se atSlotNamed: #theme put: theme] 51 | ifFalse: 52 | [se addSlot: #theme valued: theme. 53 | se traitsWindow _delegates: {theme} ; se traitsWindow _delegates]. 54 | se 55 | ]. 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/unfinished/announcement.slate: -------------------------------------------------------------------------------- 1 | conditions define: #BroadcastCondition &parents: {Cloneable}. 2 | 3 | c@(BroadcastCondition traits) new 4 | [c clone]. 5 | 6 | c@(BroadcastCondition traits) publish 7 | [ 8 | ]. 9 | 10 | conditions define: #VetoableCondition &parents: {BroadcastCondition} 11 | &slots: {#vetoed -> False}. 12 | 13 | c@(VetoableCondition traits) isVetoed 14 | [c vetoed]. 15 | 16 | c@(VetoableCondition traits) veto 17 | [c vetoed: True]. 18 | -------------------------------------------------------------------------------- /src/unfinished/lazylist.slate: -------------------------------------------------------------------------------- 1 | collections define: #LazyList. 2 | LazyList traits define: #Cons &parents: {LazyList} &slots: #{#head. #lazyTail}. 3 | LazyList traits define: #Nil &parents: {LazyList}. 4 | 5 | l@(LazyList Cons traits) ifCons: cons@(Method traits) ifNil: nil@(Method traits) 6 | [cons applyWith: l head with: l lazyTail force]. 7 | 8 | l@(LazyList Nil traits) ifCons: cons@(Method traits) ifNil: nil@(Method traits) 9 | [nil do]. 10 | 11 | x as: l@(LazyList traits) 12 | [x reader as: l]. 13 | 14 | s@(ReadStream traits) as: l@(LazyList traits) 15 | [ 16 | s isAtEnd 17 | ifTrue: [l Nil] 18 | ifFalse: [l Cons cloneSettingSlots: #{#head. #lazyTail} to: 19 | {s next. [s as: l] suspend}] 20 | ]. 21 | 22 | l@(LazyList Cons traits) first [l head]. 23 | l@(LazyList Cons traits) rest [l lazyTail force]. 24 | 25 | l@(LazyList Nil traits) first [l]. 26 | l@(LazyList Nil traits) rest [l]. 27 | -------------------------------------------------------------------------------- /src/unfinished/lzw.slate: -------------------------------------------------------------------------------- 1 | prototypes define: #LZWReadStream &parents: {PositionableReadStream} &slots: 2 | {#source -> ReadStream clone. 3 | "The stream from which the values are read." 4 | #strings -> Trie new. 5 | "The set of sequences seen so far; the codes are stored at the leaves." 6 | #currentString}. 7 | "A ReadStream which reads from another stream some LZW-compressed data and 8 | outputs the decompressed contents." 9 | 10 | lz@(LZWReadStream traits) on: s 11 | [ 12 | lz source := s. 13 | lz strings := lz strings new. 14 | lz currentString := lz strings. 15 | lz 16 | ]. 17 | 18 | lz@(LZWReadStream traits) wordSize 19 | [ 20 | lz source wordSize 21 | ]. 22 | 23 | lz@(LZWReadStream traits) next 24 | [| nextChar | 25 | nextChar := lz source next. 26 | 27 | ]. 28 | 29 | prototypes define: #LZWWriteStream &parents: {PositionableWriteStream} &slots: 30 | {#source -> ReadStream clone. "The stream to which the compressed values are written." 31 | #strings -> Trie new. "The set of sequences seen so far; the codes are stored at the leaves." 32 | #currentString}. 33 | "A WriteStream which writes out data in an LZW-compressed form. The flush 34 | method actually causes the write to occur, since a dictionary needs to be built 35 | up first to encode the data." 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/unfinished/monad.slate: -------------------------------------------------------------------------------- 1 | "http://moonbase.rydia.net/mental/writings/programming/monads-in-ruby/" 2 | 3 | "Serially-numbering monad in Slate:" 4 | 5 | "Defining a datatype for Integer-tagged values..." 6 | define: #IntegerTagging &slots: #{#tag. #value}. 7 | 8 | obj tagWith: i@(Integer traits) 9 | [IntegerTagging clone `>> [tag := i. value := obj. ]]. 10 | 11 | "Defining a counting monad with its two operations (global)..." 12 | _@here return: val 13 | [[| :currentCounter | currentCounter tagWith: val]]. 14 | 15 | _@here bind: monad to: m@(Method traits) 16 | [ 17 | [| :currentCounter result newM | 18 | result := (monad applyWith: currentCounter). 19 | newM := (m applyWith: result value). 20 | newM applyWith: result tag] 21 | ]. 22 | 23 | "Verification:" 24 | 25 | "return: is the left and right unit of bind:to: ..." 26 | (bind: (return: v) to: m) === (m applyWith: v) 27 | (bind: monad to: [| :v | return: v]) === monad 28 | 29 | "bind:to: is associative..." 30 | (bind: monad to: [| :v | bind: (f applyWith: v) to: g]) 31 | === (bind: (bind: monad to: f) to: g) 32 | 33 | "Defining an increment morphism..." 34 | 35 | _@here incr [[| :n | n tagWith: n + 1]]. 36 | 37 | "An operation to run the monad..." 38 | 39 | _@here runMonad: monad with: initCounter 40 | [monad applyWith: initCounter]. 41 | 42 | "Example..." 43 | 44 | define: #Tree &slots: {#value. #children -> {}}. 45 | 46 | "Starting over..." 47 | 48 | define: #Monad &parents: {Cloneable} &slots: {#value. #action}. 49 | 50 | m@(Monad traits) newFor: obj 51 | [m clone `>> [value := obj. ]]. 52 | 53 | m@(Monad traits) newDoing: action 54 | [m clone `>> [action := action. ]]. 55 | 56 | m@(Monad traits) pass 57 | [m action applyWith: m value]. 58 | 59 | define: #IdentityMonad -> (Monad newDoing: Method Identity). 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/unfinished/objc/generator.slate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/src/unfinished/objc/generator.slate -------------------------------------------------------------------------------- /src/unfinished/objc/syntax.slate: -------------------------------------------------------------------------------- 1 | prototypes ensureNamespace: #ObjC. 2 | 3 | ObjC ensureNamespace: #Syntax. 4 | ObjC Syntax addDelegate: C Syntax. 5 | 6 | ObjC Syntax define: #MessageSelector -> Symbol. 7 | 8 | ObjC Syntax define: #Message &parents: {Syntax Message. ObjC Syntax Node}. 9 | 10 | ObjC Syntax define: #ObjDefinition &parents: {C Syntax Definition. ObjC Syntax Node}. 11 | 12 | ObjC Syntax define: #ClassInterface &parents: {ObjC Syntax ObjDefinition} 13 | &slots: {#superClassName -> ''. 14 | #instanceVariables -> {}. 15 | #protocolReferences -> {}. 16 | #interfaces -> {} 17 | }. 18 | 19 | ObjC Syntax define: #ClassImplementation &parents: {ObjC Syntax ObjDefinition} 20 | &slots: {#superClassName -> ''. 21 | #instanceVariables -> {}. 22 | #implementations -> {} 23 | }. 24 | 25 | ObjC Syntax define: #ProtocolInterface &parents: {ObjC Syntax ObjDefinition} 26 | &slots: {#superClassName -> ''. 27 | #instanceVariables -> {}. 28 | #protocolReferences -> {}. 29 | #interfaces -> {} 30 | }. 31 | 32 | ObjC Syntax define: #ProtocolImplementation &parents: {ObjC Syntax ObjDefinition} 33 | &slots: {#implementations -> {} 34 | }. 35 | 36 | ObjC Syntax define: #Protocol &parents: {ObjC Syntax ObjDefinition} 37 | &slots: {#protocolReferences -> {}. 38 | #interfaces -> {}}. 39 | 40 | ObjC ensureNamespace: #Visibilities &slots: {#Public. #Private. #Protected}. 41 | 42 | ObjC Syntax define: #MethodDefinition &parents: {ObjC Syntax ObjDefinition} 43 | &slots: {#class. 44 | #isClassSide -> False. 45 | }. 46 | -------------------------------------------------------------------------------- /src/unfinished/objc/types.slate: -------------------------------------------------------------------------------- 1 | ObjC ensureNamespace: #Types. 2 | ObjC Types addDelegate: C Types. 3 | 4 | ObjC Types define: #Any &parents: {Types Any}. 5 | 6 | -------------------------------------------------------------------------------- /src/unfinished/objc/writer.slate: -------------------------------------------------------------------------------- 1 | ObjC define: #PrintStream &parents: {C PrintStream}. 2 | "Writes out ObjC code." 3 | 4 | w@(ObjC PrintStream traits) print: msg@(ObjC Message traits) 5 | [ 6 | w nextPut: $[. 7 | selector isUnarySelector ifTrue: 8 | [(w printAsArgument: args first) ifTrue: [w newColumn]. 9 | w printSelectorPrefixOf: node. 10 | w ; selector name]. 11 | selector isBinarySelector ifTrue: 12 | [(w printAsArgument: args first) ifTrue: [w newColumn]. 13 | w printSelectorPrefixOf: node. 14 | w ; selector name. 15 | w newColumn. 16 | w printAsArgument: args second]. 17 | "For keyword sends, print the first argument, partition the selector by 18 | the colons, (at an offset of 1 to synchronize indices for looping), 19 | and then loop from one to the end, printing the keywords and arguments 20 | alternately." 21 | selector isKeywordSelector ifTrue: 22 | [| keywords | 23 | keywords := selector keywords. 24 | (w printAsArgument: args first) ifTrue: [w newColumn]. 25 | 1 below: args size do: 26 | [| :index arg | 27 | index = 1 28 | ifTrue: [w printSelectorPrefixOf: node] 29 | ifFalse: [w newColumn]. 30 | w ; ((keywords at: index - 1) as: String) ; ': '. 31 | w printAsArgument: (args at: index)]]. 32 | w nextPut: $]. 33 | w 34 | ]. 35 | -------------------------------------------------------------------------------- /src/unfinished/quadtree.slate: -------------------------------------------------------------------------------- 1 | collections define: #QuadTree &parents: {LinkedCollection}. 2 | {#treeParent. 3 | #bounds. "The Rectangle Region that corresponds to this node." 4 | #contents -> ExtensibleArray new}. 5 | "A QuadTree is a Tree structure designed for graphics comparisons, or at least 6 | 2-d region sorting." 7 | 8 | QuadTree define: #Node &parents: {QuadTree} &slots: #{#c1. #c2. #c3. #c4}. 9 | "Each node has 4 sub-nodes, separated vertically and horizontally at one 10 | Point." 11 | 12 | QuadTree define: #Leaf &parents: {QuadTree}. 13 | "The leaves can reference Regions which they contain but which are not part of 14 | the QuadTree." 15 | -------------------------------------------------------------------------------- /src/unfinished/rpn.slate: -------------------------------------------------------------------------------- 1 | prototypes define: #RPN &parents: {Cloneable} &slots: 2 | {#parser -> Nil. 3 | #printer -> String writer. 4 | #resource -> Console. 5 | #basePrompt -> 'RPN> '. 6 | #stack -> Stack new. 7 | #results -> (RingBuffer new &capacity: 10). 8 | #exitFlag -> False. 9 | }. 10 | "A simple RPN calculator." 11 | 12 | rpn@(RPN traits) prompt 13 | [ 14 | rpn basePrompt 15 | ]. 16 | 17 | rpn@(RPN traits) newBasedOn: resource@(ExternalResource traits) 18 | "Answer a new RPN targetting the specified resource and reset it." 19 | [rpn clone `>> [on: resource. reset. ]]. 20 | 21 | rpn@(RPN traits) on: resource 22 | "Re-target the RPN to the specified resource." 23 | [ 24 | rpn parser := resource reader lines. 25 | rpn printer := resource writer. 26 | rpn resource := resource. 27 | rpn 28 | ]. 29 | 30 | rpn@(RPN traits) reset 31 | "Clear out the line number and the evaluation result Collection." 32 | [ 33 | rpn stack clear. 34 | rpn results clear. 35 | rpn exitFlag := False. 36 | ]. 37 | 38 | rpn@(RPN traits) applyOp: name arity: arity 39 | [ 40 | name intern sendTo: (rpn stack pop: arity) 41 | ]. 42 | 43 | rpn@(RPN traits) parse: word 44 | [ 45 | word caseOf: 46 | {'+' -> [rpn applyOp: #+ arity: 2]. 47 | '-' -> [rpn applyOp: #- arity: 2]. 48 | '*' -> [rpn applyOp: #* arity: 2]. 49 | '/' -> [rpn applyOp: #/ arity: 2]. 50 | 'quit' -> [rpn exitFlag := True] 51 | } otherwise: 52 | [Number readFrom: word] 53 | ]. 54 | 55 | rpn@(RPN traits) enter 56 | [ 57 | [| expr | 58 | rpn on: rpn resource. 59 | rpn printer ; rpn prompt. 60 | rpn printer flush. 61 | expr := rpn parser next. 62 | expr split do: 63 | [| :word | 64 | (rpn parse: word) ifNotNilDo: [| :result | rpn stack push: result]]. 65 | rpn printer ; ((rpn stack collect: #printString `er) join &separator: ' '). 66 | rpn printer newLine. 67 | rpn printer flush. 68 | rpn exitFlag] whileFalse. 69 | rpn 70 | ]. 71 | -------------------------------------------------------------------------------- /src/unfinished/slot.slate: -------------------------------------------------------------------------------- 1 | prototypes define: #Slot &parents: {Cloneable} &slots: {#name -> Nil}. 2 | 3 | s@(Slot traits) newNamed: name 4 | [s cloneSettingSlots: #{#name} to: {name}]. 5 | 6 | x addSlot: s@(Slot traits) named: name 7 | [overrideThis]. 8 | 9 | x addSlot: s@(Slot traits) 10 | [s name ifNil: [error: 'A slot name is required.'] 11 | ifNotNilDo: [| :name | x addSlot: s named: name]]. 12 | 13 | x removeSlot: s@(Slot traits) 14 | [s name ifNil: [error: 'A slot name is required.'] 15 | ifNotNilDo: [| :name | x removeSlotNamed: name]]. 16 | 17 | prototypes define: #ValueSlot &parents: {Slot} &slots: {#value -> Nil}. 18 | 19 | x addSlot: s@(ValueSlot traits) named: name 20 | [ 21 | x addInvisibleSlot: name valued: s. 22 | x addAccessor: [| :obj | (obj atSlotNamed: name) value] for: name. 23 | x addMutator: [| :obj :newval | (obj atSlotNamed: name) value: newval] for: name. 24 | s value 25 | ]. 26 | 27 | prototypes define: #LazySlot &parents: {Slot} &slots: {#value -> Suspension}. 28 | 29 | x addSlot: s@(LazySlot traits) named: name 30 | [ 31 | ]. 32 | -------------------------------------------------------------------------------- /src/unfinished/user.slate: -------------------------------------------------------------------------------- 1 | prototypes define: #User &parents: {Cloneable} 2 | &slots: {#id -> 0. 3 | #convenientName -> '' "The user's common name."}. 4 | 5 | User traits define: #lastID -> 0. 6 | 7 | u@(User traits) new &name: convenientName 8 | [ 9 | convenientName `defaultsTo: 'Slate Admin'. 10 | u clone `>> [lastID := u lastID + 1. id := u lastID. convenientName := convenientName. ] 11 | ]. 12 | 13 | globals define: #CurrentUser -> User new. 14 | 15 | u@(User traits) current 16 | [globals CurrentUser]. 17 | -------------------------------------------------------------------------------- /src/vm/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | slateroot=../.. 4 | 5 | include $(slateroot)/common.mk 6 | 7 | all: vm 8 | 9 | OBJECTS=debug.o external-files.o external-pipes.o external-directory.o external-library.o external-memory.o gc.o interpreter.o method.o misc.o object.o primitives.o socket.o profiler.o optimizer.o vm.o 10 | 11 | $(OBJECTS): slate.hpp 12 | 13 | %.o: %.cpp 14 | $(SECHO) "Compiling src/vm/$(BASENAME)/$< ($(MODE))" 15 | $(CPP) $(CFLAGS) $(CFLAGS_$<) -o $@ -c $< 16 | 17 | vm: $(OBJECTS) 18 | $(CPP) $(LIBS) $(CFLAGS) $(CFLAGS_$<) -o $(VMNAME) $(OBJECTS) 19 | 20 | clean: 21 | rm -f *.o *.gcda *.gcno *.gcov $(VMNAME) 22 | -------------------------------------------------------------------------------- /src/vm/windows.readme.txt: -------------------------------------------------------------------------------- 1 | Windows native VM 2 | ----------------- 3 | 4 | This directory contains a VisualStudio project with which it's possible to 5 | compile a native Windows VM. Output files are slate.exe and slatedebug.exe 6 | in the Slate root directory for the release and debug executables. The 7 | console dll project puts its output dll next to the executables, so Windows 8 | can find the dll. 9 | 10 | There were optimization bugs in versions previous to Visual C++ Express 11 | Edition Beta (VS 8) that compiled a non-functioning VM, so we recommend 12 | using a recent version. 13 | 14 | Setting up Visual C++ Express 15 | ----------------------------- 16 | 17 | To install VS8 need to do/install/read/download the following: 18 | 19 | Visual C++ Express: 20 | http://www.microsoft.com/express/vc/ 21 | 22 | This is obviously the IDE. Install it and open the project files with it. 23 | 24 | "msinttypes": 25 | http://code.google.com/p/msinttypes/ 26 | 27 | This provides the headers inttypes.h and stdint.h which are POSIX headers 28 | that Windows does not provide for some basic portable integer types. 29 | 30 | also, "dirent" 31 | 32 | http://www.softagalleria.net/dirent.php 33 | 34 | This provides the dirent.h which are POSIX headers 35 | that Windows does not provide for for scanning files and directories. 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/web/cgi.slate: -------------------------------------------------------------------------------- 1 | "CGI define: #PrintStream &parents: {Parsing BasicParser} &slots: {#rootElement}." 2 | 3 | lobby define: #CGI &parents: {Cloneable} &slots: 4 | {#variables -> Dictionary new. 5 | #out -> Console writer. 6 | #xhtml -> Xml XHTMLPrintStream. 7 | #postValues -> Dictionary new. 8 | #getValues -> Dictionary new. 9 | }. 10 | 11 | cgi@(CGI traits) parseQueryString: queryString into: dict 12 | [ 13 | (queryString splitWithAny: {$&}) do: 14 | [| :x s key value | 15 | s := (x as: cgi postString) reader. 16 | key := s upTo: $=. 17 | value := Net URLPathEncoder convert: s upToEnd. 18 | dict at: key put: value]. 19 | ]. 20 | 21 | cgi@(CGI traits) on: resource 22 | [ 23 | cgi out := resource writer. 24 | cgi xhtml := xhtml newOn: cgi out. 25 | ]. 26 | 27 | cgi@(CGI traits) new 28 | [ 29 | resend `>> 30 | [variables := variables new. 31 | cgi on: cgi out resource. 32 | postValues := postValues new. 33 | getValues := getValues new. ] 34 | ]. 35 | 36 | cgi@(CGI traits) handleCurrentRequest 37 | [ 38 | cgi variables := Environment variables. 39 | 40 | (cgi variables at: 'CONTENT_LENGTH' ifAbsent: [Nil]) ifNotNilDo: 41 | [| :contentlength | 42 | cgi parseQueryString: (Console reader next: (contentlength as: Integer)) into: cgi postValues]. 43 | (cgi variables at: 'QUERY_STRING' ifAbsent: [Nil]) ifNotNilDo: 44 | [| :query | 45 | cgi parseQueryString: query into: cgi getValues]. 46 | ]. 47 | 48 | Image startupActions at: #CGI put: 49 | [CGI new handleCurrentRequest]. 50 | -------------------------------------------------------------------------------- /src/web/css.slate: -------------------------------------------------------------------------------- 1 | lobby ensureNamespace: #CSS. 2 | 3 | CSS define: #Builder &parents: {Cloneable} &slots: { 4 | #rules -> ExtensibleArray new. 5 | }. 6 | 7 | CSS define: #Property &parents: {Association}. 8 | 9 | b@(CSS Builder traits) new 10 | [b clone `>> [rules := b rules new. ]]. 11 | 12 | b@(CSS Builder traits) new: rulesets@(Method traits) 13 | [ 14 | b := b new. 15 | rulesets environment := b. 16 | rulesets do. 17 | b 18 | ]. 19 | 20 | CSS define: #Ruleset &parents: {Cloneable} &slots: { 21 | #selector. 22 | #properties -> ExtensibleArray new. 23 | }. 24 | 25 | r@(CSS Ruleset traits) new 26 | [r clone `>> [properties := r properties new. ]]. 27 | 28 | b@(CSS Builder traits) in: selector@(String traits) apply: properties@(Method traits) 29 | [| rule | 30 | rule := CSS Ruleset new `>> [selector := selector. ]. 31 | 32 | properties environment := rule. 33 | properties do. 34 | 35 | b rules append: rule. 36 | b 37 | ]. 38 | 39 | r@(CSS Ruleset traits) didNotUnderstand: message at: position 40 | [[ 41 | r properties append: CSS Property new `>> 42 | [key := (message selector as: String) allButLast. " Exclude the :" 43 | value := message arguments second printString. ]. 44 | r 45 | ] 46 | ]. 47 | 48 | b@(CSS Builder traits) as: s@(String traits) 49 | [(b rules collect: #(as: s) `er) join]. 50 | 51 | r@(CSS Ruleset traits) as: s@(String traits) 52 | [r selector ; ' {' ; (r properties collect: #(as: s) `er) join ; '}']. 53 | 54 | p@(CSS Property traits) as: _@(String traits) 55 | [p key ; ': ' ; p value ; ';' ]. 56 | -------------------------------------------------------------------------------- /src/web/init.slate: -------------------------------------------------------------------------------- 1 | 2 | 3 | "for loading the web based components... xml, dom, etc." 4 | 5 | load: 'src/i18n/init.slate'. 6 | load: 'src/web/dom.slate'. 7 | load: 'src/web/parsers.slate'. 8 | load: 'src/web/xml.slate'. 9 | load: 'src/web/cgi.slate'. 10 | 11 | -------------------------------------------------------------------------------- /tests/benchmark/ackermann.slate: -------------------------------------------------------------------------------- 1 | 2 | x@(Integer traits) ackermann: y@(Integer traits) 3 | [ 4 | x = 0 5 | ifTrue: [y + 1] 6 | ifFalse: 7 | [y = 0 8 | ifTrue: [x - 1 ackermann: 1] 9 | ifFalse: [x - 1 ackermann: (x ackermann: y - 1)]] 10 | ]. 11 | -------------------------------------------------------------------------------- /tests/benchmark/binarytrees.slate: -------------------------------------------------------------------------------- 1 | prototypes ensureNamespace: #benchmark &delegate: True. 2 | 3 | benchmark define: #TreeNode &slots: { 4 | #left. 5 | #right. 6 | #item. 7 | }. 8 | 9 | n@(benchmark TreeNode traits) bottomUpTree: i@(Integer traits) depth: d@(Integer traits) 10 | [ 11 | d > 0 12 | ifTrue: 13 | [a ::= 2 * i. b ::= a - 1. c ::= d - 1. 14 | n new &left: (n bottomUpTree: b depth: c) &right: (n bottomUpTree: a depth: c) &item: i] 15 | ifFalse: [n new &left: Nil &right: Nil &item: i] 16 | ]. 17 | 18 | n@(benchmark TreeNode traits) new &left: l &right: r &item: i 19 | [ 20 | n clone `>> [left := l. right := r. item := i. ] 21 | ]. 22 | 23 | n@(benchmark TreeNode traits) checkItem 24 | [ 25 | n left isNil 26 | ifTrue: [n item] 27 | ifFalse: [n item + (n left checkItem - n right checkItem)] 28 | ]. 29 | 30 | n@(Integer traits) binaryTrees 31 | [| check iterations | 32 | minDepth ::= 4. 33 | maxDepth ::= minDepth + 2 max: n. 34 | stretchDepth ::= maxDepth + 1. 35 | check := (benchmark TreeNode bottomUpTree: 0 depth: stretchDepth) checkItem. 36 | longLivedTree ::= benchmark TreeNode bottomUpTree: 0 depth: maxDepth. 37 | minDepth upTo: maxDepth by: 2 do: 38 | [| :depth | 39 | iterations := 1 bitShift: maxDepth - depth + minDepth. 40 | check := 0. 41 | 1 upTo: iterations do: 42 | [| :i | 43 | check += (benchmark TreeNode bottomUpTree: i depth: depth) checkItem. 44 | check += (benchmark TreeNode bottomUpTree: (-1 * i) depth: depth) checkItem 45 | ] 46 | ]. 47 | ]. 48 | -------------------------------------------------------------------------------- /tests/benchmark/fannkuch.slate: -------------------------------------------------------------------------------- 1 | 2 | n@(Integer traits) fannkuch 3 | [| perm0 count maxFlipsCount m r flipsCount k k2 temp i j | 4 | perm ::= Array newSize: n. 5 | perm1 ::= Array newSize: n. 6 | count ::= Array newSize: n. 7 | maxPerm ::= Array newSize: n. 8 | maxFlipsCount := -1. 9 | m := n - 1. 10 | 11 | 0 below: n do: [| :i | perm1 at: i put: i]. 12 | r := n. 13 | [ 14 | [r = 1] whileFalse: 15 | [count at: r - 1 put: r. 16 | r -= 1]. 17 | (perm1 at: 0) == 0 \/ [(perm1 at: m) == m] ifFalse: 18 | [0 below: n do: 19 | [| :i | perm at: i put: (perm1 at: i)]. 20 | flipsCount := 0. 21 | k := perm at: 0. 22 | [k = 0] whileFalse: 23 | [k2 := k + 1 bitShift: -1. 24 | 0 below: k2 do: 25 | [| :i | 26 | temp := perm at: i. 27 | perm at: i put: (perm at: k - i). 28 | perm at: k - i put: temp]. 29 | flipsCount += 1. 30 | k := perm at: 0]. 31 | flipsCount > maxFlipsCount ifTrue: 32 | [maxFlipsCount := flipsCount. 33 | 0 below: n do: 34 | [| :i | maxPerm at: i put: (perm1 at: i)]]]. 35 | [r = n ifTrue: [^ maxFlipsCount]. 36 | perm0 := perm1 at: 0. 37 | i := 0. 38 | [i < r] whileTrue: 39 | [j := i + 1. 40 | perm1 at: i put: (perm1 at: j). 41 | i := j]. 42 | perm1 at: r put: perm0. 43 | count at: r put: (count at: r) - 1. 44 | r += 1] 45 | until: [(count at: r - 1) > 0]. 46 | r -= 1 47 | ] loop. 48 | ]. 49 | -------------------------------------------------------------------------------- /tests/benchmark/harmonic.slate: -------------------------------------------------------------------------------- 1 | 2 | n@(Integer traits) partialSum 3 | [| s | 4 | s := 0.0. 5 | 1 upTo: n do: [| :i | s += 1.0 / i]. 6 | s 7 | ]. 8 | -------------------------------------------------------------------------------- /tests/benchmark/init.slate: -------------------------------------------------------------------------------- 1 | load: 'src/lib/test.slate'. 2 | load: 'src/lib/extlib.slate'. 3 | load: 'src/lib/time.slate'. 4 | 5 | load: 'tests/benchmark/shootout.slate'. 6 | -------------------------------------------------------------------------------- /tests/benchmark/mandelbrot.slate: -------------------------------------------------------------------------------- 1 | 2 | w@(Integer traits) mandelbrot 3 | [ 4 | (File newNamed: 'tests/benchmark/mandelbrot.pbm' &mode: File CreateWrite) 5 | sessionDo: [| :f | w mandelbrotOn: f writer] 6 | ]. 7 | 8 | width@(Integer traits) mandelbrotOn: s@(Stream traits) 9 | [| isOverLimit bits bitnum | 10 | height ::= width. 11 | limit2 ::= 4.0. 12 | m ::= 50. 13 | isOverLimit := False. 14 | bits := 0. 15 | bitnum := 0. 16 | s ; ('P4\n%s %s\n' sprintf*, width, height). 17 | 18 | 0 below: height do: 19 | [| :y | 20 | 0 below: width do: 21 | [| :x zr zi cr ci i | 22 | zr := 0.0. 23 | zi := 0.0. 24 | cr := 2.0 * (x as: Float) / (width as: Float) - 1.5. 25 | ci := 2.0 * (y as: Float) / (height as: Float) - 1.0. 26 | i := 0. 27 | 28 | [| tr ti | 29 | tr := (zr * zr) - (zi * zi) + cr. 30 | ti := 2.0 * zr * zi + ci. 31 | zr := tr. 32 | zi := ti. 33 | (isOverLimit := (zr * zr) + (zi * zi) > limit2) not 34 | /\ [(i += 1) < m]] whileTrue. 35 | 36 | bits := bits bitShift: 1. 37 | isOverLimit ifFalse: [bits += 1]. 38 | bitnum += 1. 39 | 40 | x = (width - 1) ifTrue: [ 41 | bits := bits bitShift: 8 - bitnum. 42 | bitnum := 8 43 | ]. 44 | 45 | bitnum = 8 ifTrue: [ 46 | s nextPut: bits. 47 | bits := 0. 48 | bitnum := 0 49 | ] 50 | ] 51 | ]. 52 | ]. 53 | -------------------------------------------------------------------------------- /tests/benchmark/nsieve.slate: -------------------------------------------------------------------------------- 1 | 2 | m@(Integer traits) nsieve 3 | [| count | 4 | count := 0. 5 | (isPrime ::= Array newSize: m + 2) atAllPut: True. 6 | 2 upTo: m do: 7 | [| :i | 8 | (isPrime at: i) ifTrue: 9 | [(i + i to: m by: i) do: 10 | [| :k | isPrime at: k put: False]. 11 | count += 1]]. 12 | count 13 | ]. 14 | 15 | n@(Integer traits) primes 16 | [ 17 | m ::= (2 raisedTo: n) * 10000. 18 | m nsieve 19 | ]. 20 | -------------------------------------------------------------------------------- /tests/benchmark/nsievebits.slate: -------------------------------------------------------------------------------- 1 | 2 | m@(Integer traits) nsievebits 3 | [| count | 4 | count := 0. 5 | (isPrime ::= BitArray new &capacity: m + 1) atAllPut: True. 6 | 2 to: m do: 7 | [| :i | 8 | (isPrime at: i) ifTrue: 9 | [(i + i to: m by: i) do: [| :k | isPrime at: k put: False]. 10 | count += 1]]. 11 | count 12 | ]. 13 | 14 | n@(Integer traits) bitprimes 15 | [ 16 | m ::= (2 raisedTo: n) * 10000. 17 | m nsievebits 18 | ]. 19 | -------------------------------------------------------------------------------- /tests/benchmark/random.slate: -------------------------------------------------------------------------------- 1 | 2 | prototypes ensureNamespace: #benchmark &delegate: True. 3 | 4 | benchmark define: #RandomNumber &slots: { 5 | #increment -> 29573. 6 | #multiplier -> 3877. 7 | #modulus -> 139968. 8 | #fmodulus -> 139968.0. 9 | #seed. 10 | #scale. 11 | }. 12 | 13 | r@(benchmark RandomNumber traits) next 14 | [ 15 | r seed := r seed * r multiplier + r increment \\ r modulus. 16 | (r seed * r scale as: Float) / r fmodulus 17 | ]. 18 | 19 | r@(benchmark RandomNumber traits) to: i@(Integer traits) repeat: n@(Integer traits) 20 | [ 21 | r `>> [seed := 42. scale := i]. 22 | n - 1 timesRepeat: [r next]. 23 | r next 24 | ]. 25 | -------------------------------------------------------------------------------- /tests/benchmark/spectralnorm.slate: -------------------------------------------------------------------------------- 1 | 2 | i1@(Integer traits) matrixA: i2@(Integer traits) 3 | [ 4 | 1.0 / (i1 + i2 * (i1 + i2 + 1) / 2 + i1 + 1) 5 | ]. 6 | 7 | a@(Array traits) multiplyAv 8 | [| n av | 9 | n := a size. 10 | av := (Array new &capacity: n) atAllPut: 0.0. 11 | 0 below: n do: [| :i | 12 | 0 below: n do: [| :j | 13 | av at: i put: (av at: i) + ((i matrixA: j) * (a at: j))]]. 14 | av 15 | ]. 16 | 17 | a@(Array traits) multiplyAtv 18 | [| n atv | 19 | n := a size. 20 | atv := ((Array new &capacity: n) atAllPut: 0.0). 21 | 0 below: n do: [| :i | 22 | 0 below: n do: [| :j | 23 | atv at: i put: (atv at: i) + ((j matrixA: i) * (a at: j))]]. 24 | atv 25 | ]. 26 | 27 | a@(Array traits) multiplyAtAv 28 | [ 29 | a multiplyAv multiplyAtv 30 | ]. 31 | 32 | n@(Integer traits) spectralnorm 33 | [| n u v vBv vv | 34 | u := (Array new &capacity: n) atAllPut: 1.0. 35 | v := (Array new &capacity: n) atAllPut: 0.0. 36 | 1 upTo: 10 do: 37 | [| :i | 38 | v := u multiplyAtAv. 39 | u := v multiplyAtAv]. 40 | vBv := 0.0. 41 | vv := 0.0. 42 | 0 below: n do: 43 | [| :i | 44 | vBv += (u at: i) * (v at: i). 45 | vv += (v at: i) * (v at: i)]. 46 | (vBv / vv) sqrt printString &precision: 9 47 | ]. 48 | -------------------------------------------------------------------------------- /tests/benchmark/startup.slate: -------------------------------------------------------------------------------- 1 | 2 | Console writer ; 'hello world\n'. 3 | 4 | -------------------------------------------------------------------------------- /tests/benchmark/sumfile.slate: -------------------------------------------------------------------------------- 1 | 2 | name@(String traits) sumfile 3 | [| sum | 4 | sum := 0. 5 | (File newNamed: name &mode: File Read) 6 | sessionDo: [| :file stream | 7 | stream := file reader. 8 | [stream isAtEnd] whileFalse: [sum += stream nextLine as: Integer]]. 9 | sum 10 | ]. 11 | -------------------------------------------------------------------------------- /tests/benchmark/takfp.slate: -------------------------------------------------------------------------------- 1 | 2 | x@(Float traits) tak: y@(Float traits) with: z@(Float traits) 3 | [ 4 | y < x 5 | ifTrue: 6 | [(x - 1.0 tak: y with: z) 7 | tak: (y - 1.0 tak: z with: x) 8 | with: (z - 1.0 tak: x with: y)] 9 | ifFalse: [z] 10 | ]. 11 | 12 | n@(Integer traits) takfp 13 | [ 14 | n * 3.0 tak: n * 2.0 with: n * 1.0 15 | ]. 16 | -------------------------------------------------------------------------------- /tests/extensibleSeq.slate: -------------------------------------------------------------------------------- 1 | 2 | testing UnitTests define: #ExtensibleArray &parents: {TestCase}. 3 | 4 | tc@(UnitTests ExtensibleArray traits) testAtInsert 5 | [| ea1 ea2 | 6 | ea1: ExtensibleArray new. 7 | ea2: ExtensibleArray new. 8 | 0 upTo: 10 do: [| :ind | 9 | ea1 at: ind insert: ind + 1. 10 | ea2 add: ind + 1. 11 | tc assert: ea1 = ea2 description: '#add: and #at:insert differ at: ' ; (ind as: String)]. 12 | ]. 13 | 14 | tc@(UnitTests ExtensibleArray traits) suite 15 | [ 16 | tc suiteForSelectors: { 17 | #testAtInsert 18 | } 19 | ]. 20 | -------------------------------------------------------------------------------- /tests/file.slate: -------------------------------------------------------------------------------- 1 | UnitTests definePrototype: #File &basis: TestCase. 2 | "Unit test for file functionality." 3 | 4 | UnitTests File addSlot: #inputFileName valued: ('LICENSE' as: File Locator). 5 | UnitTests File addSlot: #outputFileName valued: ('LICENSE.copy' as: File Locator). 6 | 7 | t@(UnitTests File traits) testLocatorConversion 8 | "Note this test avoids using '~' in the filenames so that the platform library isn't required" 9 | [| filenames | 10 | filenames: {'src/lib/file.slate'. '/'. '/usr'. 'foo.bar'}. 11 | filenames do: [| :filename | 12 | t assert: (filename isSuffixOf: ((filename as: File Locator) as: filename)) 13 | description: 'Parsing and printing a filename failed: ' ; filename]. 14 | ]. 15 | 16 | t@(UnitTests File traits) testIdentityCompare 17 | [ 18 | t assert: (t inputFileName with: t inputFileName sessionDo: 19 | [| :file1 :file2 | file1 hasSameContentsAs: file2] &mode: File Read) 20 | description: 'Comparing the contents of \'' ; (t inputFileName as: String) ; '\' with itself failed'. 21 | ]. 22 | 23 | t@(UnitTests File traits) testCopy 24 | [ 25 | t inputFileName with: t outputFileName sessionDo: 26 | [| :file1 :file2 | file1 copyContentsTo: file2] &mode1: File Read &mode2: File CreateWrite. 27 | t assert: (t inputFileName with: t outputFileName sessionDo: 28 | [| :file1 :file2 | file1 hasSameContentsAs: file2] &mode: File Read) 29 | ]. 30 | 31 | t@(UnitTests File traits) suite 32 | [t suiteForSelectors: { 33 | #testLocatorConversion. 34 | #testIdentityCompare. 35 | #testCopy. 36 | }]. 37 | -------------------------------------------------------------------------------- /tests/i18n.slate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n.slate -------------------------------------------------------------------------------- /tests/i18n/bom.utf16be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom.utf16be.html -------------------------------------------------------------------------------- /tests/i18n/bom.utf16le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom.utf16le.html -------------------------------------------------------------------------------- /tests/i18n/bom.utf32be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom.utf32be.html -------------------------------------------------------------------------------- /tests/i18n/bom.utf32le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom.utf32le.html -------------------------------------------------------------------------------- /tests/i18n/bom_utf16be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom_utf16be.html -------------------------------------------------------------------------------- /tests/i18n/bom_utf16be.utf16.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom_utf16be.utf16.html -------------------------------------------------------------------------------- /tests/i18n/bom_utf16le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom_utf16le.html -------------------------------------------------------------------------------- /tests/i18n/bom_utf16le.utf16.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom_utf16le.utf16.html -------------------------------------------------------------------------------- /tests/i18n/bom_utf32be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom_utf32be.html -------------------------------------------------------------------------------- /tests/i18n/bom_utf32le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom_utf32le.html -------------------------------------------------------------------------------- /tests/i18n/bom_utf32le.utf32.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/bom_utf32le.utf32.html -------------------------------------------------------------------------------- /tests/i18n/nobom.utf16be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom.utf16be.html -------------------------------------------------------------------------------- /tests/i18n/nobom.utf16le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom.utf16le.html -------------------------------------------------------------------------------- /tests/i18n/nobom.utf32be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom.utf32be.html -------------------------------------------------------------------------------- /tests/i18n/nobom.utf32le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom.utf32le.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf16be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf16be.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf16be.utf16.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf16be.utf16.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf16le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf16le.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf16le.utf16.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf16le.utf16.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf32be.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf32be.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf32be.utf32.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf32be.utf32.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf32le.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf32le.html -------------------------------------------------------------------------------- /tests/i18n/nobom_utf32le.utf32.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/nobom_utf32le.utf32.html -------------------------------------------------------------------------------- /tests/i18n/test-bom16be: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/test-bom16be -------------------------------------------------------------------------------- /tests/i18n/test-bom16le: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/test-bom16le -------------------------------------------------------------------------------- /tests/i18n/test-nobom16be: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/test-nobom16be -------------------------------------------------------------------------------- /tests/i18n/test-nobom16le: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/i18n/test-nobom16le -------------------------------------------------------------------------------- /tests/init.slate: -------------------------------------------------------------------------------- 1 | testing. "Force autoloading some files if neccessary" 2 | load: 'src/lib/tokenizer.slate'. 3 | load: 'src/lib/array-words.slate'. 4 | 5 | load: 'tests/bytearray.slate'. 6 | load: 'tests/dictionary.slate'. 7 | load: 'tests/file.slate'. 8 | load: 'tests/mapoverlay.slate'. 9 | "load: 'tests/matrix.slate'." 10 | load: 'tests/numeric.slate'. 11 | load: 'tests/path.slate'. 12 | load: 'tests/range.slate'. 13 | load: 'tests/syntax.slate'. 14 | load: 'tests/test.slate'. 15 | load: 'tests/array-words.slate'. 16 | load: 'tests/sequence.slate'. 17 | 18 | (#SmartConsole isFoundOn: {lobby}) 19 | ifTrue: [ 20 | load: 'src/plugins/smart-console/init.slate'. 21 | load: 'tests/smartconsole.slate'] 22 | ifFalse: [inform: 'Skipped loading smart console tests because the plugin is not loaded']. 23 | 24 | "load: 'tests/benchmark/init.slate'." 25 | load: 'tests/regression/init.slate'. 26 | -------------------------------------------------------------------------------- /tests/mapoverlay.slate: -------------------------------------------------------------------------------- 1 | UnitTests definePrototype: #MapOverlay &basis: TestCase. 2 | 3 | "Tests the MapOverlay class" 4 | 5 | t@(UnitTests MapOverlay traits) setUp 6 | [ 7 | t addSlot: #d1 valued: Dictionary new 8 | `>> [ add: 'one' -> 'Uno'. add: 'two' -> 'dos'. ]. 9 | t addSlot: #d2 valued: Dictionary new 10 | `>> [ add: 'two' -> 'Dos'. add: 'three' -> 'Tres'. ]. 11 | 12 | t addSlot: #mapOverlay valued: (t d1 overlayWith: t d2). 13 | ]. 14 | 15 | t@(UnitTests MapOverlay traits) testAccess 16 | [ 17 | t assert: ((t mapOverlay at: 'one') = 'Uno'). 18 | t assert: ((t mapOverlay at: 'two') = 'Dos'). 19 | t assert: ((t mapOverlay at: 'three') = 'Tres'). 20 | t should: [t mapOverlay at: 'four'] raise: MapOverlay KeyNotFound. 21 | ]. 22 | 23 | t@(UnitTests MapOverlay traits) testAddition 24 | [ 25 | t mapOverlay add: 'five' -> 'Cinco'. 26 | t assert: ((t mapOverlay at: 'five') = 'Cinco'). 27 | t assert: ((t d2 at: 'five') = 'Cinco'). 28 | t should: [t d1 at: 'five'] raise: MapOverlay KeyNotFound. 29 | ]. 30 | 31 | t@(UnitTests MapOverlay traits) suite 32 | [t suiteForSelectors: { 33 | #testAccess. 34 | #testAddition. 35 | }]. 36 | -------------------------------------------------------------------------------- /tests/match.slate: -------------------------------------------------------------------------------- 1 | 2 | assert: (Nil matches: Nil). 3 | 4 | assert: (Nil matches: 4). 5 | 6 | assert: (lobby matches: Nil). 7 | 8 | assert: ({} matches: {}). 9 | 10 | assert: ({1. 2. 3} matches: {1. 2. 3}). 11 | 12 | assert: ({Nil. 2} matches: {2. Nil}). 13 | 14 | assert: ({1. 2. {3. 4}} matches: {Nil. 2. {3. Nil}}). 15 | -------------------------------------------------------------------------------- /tests/matrix.slate: -------------------------------------------------------------------------------- 1 | UnitTests define: #Matrix &parents: {TestCase} &slots: { 2 | "3x3 Matrices" 3 | #affineScale -> (Matrix newFromArrayOfArrays: {{2 . 0 . 0} . {0 . 2 . 0} . {0 . 0 . 1}}). 4 | #affineTranslate -> (Matrix newFromArrayOfArrays: {{1 . 0 . 0} . {0 . 1 . 0} . {2 . 2 . 1}}). 5 | #affineRotate -> (Matrix newFromArrayOfArrays: {{2 . 2 . 0} . {-3 . 3 . 0} . {0 . 0 . 1}}). 6 | #affineReflect -> (Matrix newFromArrayOfArrays: {{1 . 0 . 0} . {0 . -1 . 0} . {0 . 0 . 1}}). 7 | #affineShear -> (Matrix newFromArrayOfArrays: {{1 . 2 . 0} . {0 . 1 . 0} . {0 . 0 . 1}}). 8 | #affineTransform -> (UnitTests Matrix affineScale * UnitTests Matrix affineTranslate * UnitTests Matrix affineRotate * UnitTests Matrix affineReflect * UnitTests Matrix affineShear). 9 | #zero -> (Matrix newRows: 3 columns: 3). 10 | #identity -> (Matrix newIdentitySize: 3). 11 | "2x3 Matrices" 12 | "Column Vectors" 13 | "Bezier Curves" 14 | #bezierPoints -> (Matrix newFromArrayOfArrays: {{1} . {2} . {3} . {4}}). 15 | "From wikipedia http://en.wikipedia.org/wiki/B%E9zier_curve" 16 | #bezierMatrix -> (Matrix newFromArrayOfArrays: {{1 . 0 . 0 . 0} . {(1 / 2) . (1 / 2) . 0 . 0} . {(1 / 4) . (2 / 4) . (1 / 4) . 0} . {(1 / 8) . (3 / 8) . (3 / 8) . (1 / 8)}}) 17 | }. 18 | 19 | t@(UnitTests Matrix traits) testAddition 20 | [ 21 | t assert: t affineScale + t affineRotate = (Matrix newFromArrayOfArrays: {{4 . 2 . 0} . {-3 . 5 . 0} . {0 . 0 . 2}}). 22 | ]. 23 | 24 | t@(UnitTests Matrix traits) testMultiplication 25 | [ 26 | t assert: t bezierMatrix * t bezierPoints = (Matrix newFromArrayOfArrays: {{1} . {(3 / 2)} . {2} . {(5 / 2)}}). 27 | ]. 28 | 29 | t@(UnitTests Matrix traits) suite 30 | [t suiteForSelectors: { 31 | #testAddition. 32 | #testMultiplication. 33 | }]. 34 | -------------------------------------------------------------------------------- /tests/pidgin.slate: -------------------------------------------------------------------------------- 1 | (VM define: #Memory &builder: [C Module new]) enter. 2 | 3 | addSynonymNamed: #Word of: UnsignedLongInt. 4 | Word export. 5 | 6 | addSynonymNamed: #Bool of: UnsignedLongInt. 7 | Bool export. 8 | 9 | define: #True -> 1 &type: Bool &export: True. 10 | define: #False -> 0 &type: Bool &export: True. 11 | define: #Nil -> 0 &type: Void pointer &export: True. 12 | 13 | define: #Map &slots: {} &export: True. 14 | 15 | define: #ObjectHeader &slots: {} &export: True. 16 | 17 | define: #Object &export: True &slots: 18 | {#header -> ObjectHeader. 19 | #map -> Map pointer}. 20 | -------------------------------------------------------------------------------- /tests/regex.slate: -------------------------------------------------------------------------------- 1 | load: 'src/lib/regex.slate'. 2 | 3 | "UnitTests definePrototype: #Regex &basis: TestCase. 4 | 5 | tc@(UnitTests Regex traits) shouldMatch: string against: regex withMatches: c 6 | [| matcher | 7 | inform: 'Testing regex: ' ; regex. 8 | matcher: (Regex Parser compileRegex: regex). 9 | matcher 10 | ifNil: [c ifNil: [inform: 'Compilation error as expected.'] 11 | ifNotNil: [inform: 'Compilation error, Unexpected!'. 12 | tc failures: tc failures + 1]] 13 | ifNotNil: [c ifNil: [inform: 'Compilation succeeded, should have failed!'. 14 | tc failures: tc failures + 1] 15 | ifNotNil: [c do: [| :eachMatch | ]]] 16 | ]. 17 | 18 | tc@(UnitTests Regex traits) testSimple 19 | [| src | 20 | src: 'abc'. 21 | tc shouldMatch: string against: string withMatches: {1. 'abc'}. 22 | tc shouldMatch: string against: 'xbc' withMatches: Nil. 23 | tc shouldMatch: string against: 'axc' withMatches: Nil. 24 | tc shouldMatch: string against: 'abx' withMatches: Nil. 25 | ]. 26 | " 27 | 28 | _@lobby testURLMatch 29 | [ 30 | r ::= Regex Matcher for: '^(([^:/?#]+)X)?(//([^/?#]*))?([^?#]*)(Z([^#]*))?(#(.*))?'. 31 | (r matches: 'httpX//www.foo.com/ra/ra/raZa=b') printOn: Console writer. 32 | 1 to: 10 do: [ | :a | Console ; (a as: '') ; ' ' . (r subexpression: a) printOn: Console writer. Console ; '\n']. 33 | ]. 34 | 35 | -------------------------------------------------------------------------------- /tests/regression/init.slate: -------------------------------------------------------------------------------- 1 | load: 'tests/regression/shootout.slate'. 2 | load: 'tests/regression/wordcount.slate'. 3 | load: 'tests/regression/collection.slate'. 4 | -------------------------------------------------------------------------------- /tests/regression/mandelbrot.gold: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/briantrice/slate-language/cc65a4fa073e27310d926cf2aa02d2cfe3efb036/tests/regression/mandelbrot.gold -------------------------------------------------------------------------------- /tests/regression/wordcount.slate: -------------------------------------------------------------------------------- 1 | RegressionTests definePrototype: #WordCount &basis: TestCase. 2 | "A regression test playing with the LICENSE file" 3 | 4 | t@(RegressionTests WordCount traits) testFileName 5 | [ 6 | 'LICENSE' 7 | ]. 8 | 9 | t@(RegressionTests WordCount traits) testWordCount 10 | [ 11 | words ::= Bag new. 12 | (File newNamed: t testFileName &mode: File Read) sessionDo: 13 | [| :file | 14 | file reader split >> words writer. 15 | ]. 16 | "Console ; 'Number of different words ' ; (words size as: String) ; '\n'." 17 | t assert: words size = 170 description: 'The number of words found in the LICENSE file is not as expected.'. 18 | ]. 19 | 20 | t@(RegressionTests WordCount traits) testLineCount 21 | "Note that empty lines will be ignored by #splitWith: " 22 | [| lineCount | 23 | lineCount := 0. 24 | (File newNamed: t testFileName &mode: File Read) sessionDo: 25 | [| :file | 26 | (file reader splitWith: { $\n }) do: 27 | [| :line | lineCount += 1]. 28 | ]. 29 | "Console ; 'Number of lines ' ; (lineCount as: String) ; '\n'." 30 | t assert: lineCount = 16 description: 'The number of lines found in the LICENSE file is not as expected.'. 31 | ]. 32 | 33 | t@(RegressionTests WordCount traits) suite 34 | [t suiteForSelectors: { 35 | #testLineCount. 36 | #testWordCount. 37 | }]. 38 | -------------------------------------------------------------------------------- /tests/rot13.sh: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/slate 2 | 3 | ch@(String Character traits) rot13 4 | [| value upper | 5 | upper: ch isUppercase. 6 | value: (ch toLowercase as: Integer). 7 | (value >= 97) /\ (value < 110) 8 | ifTrue: [value: value + 13] 9 | ifFalse: [(value > 109) /\ (value <= 122) 10 | ifTrue: [value: value - 13]]. 11 | upper 12 | ifTrue: [(value as: String Character) toUppercase] 13 | ifFalse: [value as: String Character] 14 | ]. 15 | 16 | s@(String traits) rot13 17 | [| result | 18 | result: s newSameSize. 19 | s doWithIndex: [| :each :index | 20 | result at: index put: each rot13]. 21 | result 22 | ]. 23 | 24 | lobby define: #Rot13Encoder &parents: {Encoder}. 25 | 26 | 27 | c@(Rot13Encoder traits) convert 28 | [ 29 | [c in isAtEnd] whileFalse: [c out nextPut: c in next rot13]. 30 | ]. 31 | 32 | 33 | (Rot13Encoder newFrom: Console reader to: Console writer) convert. 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/sequence.slate: -------------------------------------------------------------------------------- 1 | testing UnitTests define: #Sequence &parents: {TestCase}. 2 | 3 | tc@(UnitTests Sequence traits) testCopyReplaceAll 4 | [| s1 s2 | 5 | s1 := 'slate'. 6 | s2 := s1 copyReplaceAll: 's' with: 'S'. 7 | tc assert: (s2 = 'Slate'). 8 | 9 | s2 := s1 copyReplaceAll: 'e' with: 'ed'. 10 | tc assert: (s2 = 'slated'). 11 | 12 | s1 := 'SlSlate'. 13 | s2 := s1 copyReplaceAll: 'SlSl' with: 'Sl'. 14 | tc assert: (s2 = 'Slate'). 15 | 16 | s1 := 'Slete'. 17 | s2 := (s1 copyReplaceAll: 'e' with: 'a') copyReplaceAll: 'ta' with: 'te'. 18 | tc assert: (s2 = 'Slate'). 19 | ]. 20 | 21 | tc@(UnitTests Sequence traits) suite 22 | [tc suiteForSelectors: { 23 | #testCopyReplaceAll. 24 | }]. 25 | -------------------------------------------------------------------------------- /tests/socket.slate: -------------------------------------------------------------------------------- 1 | load: 'src/mobius/c/types.slate'. 2 | load: 'src/lib/extlib.slate'. 3 | load: 'src/lib/net/socket.slate'. 4 | load: 'src/plugins/socket/unix/socket.slate'. 5 | 6 | addSlot: #s valued: (Net Socket open: 'localhost' port: 22). 7 | addSlot: #b valued: (ByteArray newSize: 20). 8 | 9 | Console ; ((s reader next: 5) as: String). 10 | s writer nextPut: $b. 11 | s writer nextPut: $o. 12 | s writer nextPut: $o. 13 | -------------------------------------------------------------------------------- /tests/sorted.slate: -------------------------------------------------------------------------------- 1 | UnitTests define: #SortedArray &parents: {UnitTests ExtensibleArray}. 2 | 3 | tc@(UnitTests SortedArray traits) testIndexForInsertingAsLastElement 4 | [ 5 | se ::= SortedArray new. 6 | insertIndex ::= se indexForInserting: 1. 7 | tc assert: insertIndex = 0 description: 'Empty SortedArray should insert to 0.'. 8 | se at: insertIndex insert: 1. 9 | 2 upTo: 10 do: [| :ind insertAt | 10 | insertAt := se indexForInserting: ind. 11 | tc assert: insertAt = (ind - 1) 12 | description: 'SortedArray should maintain sort order for: ' ; (ind as: String). 13 | se at: insertAt insert: 1]. 14 | ]. 15 | 16 | tc@(UnitTests SortedArray traits) testAddByInsert 17 | [ 18 | se ::= SortedArray new. 19 | 0 below: 10 do: [| :ind | se add: ind + 1]. 20 | tc assert: se size = 10 description: '#add: should increase size.'. 21 | ]. 22 | 23 | tc@(UnitTests SortedArray traits) suite 24 | [ 25 | tc suiteForSelectors: { 26 | #testIndexForInsertingAsLastElement. 27 | #testAddByInsert 28 | } 29 | ]. 30 | -------------------------------------------------------------------------------- /tests/stream.slate: -------------------------------------------------------------------------------- 1 | testing UnitTests define: #Stream &parents: {TestCase}. 2 | "Unit tests for Stream semantics." 3 | 4 | "---------------------------------------------------------------------------" 5 | "The build... methods can be overridden in subinstances to allow 6 | testing of different kinds of stream. The tests in the base stream 7 | class exercise just the common stream protocols." 8 | 9 | tc@(UnitTests Stream traits) buildEmptyReader 10 | ['' reader]. 11 | 12 | tc@(UnitTests Stream traits) buildReader 13 | ['hello' reader]. 14 | 15 | tc@(UnitTests Stream traits) expectedReaderFirstElement 16 | [$h]. 17 | 18 | tc@(UnitTests Stream traits) testExhaustionOnEmptyReader 19 | [tc should: ['' reader next] raise: Stream Exhaustion]. 20 | 21 | tc@(UnitTests Stream traits) testReaderFirstElement 22 | [tc assert: (tc buildReader next = tc expectedReaderFirstElement)]. 23 | 24 | tc@(UnitTests Stream traits) suite 25 | [tc suiteForSelectors: { 26 | #testExhaustionOnEmptyReader. 27 | #testReaderFirstElement. 28 | }]. 29 | -------------------------------------------------------------------------------- /tests/testuni.txt: -------------------------------------------------------------------------------- 1 | Czech and Slovak characters: š ť ž ľ č ě ď ň ř ů ĺ Š Ť Ž Ľ Č Ě Ď Ň Ř Ů Ĺ 2 | Polish Characters: ł ą ż ę ć ń ś ź Ł Ą Ż Ę Ć Ń Ś Ź 3 | Romanian characters: Ă ă Ş ş Ţ ţ 4 | Croatian and Slovenian characters: š č ž ć đ Š Č Ž Ć Đ 5 | Hungarian characters: Ő ő Ű ű 6 | German characters: Ä, ä, Ö, ö, Ü, ü, ß 7 | Russian alphabet: абвгдеёжзийклмно прстуфхцчшчьыъэюя АБВГДЕЁЖЗИЙ КЛМНОПРСТУФ ХЦЧШЩЬЫЪЭЮЯ 8 | Special Byelorussian and Ukrainian characters: Ў ў Є є Ґ ґ 9 | Special Serbian and Macedonian characters: Ђ Љ Њ Ћ Џ ђ љ њ ћ џ 10 | Spanish special characters: Á, á, É, é, Í, í, Ó, ó, Ú, ú, Ü, ü, Ñ, ñ 11 | Esperanto special characters: Ĉ, ĉ, Ĝ, ĝ, Ĥ, ĥ, Ĵ, ĵ, Ŝ, ŝ, Ŭ, ŭ 12 | --------------------------------------------------------------------------------