In one of my previous posts I wrote about beeScript.
BeeScript is meant to be an automation language for diskotek.
This post is a more detailed description.
Right now it is in early development so this is the description of how it is developed and what state it is in.
This is a list of what is currently implemented regarding the communication with the backend:
a = memory.place
sending gdb commands
s disas /rm $eip-40, $eip+40
One can use control flow structures, function definitions, variable definitions, expressions.
Some might be developed further.
now the look on the internals of how it all works
- parser is jison generated and is located in beeScript.jison
- interface for code generator is located in compiler.coffee.
it contains bunch of functions that are called when parsers productions are reduced. That class is meant to bee extended
by any code/ast generator.
beeScriptRunner & stack machine vm
example of one such generator is in beeScriptRunner.coffee. It is a generator for stack machine vm written in coffee script.
The stack machine vm has two stacks.
- expression stack. Used to calculate and assign stuff
- call stack. Used for method invocation
variables are stored in
@variables is an object whose properties are variable names
functions are stored in
there is also diskotekLib that is an object containing functions that interface with the backend.
It provides easy extensiblity for the script one can use functions from it by just calling them like functions defined in beeScript.
There is only one argument passed that is ref to expression stack like so.
Parameters are on the stack so one just needs to pop them.
Care must be taken to leave the stack in state so that rest of the code works.
One would define a function with python like syntax without the : at the end like so
def func(param1, param2)
param1 = param2
It is important to put that newline at the end of the function. That newline means end of a function. That may be slightly modified.
Arguments are searched first in function block and then global scope. That may change.
There are special variables:
That list may change.
Memory special variable can be used for reading from and writing to memory.
This is an example of reading:
//create a variable that has an address from where to read memory from
memoryLocation = 0x80000000
//read from memory
contentsOfMemLocation = memory.memoryLocation
In the background reading works like cache memory with block access. First it tries to access location if it is not there it asks the backend.
What is returned is a dictionary that looks like this
Then calls access function one more time and gets it.
This is an example of writing:
//create a variable that has an address where we want to write to memory
memoryLocation = 0x80000000
//assemble and write to memory
memory.memoryLocation = 'nop'
This post may be updated so that it can be used as a reference for the beeScript in the future.