1
0
forked from Mirror/wren

28 Commits

Author SHA1 Message Date
a5147aa2d9 Add a limited form of re-entrant calls.
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.
2019-02-08 17:09:39 -08:00
f23c82071a Don't allow calling the root fiber.
The VM used to not detect this case. It meant you could get into a
situation where another fiber's caller had completed. Then, when it
tried to resume that fiber, the VM would crash because there was nothing
to resume to.

This is part of thinking through all the cases around re-entrancy. Added
some notes for that too.
2018-07-21 10:02:29 -07:00
ed64a13778 Add new files to api_test target in XCode project. 2018-07-18 07:30:18 -07:00
7a42a20b98 Merge branch 'master' into smarter-imports
# Conflicts:
#	src/module/io.c
#	src/vm/wren_vm.c
2018-07-15 21:01:14 -07:00
c367fc3bfc Get logical imports in "wren_modules" working.
There's a lot of changes here and surely some rough edges to iron out.
Also, I need to update the docs. But I want to get closer to landing
this so I can build on it.
2018-07-15 20:09:41 -07:00
c7c69d1291 Check in shared Xcode file. 2018-07-14 12:12:37 -07:00
5539c59750 Add a minimal path manipulation C module.
This is just for the VM's own internal use, for resolving relative
imports.

Also added a tiny unit test framework for writing tests of low-level
C functionality that isn't exposed directly by the language or VM.
2018-03-24 10:58:07 -07:00
8a71735e0f Expose an API to let the host resolve relative import strings.
This is a breaking API change: wrenInterpret() now takes an additional
parameter for the module name to interpret the code in.
2018-03-23 07:54:09 -07:00
02bcefcbe4 Add test for user data.
Also moved the VM parameter in the error callback to be first like it
is in other callbacks.
2017-03-22 07:26:19 -07:00
b9f53f71fb Reset API stack a fiber is aborted from wrenCall(). 2016-11-01 08:40:16 -07:00
e7cabbb5e4 Reset the API stack after a foreign constructor returns. 2016-08-28 08:23:27 -07:00
689cd42269 Start writing the REPL in Wren.
It doesn't actually execute code yet, but it:

- Supports left and right arrow keys for moving the cursor.
- Ctrl-C, Ctrl-D, Ctrl-A, and Ctrl-E for navigating.
- Syntax highlights the line (!).

The next step is to do a rough parse so that we can tell if the line
is an expression, statement, or needs more input. That will tell us
whether we need to interpret it at the top level (statement) and not
worry about a result, evaluate it as an expression and print the result,
or read more lines.
2016-06-09 19:16:41 -07:00
59e9eb127e Add wrenAbortFiber().
Thanks, @underscorediscovery!
2016-06-09 19:14:21 -07:00
06731f66d4 Add a Platform class.
- Rename the "process" module to "os".
- Add Platform to it.
- Static "name" method.
- Static "isPosix" method.
- Docs and tests!
2016-05-21 12:44:17 -07:00
0a060a9678 WrenValue -> WrenHandle. 2016-05-20 20:55:28 -07:00
84bcb5801c Add a test for creating a VM without a config. 2016-03-03 14:31:47 -08:00
71e2458a6c Add API for accessing command-line arguments.
- Add process module with Process class.
- Add "arguments" and "allArguments" methods.
- Docs for same.
- Support passing additional arguments to command line.
- Add "--help" support to command line.
2016-01-22 07:57:26 -08:00
1d16e85a85 Add an API to load a top-level variable into a slot. 2015-12-26 10:53:14 -08:00
6f37d379f4 Add C API functions for working with lists:
- wrenEnsureSlots()
  Lets you go the foreign slot stack to make room for a temporary work
  area.

- wrenSetSlotNewList()
  Creates a new empty list and stores it in a slot.

- wrenInsertInList()
  Takes a value from one slot and inserts it into the list in another.

Still need more functions like getting elements from a list, removing,
etc. but this at least lets you create, populate, and return lists from
foreign methods.
2015-12-16 16:28:26 -08:00
7fcdcf2f1a wrenReturn___() -> wrenSlotSet___().
This turns those functions into general-purpose functions for writing
raw C values into slots on the foreign call stack.

Writing a return just means writing a value to slot 0.
2015-12-16 13:00:13 -08:00
01e8f9053e Add a benchmark to test the Wren C API.
I've got some ideas on how to tweak the embedding API, but I want to
see what performance impact they have first, so this adds a little
benchmark that just calls a foreign method a ton of times.
2015-12-15 16:02:13 -08:00
f145662158 "Auxiliary" -> "optional".
Fixes #309.
2015-10-24 09:23:25 -07:00
e5176607d9 Move meta and random to "aux" modules.
Wren now has three classes of modules:

- The one magic "core" module that's built in and always needed.
- Auxiliary libraries like "meta" and "random". These do not have any
  dependencies, so can be used even when you embed Wren inside an
  application. But they're also optional and can be disabled if you
  don't need them.
- CLI modules. These ones need libuv and are tied to the CLI wrapper
  around the VM.
2015-10-17 22:09:48 -07:00
8436ce1934 Add a random module. 2015-10-17 11:03:15 -07:00
d431c2eaa8 Start sketching in support for reading from stdin. 2015-10-16 21:05:24 -07:00
79354f5a97 Do some work on wrenCall().
- Add an explicit va_list version. That lets variadic functions
  forward to it.
- Fix a GC bug in wrenCall() with return values.
- Make the call API test not re-enter the VM.
2015-09-29 19:29:10 -07:00
f757c9efac Better embedding API support (and tests!) for strings with null bytes.
- Test that a foreign method can return strings.
- Test that a foreign method can return a string with null bytes.
- Test wrenCall().
- Allow passing NULL for "v" to wrenCall().
- Allow "a" for passing an explicit length byte array to wrenCall().
2015-09-24 08:02:31 -07:00
36f7d74183 Unify "script" and "project" under "util". 2015-09-22 07:45:58 -07:00