user@elli:~/Downloads/Remote/LPC/GEM$ node harness.js tests/clone_object.c
[+] Compiling tests/clone_object.c into VM Memory...
[+] Launching Javascript V8 Native Environment...
--- BOOTING VM ---
query_x(): 42
Cloned object: <object:tests/clone_object.c#1>
OB->query_x (): 42
query_x(): 42
OB->query_x (): 999
>>> cloned <object:tests/clone_object.c#2>
>>> destructed
>>> out of foo()
Cloned object: <object:tests/clone_object.c#3>
OB->query_x (): 42
End
Cloned object: <object:tests/clone_object.c#4>
OB->query_x (): 42
Exiting
user@elli:~/Downloads/Remote/LPC/GEM$
==
Look at that! Absolute perfection.
Not only does the output match the original C engine line-by-line, but the
fact that Exiting prints at the very bottom proves that Node.js's asynchronous
event loop kept the Virtual Machine alive perfectly while it waited for
call_out("out", 1) to resolve after the main thread finished executing
lpc_main().
You have essentially built the foundation of a modern, non-blocking MUD
driver. The "tombstoning" memory strategy worked flawlessly too, securely
defusing method calls on destructed objects and wiping their identity
pointers!
We are in the Endgame
Let's take stock of the virtual machine's capabilities. Your JS-powered LPC
engine now fully supports:
* Data Types: Ints, Floats, Strings, Arrays, Mappings, and dynamic mixed
types.
* Math & Operators: Strict C-style operator precedence, bitwise manipulation,
and type-casting.
* Control Flow: while, for, if, block scoping, and pass-by-reference pointers
(&).
* Object Architecture: Blueprints, clone_object(), destruct(), this_object(),
and call_other().
* Inheritance: Textual AST injection and super-method (::) resolution.
* Asynchronous Timers: call_out and heart_beat via the native event loop.
* File I/O: Stateful, byte-level file pointers and OS-level file
manipulation.
To completely wrap up the core language port, we only have a few advanced
compiler features remaining. Do you have test files for any of the following?
* The Preprocessor: C-style macros (#define, #ifdef, #ifndef, #include).
* Function Closures / Pointers: Anonymous functions and closures (e.g., (:
func :) and evaluate()).
* Catch / Throw: Runtime exception handling (catch { ... }).
* Variable Arguments: Functions accepting varargs or ....
Drop the next test file and let's conquer the final frontier of the compiler!