This gives you a simple, efficient way to invoke a method on
some Wren object from C code, passing in arguments.
The basic API is in place and works, but there's still lots to do:
- Lots of error handling.
- Documentation.
- Tests!
Right now, it uses a weird "import_" method on String which
should either be replaced or at least hidden behind some syntax.
But it does roughly the right thing. Still lots of corner cases to
clean up and stuff to fix. In particular:
- Need to handle compilation errors in imported modules.
- Need to implicitly import all core and IO types into imported module.
- Need to handle circular imports.
(Just need to give entry module the right name for this to work.)
Functions store a reference to the module where they were
defined and load "module" variables from there.
Right now there's only one "main" module, but this is a step
in the right direction. Perf is down, though. :(
binary_trees - wren .......... 3026 0.33s 88.28% relative to baseline
delta_blue - wren .......... 7248 0.14s 94.32% relative to baseline
fib - wren .......... 2414 0.41s 88.08% relative to baseline
for - wren .......... 6753 0.15s 78.79% relative to baseline
method_call - wren .......... 6624 0.15s 100.03% relative to baseline
- Primitives can now signal an error.
- An error prints a callstack and ends the current (and right
now only) fiber.
- Arithmetic operators error if the operand is not a number.
- Real error for method not found.
- Associate source file name, and method names with functions.
- Debug line number info for functions.
Unfortunately, this regresses perf on fib about 15%, mostly
because of the better checking in arithmetic ops.
There's still a bunch of clean up to do, but this is a big step
in the right direction.
It used to subtract the number of bytes during deallocation, but
that required knowing the size of an object at free time. That
isn't always available. The old code could read a freed object
while doing this. Bad!
Instead, this tracks how much memory is still being used by
marked objects. It's correct, and is also a bit less code and
faster.