0.01
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A Virtual Machine for the Koi programming language written in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

koi-vm-ruby¶ ↑

Koi-vm-ruby is a simple proof-of-concept Virtual Machine for the Koi programming language written in Ruby. It was created with learning in mind and is written so that it is easy to understand and play with. This virtual machine implements an instruction set specifically designed for running the Koi programming language. A compiler for producing compatible bytecode can be found at the koi-reference-compiler.

Examples¶ ↑

The standard ‘Hello world!’, KoiVM style:

require 'koi'
include KoiVMRuby

VM.new.run [
  PUSH_STRING, "Hello World!\n",
  PRINT
]

#=> Hello world!

And an old-school ‘Blast off’ example:

require 'koi'
include KoiVMRuby

VM.new.run [
  PUSH_INT, 11,
  PUSH_INT, 1,
  SUBTRACT,
  DUP,
  TO_STRING,
  PRINT,
  PUSH_STRING, ", ",
  PRINT,
  DUP,
  PUSH_INT, 0,
  EQUAL,
  JUMP_UNLESS, -13,
  PUSH_STRING, "Blast Off!\n",
  PRINT
]

#=> 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, Blast off!

Installation¶ ↑

This VM is normally installed as part of Koi’s default toolchain. However if you would like to install it on it’s own you can do so by installing the gem like so:

gem install koi-vm-ruby

Usage¶ ↑

require 'rubygems'
require 'koi-vm-ruby'

include KoiVMRuby

vm = VM.new

vm.run( bytecode )

Author & Credits¶ ↑

Author

Aaron Gough

Copyright © 2010 Aaron Gough (thingsaaronmade.com), released under the MIT license