diff --git a/lib/omv/events.dart b/lib/omv/events.dart index e41a98e..ff8bc02 100644 --- a/lib/omv/events.dart +++ b/lib/omv/events.dart @@ -50,3 +50,50 @@ abstract class SLEvents { void touch_start(Integer iTouchesCount); 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_ +/// global_function: g_f +/// local: __ +/// +/// 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 _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 _memory = {}; + + void set(String name, dynamic memory) { + _memory[name] = memory; + } + + dynamic get(String name) { + return _memory[name] ?? ""; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index f29eb33..b514264 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libac_dart description: "Aria's Creations code library" -version: 1.2.082224+1433 +version: 1.2.082224+1532 homepage: "https://zontreck.com"