Programmers Reference

Previous Next

Introduction.

This documentation is a manual for the SCRAMBLECODE programming language. It can be read in a sequential order - however most of the time it will probably serve as a reference for looking up particular subjects.


It provides detailed information about four major issues:


Before diving into the next chapters, please read the rest of this page to get the big picture to each of the 4 issues.



How to Write Your Program.

SCRAMBLECODE is a simple, high level, class based, curly bracket language.


The source code is written in the editor and compiled into bytecode using the compiler. They are both an integrated part of the Integrated Development Environment (IDE).


SCRAMBLECODE targets the development of well structured and type safe code, and to a certain extent resembles the structure of other languages in order to facilitate easy code replacement. Anyone familiar with either C++, Java, C#, Python, Pascal etc. can quickly learn to program in SCRAMBLECODE.


The class aspect of SCRAMBLECODE supports data encapsulation, reference based method invocation and overloaded methods. However, it does not support full object oriented programming – e.g inheritance is not supported.



How to Execute the ByteCode.

A SCRAMBLECODE project must always include at least the Main class and the Main function as presented here. This constitutes the entry point at which execution of the bytecode starts and ends.


Class Main

{

 Public Function Main(Integer x, y, z) : Integer

 {

   //...execution starts here...

 }

}


Please notice, that the Main function only has a few simple input parameters. In order to transfer thousands of complex parameters to or from a VM, you can use the VM cells as presented next.



How to Transfer Values.

Each VM has a public storage space named VM cells. This storage is defined as a two-dimensional grid with rows and columns of data cells. It works very much like a spreadsheet where each cell can either be empty or contain a value:


COLUMNS

-1

0

1

2

ROWS






-1






0



123

"My string"

0x12FF4E

1



456

"And yours"

0x3355EF

2


"Hello"

"How"

"Are"

"You"


You can use cells to transport data from the host application to the VM, or from one VM to another. Rows and columns are 32 bit integers providing an index range of 232 x 232 (also having negative indexes).


VM cells allow for a very flexible way of transporting lots of values/parameters to a VM before calling the Main function. And the results can be placed in cells as well to be returned to the calling VM or host application.


Please notice the possibilities for using the cells as data records, although each cell is completely independent of the others.



How to Integrate the DLL.

Your application is known as the host.


The host loads the SCRAMBLECODE DLL in order to execute the bytecode. The DLL has an API that provide the host with a number of functions to access each running VM and their cells. The host communicates with the DLL in a manner, that is very similar to how one VM internally can call another VM.


The host can also provide a callback function to a VM. While executing the bytecode, the VM can invoke the callback function as a simple command. Once the callback is done, execution returns from the host to let the VM continue the bytecode execution.


The host can also have the DLL execute multiple VMs in parallel using multiple threads.