|
ScriptStack 1.0.5
|
The Interpreter finally interprets the parse tree in form of a token stream returned from the ScriptStack.Compiler.Parser. More...
Classes | |
| class | FunctionFrame |
| For every forward declared function, a new function frame is created including a memory object holding its local variables. The values are pushed on the stack before they are called. More... | |
Public Member Functions | |
| Interpreter (Function function, List< object > parameters, InterpreterOptions? options=null) | |
| Interpreter (Function function) | |
| Interpreter (Script script, List< object > parameters, InterpreterOptions? options=null) | |
| Interpreter (Script script, InterpreterOptions? options=null) | |
| void | Reset () |
| uint | Interpret (uint instructions) |
| uint | Interpret (TimeSpan interval) |
| uint | Interpret () |
Properties | |
| Script | Script [get] |
| bool | Interrupt [get, set] |
| ReadOnlyCollection< Interpreter > | Jobs [get] |
| bool | Interrupted [get] |
| bool | Finished [get] |
| int | NextInstruction [get] |
| ReadOnlyCollection< Function > | FunctionStack [get] |
| ReadOnlyCollection< object > | ParameterStack [get] |
| Memory | LocalMemory [get] |
| Host | Handler [get, set] |
Private Member Functions | |
| int | ToInt32Bitwise (object value, string opName="bitwise") |
| object | Evaluate (Operand operand) |
| void | Assignment (Operand dst, object val) |
| void | Arithmetic () |
| Ausführung arithmetischer Operationen. | |
| void | Relation () |
| Ausführung einer Vergleichsoperation. | |
| void | Logic () |
| Usually its a boolean operation but it allows numerics too. | |
| void | Iterator (ArrayList array) |
| void | Iterator (IDictionary dict) |
| void | Iterator (string str) |
| void | DBG () |
| void | NOP () |
| void | INT () |
| void | RET () |
| Return from current function frame to the last one on the stack, copying local memory to the new one. | |
| void | PUSH () |
| void | POP () |
| Pop a value from the stack into an atom. | |
| void | MOV () |
| Basic assignment. | |
| void | ADD () |
| void | SUB () |
| void | MUL () |
| void | DIV () |
| void | MOD () |
| void | INC () |
| void | DEC () |
| void | NEG () |
| Negate a literal (* -1). | |
| void | SHL () |
| void | SHR () |
| void | TEST () |
| void | CEQ () |
| void | CNE () |
| void | CG () |
| void | CGE () |
| void | CL () |
| void | CLE () |
| void | OR () |
| void | AND () |
| void | NOT () |
| Negate a boolean or int. | |
| void | ORB () |
| void | ANDB () |
| void | NOTB () |
| void | XOR () |
| void | JMP () |
| Jump to the address the first operator points at. | |
| void | JZ () |
| Jump to the instruction the second operand is pointing at if the first operand is true. | |
| void | JNZ () |
| Jump to the instruction the second operand is pointing at if the first operand is false. | |
| void | DSB () |
| void | DB () |
| void | DC () |
| void | DCO () |
| void | PTR () |
| A pointer in foreach loops. | |
| void | CALL () |
| Call a Function. | |
| void | INV () |
| Invoke a Routine, if no result is specified a null is pushed onto the stack. | |
| void | MIV () |
| Invoke a CLR instance method via reflection. | |
| void | RUN () |
| Run a Function in Background. | |
| void | LOCK () |
| void | FREE () |
| uint | ExecuteBackgroundJobs () |
| void | ExecuteInstruction () |
| void | Iterator (IList list) |
Private Attributes | |
| Function | function |
| Script | script |
| Executable | executable |
| Stack< FunctionFrame > | functionStack |
| Stack< object > | parameterStack |
| Dictionary< object, Instruction > | locks |
| List< Interpreter > | jobs |
| Instruction | instruction |
| Memory | localMemory |
| bool | interrupt |
| bool | interrupted |
| bool | finished |
| ClrBridge | _clr |
| InterpreterOptions | _options |
| Host | host |
The Interpreter finally interprets the parse tree in form of a token stream returned from the ScriptStack.Compiler.Parser.
Definition at line 17 of file Interpreter.cs.
| ScriptStack.Runtime.Interpreter.Interpreter | ( | Function | function, |
| List< object > | parameters, | ||
| InterpreterOptions? | options = null ) |
Definition at line 1874 of file Interpreter.cs.
References _clr, _options, executable, functionStack, host, interrupt, jobs, locks, parameterStack, Reset(), and script.
Referenced by ExecuteBackgroundJobs(), LOCK(), and RUN().
| ScriptStack.Runtime.Interpreter.Interpreter | ( | Function | function | ) |
Definition at line 1935 of file Interpreter.cs.
References function.
| ScriptStack.Runtime.Interpreter.Interpreter | ( | Script | script, |
| List< object > | parameters, | ||
| InterpreterOptions? | options = null ) |
Definition at line 1940 of file Interpreter.cs.
| ScriptStack.Runtime.Interpreter.Interpreter | ( | Script | script, |
| InterpreterOptions? | options = null ) |
Definition at line 1945 of file Interpreter.cs.
|
private |
Definition at line 951 of file Interpreter.cs.
References Arithmetic().
|
private |
Definition at line 1217 of file Interpreter.cs.
References Logic().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1278 of file Interpreter.cs.
References Evaluate(), instruction, localMemory, ToInt32Bitwise(), ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by ExecuteInstruction().
|
private |
Ausführung arithmetischer Operationen.
dest = dest OP source
Special rules for strings and arrays
Definition at line 298 of file Interpreter.cs.
References Assignment(), Evaluate(), instruction, and ScriptStack.Compiler.String.
Referenced by ADD(), DIV(), ExecuteInstruction(), MOD(), MUL(), and SUB().
|
private |
| dst | |
| val |
Definition at line 235 of file Interpreter.cs.
References _clr, localMemory, ScriptStack.Runtime.Operand.Member, ScriptStack.Runtime.Operand.Pointer, ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by Arithmetic(), Logic(), MOV(), POP(), and Relation().
|
private |
Call a Function.
Definition at line 1517 of file Interpreter.cs.
References ScriptStack.Runtime.Memory.AllocateLocalMemory(), executable, functionStack, and instruction.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1165 of file Interpreter.cs.
References Relation().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1181 of file Interpreter.cs.
References Relation().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1189 of file Interpreter.cs.
References Relation().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1197 of file Interpreter.cs.
References Relation().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1205 of file Interpreter.cs.
References Relation().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1173 of file Interpreter.cs.
References Relation().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1406 of file Interpreter.cs.
References instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
|
private |
Definition at line 1413 of file Interpreter.cs.
References instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1425 of file Interpreter.cs.
References Evaluate(), instruction, localMemory, ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1027 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
Definition at line 975 of file Interpreter.cs.
References Arithmetic().
|
private |
Definition at line 1399 of file Interpreter.cs.
Referenced by ExecuteInstruction().
|
private |
Definition at line 93 of file Interpreter.cs.
References _clr, localMemory, ScriptStack.Runtime.Operand.Member, ScriptStack.Runtime.Operand.Pointer, ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by ANDB(), Arithmetic(), DCO(), DEC(), FREE(), INC(), Iterator(), Iterator(), Iterator(), Iterator(), JNZ(), JZ(), LOCK(), Logic(), MOV(), NEG(), NOT(), NOTB(), ORB(), PUSH(), Relation(), SHL(), SHR(), TEST(), and XOR().
|
private |
Definition at line 1784 of file Interpreter.cs.
References Finished, Interpret(), Interpreter(), and jobs.
Referenced by Interpret(), Interpret(), and Interpret().
|
private |
Definition at line 1801 of file Interpreter.cs.
References AND(), ANDB(), Arithmetic(), CALL(), CEQ(), CG(), CGE(), CL(), CLE(), CNE(), DB(), DBG(), DC(), DCO(), DEC(), DSB(), executable, FREE(), functionStack, INC(), instruction, INT(), INV(), JMP(), JNZ(), JZ(), LOCK(), MIV(), MOV(), NEG(), NOP(), NOT(), NOTB(), OR(), ORB(), POP(), PTR(), PUSH(), RET(), RUN(), SHL(), SHR(), TEST(), and XOR().
Referenced by Interpret(), Interpret(), and Interpret().
|
private |
Definition at line 1766 of file Interpreter.cs.
References Evaluate(), instruction, locks, and script.
Referenced by ExecuteInstruction().
|
private |
Definition at line 993 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
Definition at line 893 of file Interpreter.cs.
References interrupted.
Referenced by ExecuteInstruction().
| uint ScriptStack.Runtime.Interpreter.Interpret | ( | ) |
Definition at line 2039 of file Interpreter.cs.
References ExecuteBackgroundJobs(), ExecuteInstruction(), Finished, interrupted, and localMemory.
| uint ScriptStack.Runtime.Interpreter.Interpret | ( | TimeSpan | interval | ) |
Definition at line 2008 of file Interpreter.cs.
References ExecuteBackgroundJobs(), ExecuteInstruction(), Finished, interrupted, and localMemory.
| uint ScriptStack.Runtime.Interpreter.Interpret | ( | uint | instructions | ) |
Definition at line 1982 of file Interpreter.cs.
References ExecuteBackgroundJobs(), ExecuteInstruction(), Finished, interrupted, and localMemory.
Referenced by ExecuteBackgroundJobs().
|
private |
Invoke a Routine, if no result is specified a null is pushed onto the stack.
The Verify() function will skip null and void parameters.
Definition at line 1540 of file Interpreter.cs.
References ScriptStack.Runtime.Routine.Handler, host, instruction, interrupt, interrupted, ScriptStack.Runtime.Host.Invoke(), ScriptStack.Runtime.Routine.Name, parameterStack, ScriptStack.Runtime.Routine.ParameterTypes, and ScriptStack.Runtime.Routine.Verify().
Referenced by ExecuteInstruction().
|
private |
Definition at line 771 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
Referenced by PTR().
|
private |
Definition at line 815 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
|
private |
Definition at line 2134 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
|
private |
Definition at line 856 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
|
private |
Jump to the address the first operator points at.
Definition at line 1356 of file Interpreter.cs.
References functionStack, and instruction.
Referenced by ExecuteInstruction().
|
private |
Jump to the instruction the second operand is pointing at if the first operand is false.
Definition at line 1385 of file Interpreter.cs.
References Evaluate(), functionStack, and instruction.
Referenced by ExecuteInstruction().
|
private |
Jump to the instruction the second operand is pointing at if the first operand is true.
Definition at line 1368 of file Interpreter.cs.
References ScriptStack.Runtime.Instruction.Address, Evaluate(), functionStack, and instruction.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1733 of file Interpreter.cs.
References Evaluate(), functionStack, instruction, Interpreter(), interrupted, locks, ScriptStack.Runtime.Interpreter.FunctionFrame.nextInstruction, and script.
Referenced by ExecuteInstruction().
|
private |
Usually its a boolean operation but it allows numerics too.
Definition at line 713 of file Interpreter.cs.
References Assignment(), Evaluate(), and instruction.
|
private |
Invoke a CLR instance method via reflection.
The compiler lowers
into: PUSH a; PUSH b; MIV obj.Method, <argc>; POP result
Definition at line 1598 of file Interpreter.cs.
References _clr, instruction, interrupt, interrupted, localMemory, and parameterStack.
Referenced by ExecuteInstruction().
|
private |
Definition at line 983 of file Interpreter.cs.
References Arithmetic().
|
private |
Basic assignment.
Definition at line 941 of file Interpreter.cs.
References Assignment(), Evaluate(), and instruction.
Referenced by ExecuteInstruction().
|
private |
Definition at line 967 of file Interpreter.cs.
References Arithmetic().
|
private |
Negate a literal (* -1).
Definition at line 1061 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
|
private |
Negate a boolean or int.
Definition at line 1227 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1307 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1212 of file Interpreter.cs.
References Logic().
Referenced by ExecuteInstruction().
|
private |
Definition at line 1249 of file Interpreter.cs.
References Evaluate(), instruction, localMemory, ToInt32Bitwise(), ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by ExecuteInstruction().
|
private |
Pop a value from the stack into an atom.
Definition at line 926 of file Interpreter.cs.
References Assignment(), instruction, and parameterStack.
Referenced by ExecuteInstruction().
|
private |
A pointer in foreach loops.
Definition at line 1457 of file Interpreter.cs.
References instruction, Iterator(), and localMemory.
Referenced by ExecuteInstruction().
|
private |
Definition at line 918 of file Interpreter.cs.
References Evaluate(), instruction, and parameterStack.
Referenced by ExecuteInstruction().
|
private |
Ausführung einer Vergleichsoperation.
If one of both is of type 'null' only certain operations are allowed.
If one of both is a string, both are converted to string and alphabetically evaluated.
Numbers are converted to type 'double'.
Only equations may reference null
If one of both is a string both are converted to string and alphabetically compared
Definition at line 480 of file Interpreter.cs.
References Assignment(), Evaluate(), and instruction.
| void ScriptStack.Runtime.Interpreter.Reset | ( | ) |
Definition at line 1950 of file Interpreter.cs.
References ScriptStack.Runtime.Memory.AllocateLocalMemory(), executable, finished, functionStack, instruction, interrupted, ScriptStack.Runtime.Interpreter.FunctionFrame.localMemory, localMemory, locks, parameterStack, and script.
Referenced by Interpreter().
|
private |
Return from current function frame to the last one on the stack, copying local memory to the new one.
Definition at line 901 of file Interpreter.cs.
References finished, functionStack, and localMemory.
Referenced by ExecuteInstruction().
|
private |
Run a Function in Background.
An example
Definition at line 1715 of file Interpreter.cs.
References _options, host, instruction, Interpreter(), jobs, and parameterStack.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1090 of file Interpreter.cs.
References Evaluate(), instruction, localMemory, ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by ExecuteInstruction().
|
private |
Definition at line 1121 of file Interpreter.cs.
References Evaluate(), instruction, localMemory, ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by ExecuteInstruction().
|
private |
Definition at line 959 of file Interpreter.cs.
References Arithmetic().
|
private |
Definition at line 1151 of file Interpreter.cs.
References Evaluate(), instruction, and localMemory.
Referenced by ExecuteInstruction().
|
private |
Definition at line 59 of file Interpreter.cs.
|
private |
Definition at line 1324 of file Interpreter.cs.
References Evaluate(), instruction, localMemory, ToInt32Bitwise(), ScriptStack.Runtime.Operand.Type, and ScriptStack.Runtime.Operand.Value.
Referenced by ExecuteInstruction().
|
private |
Definition at line 49 of file Interpreter.cs.
Referenced by Assignment(), Evaluate(), Interpreter(), and MIV().
|
private |
Definition at line 50 of file Interpreter.cs.
Referenced by Interpreter(), and RUN().
|
private |
Definition at line 39 of file Interpreter.cs.
Referenced by CALL(), ExecuteInstruction(), Interpreter(), and Reset().
|
private |
Definition at line 48 of file Interpreter.cs.
|
private |
Definition at line 37 of file Interpreter.cs.
Referenced by Interpreter().
|
private |
Definition at line 40 of file Interpreter.cs.
Referenced by CALL(), ExecuteInstruction(), Interpreter(), JMP(), JNZ(), JZ(), LOCK(), Reset(), and RET().
|
private |
Definition at line 57 of file Interpreter.cs.
Referenced by Interpreter(), INV(), and RUN().
|
private |
Definition at line 44 of file Interpreter.cs.
Referenced by ANDB(), Arithmetic(), CALL(), DB(), DC(), DCO(), DEC(), ExecuteInstruction(), FREE(), INC(), INV(), Iterator(), Iterator(), Iterator(), Iterator(), JMP(), JNZ(), JZ(), LOCK(), Logic(), MIV(), MOV(), NEG(), NOT(), NOTB(), ORB(), POP(), PTR(), PUSH(), Relation(), Reset(), RUN(), SHL(), SHR(), TEST(), and XOR().
|
private |
Definition at line 46 of file Interpreter.cs.
Referenced by Interpreter(), INV(), and MIV().
|
private |
Definition at line 47 of file Interpreter.cs.
Referenced by INT(), Interpret(), Interpret(), Interpret(), INV(), LOCK(), MIV(), and Reset().
|
private |
Definition at line 43 of file Interpreter.cs.
Referenced by ExecuteBackgroundJobs(), Interpreter(), and RUN().
|
private |
Definition at line 45 of file Interpreter.cs.
Referenced by ANDB(), Assignment(), DB(), DC(), DCO(), DEC(), Evaluate(), INC(), Interpret(), Interpret(), Interpret(), Iterator(), Iterator(), Iterator(), Iterator(), MIV(), NEG(), NOT(), NOTB(), ORB(), PTR(), Reset(), RET(), SHL(), SHR(), TEST(), and XOR().
|
private |
Definition at line 42 of file Interpreter.cs.
Referenced by FREE(), Interpreter(), LOCK(), and Reset().
|
private |
Definition at line 41 of file Interpreter.cs.
Referenced by Interpreter(), INV(), MIV(), POP(), PUSH(), Reset(), and RUN().
|
private |
Definition at line 38 of file Interpreter.cs.
Referenced by FREE(), Interpreter(), Interpreter(), Interpreter(), LOCK(), and Reset().
|
get |
Definition at line 2090 of file Interpreter.cs.
Referenced by ExecuteBackgroundJobs(), Interpret(), Interpret(), and Interpret().
|
get |
Definition at line 2104 of file Interpreter.cs.
|
getset |
Definition at line 2125 of file Interpreter.cs.
|
getset |
Definition at line 2074 of file Interpreter.cs.
|
get |
Definition at line 2085 of file Interpreter.cs.
|
get |
Definition at line 2080 of file Interpreter.cs.
|
get |
Definition at line 2120 of file Interpreter.cs.
|
get |
Definition at line 2095 of file Interpreter.cs.
|
get |
Definition at line 2115 of file Interpreter.cs.
|
get |
Definition at line 2069 of file Interpreter.cs.
Referenced by Interpreter(), and Interpreter().