1
0
forked from Mirror/wren
Commit Graph

1467 Commits

Author SHA1 Message Date
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
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
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
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
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
43cf652003 Simplify wrenCompileSource(). 2018-03-17 09:13:51 -07:00
bd3897278c Use newer GYP. 2018-03-14 08:06:06 -07:00
a95077cd9f Don't build the libuv tests on Linux. 2018-03-14 07:27:29 -07:00
011e8fab96 Fix off-by-one error in arg checking. 2018-03-14 07:27:29 -07:00
f866ee7003 Vendor GYP and libuv into the repo.
Instead of dynamically downloading these as needed during a build, this
checks in those two dependencies directly into the Wren repo. That's a
little lame because users of Wren who aren't building the CLI don't
actually need them, but they aren't too big, so it's not a huge deal.

It makes builds (particularly on Travis) more reliable, because they
don't have to pull down additional content over the network.
2018-03-14 07:27:29 -07:00
3ce9ecfc65 Merge pull request #506 from adsr/patch-readme
Fix embedding link in README
2018-02-20 14:23:39 -08:00
0ad0af0e1f Fix embedding link in README 2018-02-16 23:18:01 -05:00
c4d08bcb81 Fix missing return error. 2017-10-31 22:07:07 -07:00
7b326d804b Merge pull request #475 from KyleCharters/master
Correct method examples in Range docs
2017-10-31 16:24:58 -07:00
8d37b20783 Compile imports to actual instructions instead of core library calls. 2017-10-31 15:58:59 -07:00
e9ac543853 Merge pull request #480 from aliou/ad-fix-embedding-path
Fix embedding path in getting started
2017-10-31 14:04:37 -07:00
b45cab28d1 Fix embedding path in getting started. 2017-10-31 21:47:51 +01:00
1be76bb478 Correct method examples in Range docs 2017-10-23 13:48:43 -04:00
88ff8f90ef Merge pull request #474 from minirop/typo-in-doc
missing language specifier and variable declaration
2017-10-19 22:12:25 -07:00
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
e043a95e4e Edit docs. Docs docs docs. 2017-10-19 19:52:05 -07:00
6444a5f5db missing language specifier and variable declaration 2017-10-19 21:17:40 +02:00
f8076c2c1c Revise embedding docs. 2017-10-19 07:02:18 -07:00
e2e16dc4a9 Finish off the rest of the embedding docs.
A first draft of them, at least. They probably need some editing.
Remove the "Application Lifecycle" page for now. I do intend to add
some docs about how fibers interact with the host app, but I can do
that later.
2017-10-17 08:26:06 -07:00
9661a5b999 Fix a couple of bugs in the REPL.
- Not sure what was going on, but fix #456. It makes more sense for the
  REPL to invoke the compiled code as a fiber than a function anyway.

- Flush stdout before reading from stdin since System.print() no longer
  does that automatically.
2017-10-13 07:58:57 -07:00
97b2e1c818 Add web server to doc generator. 2017-10-12 06:38:34 -07:00
91853a7fa9 Fix comment on foreign allocate function.
Fix #453.
2017-10-12 06:37:49 -07:00
2021e086bf Don't automatically flush on every System.write().
It's handy because it ensures writes are flushed to the terminal before
any calls to read from stdin, but it's also gratuitously slow.

Instead, added a Stdout class with an explicit flush() method that can
be called by the user.

Fix #445.
2017-10-09 07:16:05 -07:00
c4b0f83cb3 "ClassCompiler" -> "ClassInfo".
Fix #469.
2017-10-09 06:47:42 -07:00
973b43eb7f Simplify statement compiler code a little. 2017-10-08 10:47:31 -07:00
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
c38d97b973 Properly detect a missing "}" in a block.
Fix #429.
2017-10-08 10:03:42 -07:00
18449102e8 Parenthesize macro arguments in ALLOCATE_FLEX and ALLOCATE_ARRAY.
Fix #457.
2017-10-08 09:45:06 -07:00
fec54d5021 Avoid undefined pointer difference behavior.
Fix #458.
2017-10-08 09:42:35 -07:00
eba0b97aa2 Merge pull request #472 from KyleCharters/master
Add Num .round
2017-10-06 07:51:55 -07:00
8963a870ff Abort all fibers along a call chain when one aborts. 2017-10-06 07:39:00 -07:00
0f19984017 Merge branch '201703_bubble_exceptions' of https://github.com/JonesAndrew/wren into JonesAndrew-201703_bubble_exceptions 2017-10-06 06:58:27 -07:00
61f5e56e93 Merge pull request #460 from skybrian/fixcomment
Remove obsolete comment
2017-10-05 06:51:48 -07:00
2bb531d860 Tweak Fiber.error docs. 2017-10-05 06:50:45 -07:00
84f2252c68 Add Num .round 2017-09-20 20:27:02 -04:00
16bab57056 fix #468 2017-09-16 21:38:35 -07:00
a7418d64e6 Remove obsolete comment 2017-05-29 12:02:50 -07:00
d390e16a99 Kill duplicate test.
Fix #438.
2017-04-08 12:53:33 -07:00
7aa3fc1ce7 Merge pull request #435 from Nelarius/vs
Modernize the Visual Studio solution
2017-04-08 12:48:47 -07:00
6ccdc0cf19 Merge pull request #443 from nathanhourt/nathanhourt-typo-fixes
One more typo fix
2017-04-08 12:40:31 -07:00
889cae5ff1 Free imported module source strings after compiling them.
Fix #430.
2017-04-08 12:38:36 -07:00
e9896544c8 Typo fix: is only be -> will only be 2017-04-04 15:29:53 -05:00
a6424e94b1 Merge pull request #440 from nathanhourt/patch-1
Fix typos in documentation
2017-04-04 07:07:57 -07:00
7d631276cb Catch errors in the first try() 2017-03-30 21:57:29 -04:00