feat: allow re-entrant wrenCall from foreign methods by resetting apiStack to NULL

The core change in wren_vm.c replaces the save/restore pattern for vm->apiStack with a simple NULL assignment after foreign calls, enabling nested wrenCall invocations from within foreign method handlers. This is accompanied by new test files (call_calls_foreign.c/.h/.wren) that verify the re-entrant call path works correctly, along with Makefile and Xcode project updates to build and run the new tests. A minor typo fix in reset_stack_after_call_abort.c renames a handle variable from 'afterConstruct' to 'afterAbort' for consistency.
This commit is contained in:
Bob Nystrom
2019-02-09 01:09:39 +00:00
parent 4a0e60236e
commit 523e157c6a
10 changed files with 111 additions and 16 deletions
+6 -3
View File
@@ -76,8 +76,7 @@ clean:
$(V) rm -rf lib
# Run the tests against the debug build of Wren.
test: debug
$(V) $(MAKE) -f util/wren.mk MODE=debug api_test
test: api_test debug
$(V) ./util/test.py $(suite)
benchmark: release
@@ -92,6 +91,10 @@ unit_test:
$(V) $(MAKE) -f util/wren.mk MODE=debug unit_test
$(V) ./build/debug/test/unit_wrend
# Build API tests.
api_test:
$(V) $(MAKE) -f util/wren.mk MODE=debug api_test
# Generate the Wren site.
docs:
mkdir -p build
@@ -113,4 +116,4 @@ gh-pages: docs
amalgamation: src/include/wren.h src/vm/*.h src/vm/*.c
./util/generate_amalgamation.py > build/wren.c
.PHONY: all amalgamation benchmark builtin clean debug docs gh-pages release test vm watchdocs ci ci_32 ci_64
.PHONY: all amalgamation api_test benchmark builtin clean debug docs gh-pages release test vm watchdocs ci ci_32 ci_64