NebulousLabs/Sia — pull request #133 by lukechampine (2014-06-03 00:52:28+00:00)
Title: Bytecode scripting

This changed introduces "real" scripting based on a simple bytecode. The bytecode is defined in bytecode_spec.md. Reflection is used to call go functions associated with each opcode.

Scripts are divided into "code" and "data" blocks by the `0xFF` separator byte. Execution ends when this byte is encountered, or when the maximum number of instructions has been reached. Scripts can load and/or modify any byte contained in either the code or data blocks. This means that scripts can change their own behavior during execution.

The largest limitation of the current interpreter is that it can only operate on byte values. That sets a maximum of 255 for all values (e.g. only 255 bytes in the data block are addressable). This needs to be extended such that multiple bytes can be interpreted as shorts, ints, floats, etc.

The cost calculation is also fairly simplistic, with a specific cost associated with every opcode. This can be refined later.