forked from Mirror/wren
This doesn't let you arbitrarily call back into the VM from within foreign methods. I'm still not sure if that's even a good idea since God knows what that would mean if you switch fibers while doing that. But this does allow the very important use case of being able to call a foreign method from within a call to wrenCall(). In other words, foreign methods need to always be leaf calls on the call stack, but the root of that stack can now come from runInterpreter() or wrenCall(). Fix #510.
18 lines
548 B
Plaintext
18 lines
548 B
Plaintext
// Regression test for https://github.com/munificent/wren/issues/510.
|
|
//
|
|
// Tests that re-entrant API calls are handled correctly. The host uses
|
|
// `wrenCall()` to invoke `CallCallsForeign.call()`. That in turn calls
|
|
// `CallCallsForeign.api()`, which goes back through the API.
|
|
class CallCallsForeign {
|
|
foreign static api()
|
|
|
|
static call(param) {
|
|
System.print(api())
|
|
// expect: slots before 2
|
|
// expect: [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
System.print(param) // expect: parameter
|
|
// expect: slots after 1
|
|
return "result"
|
|
}
|
|
}
|