Add a execution and memory stack
This commit is contained in:
parent
53754ecf6e
commit
c87af3d10e
2 changed files with 48 additions and 1 deletions
|
@ -50,3 +50,50 @@ abstract class SLEvents {
|
||||||
void touch_start(Integer iTouchesCount);
|
void touch_start(Integer iTouchesCount);
|
||||||
void transaction_result(Key kID, Integer iSuccess, string sMessage);
|
void transaction_result(Key kID, Integer iSuccess, string sMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Custom execution stack to mimic compilation behavior
|
||||||
|
/// A script is composed of states, which have every event listed in SLEvents, or OSEvents which inherits SLEvents
|
||||||
|
/// Each event will be composed of an execution stack. Custom function can be defined, they shall be stored in a dictionary with their execution stack
|
||||||
|
///
|
||||||
|
/// The execution stack should execute each function contained within in sequential order.
|
||||||
|
///
|
||||||
|
/// The execution stack cannot be altered once created, it is designed to be assembled, then executed, to change it, one must create a new stack.
|
||||||
|
///
|
||||||
|
/// Variables are defined in the SLMemoryStack.
|
||||||
|
/// On parse, a variable will be created, then inserted into the memory stack. Naming convention is as follows.
|
||||||
|
/// global: g_<name>
|
||||||
|
/// global_function: g_f<name>
|
||||||
|
/// local: <state>_<event>_<name>
|
||||||
|
///
|
||||||
|
/// Any function here will need to be parsed properly to edit the memory stack if applicable before adding it to the execution stack
|
||||||
|
///
|
||||||
|
/// NOTE: Dart does not have a JIT Compiler that can at runtime without the Dart SDK compile a dynamic dart script against the running application
|
||||||
|
/// To make up for this, we must put in place a structure that would allow parsing the script and still allowing execution within our own codebase.
|
||||||
|
class SLExecutionStack {
|
||||||
|
List<Function> _stack = [];
|
||||||
|
|
||||||
|
void add(Function fnc) {
|
||||||
|
_stack.add(fnc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void execute() {
|
||||||
|
for (var f in _stack) {
|
||||||
|
f.call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This memory stack is meant to be allocated per script. See naming convention specified in SLExecutionStack documentation
|
||||||
|
///
|
||||||
|
/// NOTE: If memory is not present, it will return a blank string
|
||||||
|
class SLMemoryStack {
|
||||||
|
Map<String, dynamic> _memory = {};
|
||||||
|
|
||||||
|
void set(String name, dynamic memory) {
|
||||||
|
_memory[name] = memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic get(String name) {
|
||||||
|
return _memory[name] ?? "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: libac_dart
|
name: libac_dart
|
||||||
description: "Aria's Creations code library"
|
description: "Aria's Creations code library"
|
||||||
version: 1.2.082224+1433
|
version: 1.2.082224+1532
|
||||||
homepage: "https://zontreck.com"
|
homepage: "https://zontreck.com"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue