Commit Graph

484 Commits

Author SHA1 Message Date
72cde36478 Update.
All checks were successful
CI / build-linux (push) Successful in 1m3s
2026-01-26 16:28:49 +01:00
5edaf69915 Update.
Some checks failed
WrenCI / linux (push) Failing after 34s
WrenCI / mac (push) Has been cancelled
WrenCI / windows (push) Has been cancelled
2026-01-26 12:29:25 +01:00
264712dcbc Upate. 2026-01-26 10:59:07 +01:00
fbc1a6e294 Update. 2026-01-26 10:21:03 +01:00
fe2f087d9f UPdate.
Some checks failed
WrenCI / mac (push) Waiting to run
WrenCI / windows (push) Waiting to run
WrenCI / linux (push) Failing after 55s
2026-01-26 05:12:14 +01:00
a59dbe1d55 Update. 2026-01-25 22:09:29 +01:00
1ee28a1644 Update. 2026-01-25 19:02:02 +01:00
a830238d11 Update. 2026-01-25 13:09:28 +01:00
4de99d477f Update. 2026-01-25 10:54:09 +01:00
735596fdf6 Update. 2026-01-25 10:50:20 +01:00
2e425571ca Update. 2026-01-25 04:58:39 +01:00
957e3a4762 Update. 2026-01-25 02:47:47 +01:00
8c1a721c4c Update. 2026-01-24 23:40:22 +01:00
236d69c2d7 New modules.
Some checks are pending
WrenCI / linux (push) Waiting to run
WrenCI / mac (push) Waiting to run
WrenCI / windows (push) Waiting to run
2026-01-24 19:35:43 +01:00
Dario Vladović
8190115b97
Implement Platform.homePath (#48)
* fix naming and path max

Co-authored-by: ruby0x1 <ruby0x1@pm.me>
2021-05-02 13:00:19 -07:00
Josh Goebel
8227330eb6
Improve file/directory utils (#84) 2021-05-01 15:58:17 -07:00
Dario Vladović
4acf7b395d
Implement Process.pid & Process.ppid (#43)
* Implement `Process.pid` & `Process.ppid`

* Update `os` test suite
2021-04-28 14:51:23 -07:00
Josh Goebel
fcea7ba1d5
improve tests just a bit (#79) 2021-04-28 14:45:50 -07:00
Dario Vladović
e4a0fa485e
Implement Process.version (#42)
* Implement `Process.version`
* Update`os` test suite
2020-06-13 21:23:02 -07:00
Dario Vladović
1ab88ed201
Implement Process.cwd (#41)
* Implement `Process.cwd`
* Update `os` test suite
2020-06-13 21:12:34 -07:00
underscorediscovery
fe186d2ea1 0.3.0; skip tests that were previously failing on windows + mac until that can be fixed
We don't need to block 0.3.0 on this
2020-05-28 13:12:08 -07:00
underscorediscovery
f5f08bbbf5 0.3.0: it appears stat on a directory has no size on windows 2020-02-16 15:52:08 -08:00
underscorediscovery
9f1121ab2f 0.3.0: remove vm tests 2020-02-11 20:16:03 -08:00
underscorediscovery
3eb4ac1419
Add a clearer error message for forward declared lowercase variables (#699)
* Add better error messaging for forward referenced top level variables, see #467
* add test case
2019-09-30 20:30:27 -07:00
Sven Bergström
898e5356c7
Merge pull request #562 from Salmela/locals-array-overflow-fix
Check that there is space in local variable array
2019-09-18 00:20:03 -07:00
Matus Novak
f91586a71a Fix wrenAbortFiber does not work inside of foreign class allocator 2019-09-17 19:43:53 +02:00
Robert Nystrom
2a1499b04b Fix horrendously bad bit hashing function.
hashBits() is used to generate a hash code from the same 64 bits used
to represent a Wren number as a double. When building a map containing
a large number of integer keys, it's important for this to do a good
job scattering the bits across the 32-bit key space.

Alas, it does not. Worse, the benchmark to test this happens to stop
just before the performance falls off a cliff, so this was easy to
overlook.

This replaces it with the hash function V8 uses, which has much better
performance across the numeric range.
2019-07-27 13:34:07 -07:00
Walter Schell
a437e804ba Added String.fromByte with docs and unit test 2019-02-27 08:10:54 -05:00
Bob Nystrom
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
Bob Nystrom
e47f17567e Fix a couple more casts needed in C++. 2018-07-24 07:27:18 -07:00
Bob Nystrom
c237a44b88 Add file to test directory so Git creates directory. 2018-07-24 07:15:04 -07:00
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
09f4beff4a Add trim methods on String:
- trim()
- trim(chars)
- trimEnd()
- trimEnd(chars)
- trimStart()
- trimStart(chars)
2018-07-15 10:48:56 -07:00
Aleksi Salmela
e7b1bade1a Check that there is space in local variable array
Otherwise it can overflow due to for loop's hidden
variables.

Fix #561
2018-06-13 00:59:55 +03:00
Bob Nystrom
d03ef9e8b0 Move test and tweak code a bit. 2018-04-28 10:08:42 -07:00
Bob Nystrom
4d056b6ec3 Merge branch 'master' of https://github.com/jclc/wren into jclc-master 2018-04-28 10:00:59 -07:00
Bob Nystrom
8fae8e4f1e Don't overflow signature string if there are too many parameters.
Fix #494.
2018-04-27 09:13:40 -07:00
Bob Nystrom
c5ce6fac46 Fix local variable declarations in the REPL.
A statement like:

  for (i in 1..2)

When run in the REPL declares a local variable ("i"), but not inside
a function or method body. This hit a corner case in the compiler
where it didn't have the correct slot indexes set up.

That corner case is because sometimes when you compile a chunk, local
slot zero is pre-allocated -- either to refer to "this" or to hold the
closure for a function so that it doesn't get GCed while running. But
if you're compiling top-level code, that slot isn't allocated. But top
level code for the REPL *should* be, because that gets invoked like a
function.

To simplify things, *every* compiled chunk now pre-allocates slot zero.
That way, there are fewer cases to keep in mind.

Also fixed an issue where a GC during an import could collected the
imported module body's closure.

Fix #456.
2018-04-27 08:20:49 -07:00
jclc
e66115c9fc add regression test for #520 2018-04-10 18:53:56 +03:00
Bob Nystrom
8210452970 Relative imports!
This is a breaking change because existing imports in user Wren code
that assume the path is relative to the entrypoint file will now likely
fail.

Also, stack trace output and host API calls that take a module string
now need the resolved module string, not the short name that appears in
the import.
2018-03-24 11:10:36 -07:00
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
c5befa72cf Don't use module import string when loading imported variables.
This is an interim step towards supporting relative imports. Previously,
the IMPORT_VARIABLE instruction had a constant string operand for the
import string of the module to import the variable from. However, with
relative imports, the import string needs to be resolved by the host
all into a canonical import string. At that point, the original import
string in the source is no longer useful.

This changes that to have IMPORT_VARIABLE access the imported ObjModule
directly. It works in two pieces:

1. When a module is compiled, it ends with an END_MODULE instruction.
   That instruction stores the current ObjModule in vm->lastModule.

2. The IMPORT_VARIABLE instruction uses vm->lastModule as the module to
   load the variable from. Since no interesting code can execute between
   when a module body completes and the subsequent IMPORT_VARIABLE
   statements, we know vm->lastModule will be the one we imported.
2018-03-20 06:54:51 -07:00
Bob Nystrom
2c88e19497 Compile imports to closures, not fibers.
This is simpler and marginally faster. We don't need the overhead of
fibers since you can't have long or recursive import chains anyway.

More importantly, this makes the behavior more well-defined when you do
things like yield from an imported module. (Not that you should do that,
but if you do, it shouldn't do weird things.)
2018-03-17 09:33:33 -07:00
Bob Nystrom
1661f5368f Allow passing a value when first starting a fiber.
If the function the fiber is created from takes a parameter, the value
passed to the first call() or transfer() gets bound to that parameter.

Also, this now correctly handles fibers with functions that take
parameters. It used to leave the stack in a busted state. Now, it's a
runtime error to create a fiber with a function that takes any more
than one parameter.
2017-10-19 20:45:13 -07:00
Bob Nystrom
c7087652ee Add regression tests from wren-fuzz.
These are all non-crashing now, so it looks like the underlying issue
is fixed. (It was probably #429.)

Fix #442.
2017-10-08 10:15:15 -07:00
Bob Nystrom
c38d97b973 Properly detect a missing "}" in a block.
Fix #429.
2017-10-08 10:03:42 -07:00
Bob Nystrom
eba0b97aa2 Merge pull request #472 from KyleCharters/master
Add Num .round
2017-10-06 07:51:55 -07:00