Commit Graph
100 Commits
Author SHA1 Message Date
Bob Nystrom 40c927f440 Make sure we consume all the input when compiling a single expression.
Fix #528.
2018-04-28 16:54:33 -07:00
Bob Nystrom c4ae0f5c59 Be a little more conservative with some string operations.
This should hopefully fix #531, though in practice the previous code
should have been safe too.
2018-04-28 16:38:09 -07:00
Bob Nystrom 41a56446c6 Refine a few things:
- Fix some doc comments.

- Inline comparing two ObjStrings, since it's only used in one place.
  Also, this avoids a redundant identity check.

- Move the forward declarations of the object types out of
  wren_common.h. Instead, I just added the one needed forward
  declaration of ObjString in wren_utils.h. It's a little inelegant,
  but it feels weird to me to expose all of the object types in
  wren_common.h when they logically belong to wren_value.h and most of
  the types aren't problematic.

- Fix a bug where field symbol tables weren't being marked. If a GC
  happened while compiling a class, field strings got freed.
2018-04-28 12:13:03 -07:00
Bob Nystrom 05e18fa95f Merge branch 'unify_string' of https://github.com/mhermier/wren into mhermier-unify_string 2018-04-28 10:22:42 -07: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
Bob Nystrom 64f8bf7ae3 Merge pull request #524 from bjorn/master
Small documentation fixes
2018-04-25 21:09:48 -07:00
Bob Nystrom 4bc3e6f424 Fix LICENSE to match https://choosealicense.com/licenses/mit/.
That way GitHub and other tools correctly recognize the license. There
is no substantive change to the license itself.
2018-04-23 16:48:47 -07:00
Bob Nystrom c1ed027973 Merge pull request #523 from jaromirmuller/patch-1
documentation: fixed typo, function declares data, body uses file
2018-04-06 23:49:55 -07:00
Bob Nystrom 7487eeab49 Merge pull request #515 from kjk/patch-1
fix bindForeignMethod() example
2018-03-26 07:52:26 -07:00
Bob Nystrom af9fda5e60 Merge branch 'master' of https://github.com/munificent/wren 2018-03-26 07:50:49 -07:00
Bob Nystrom 8c7174d1c6 Merge branch 'fix-assert' of https://github.com/maxdeviant/wren into maxdeviant-fix-assert 2018-03-26 07:50:16 -07:00
Bob Nystrom 8852e5accc Merge pull request #500 from mhermier/critical_fixes
[critical] Fix getNumArguments and wrenBindMethodCode opcodes data.
2018-03-26 07:49:54 -07:00
Bob Nystrom e1f105fd8e Merge pull request #484 from feiss/patch-1
parameter missing in errorFn
2018-03-22 10:31:01 -07:00
Bob Nystrom 7612b6bc8c Merge pull request #513 from snocl/replfix
Fix REPL being broken by latest commit
2018-03-19 14:08:04 -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 43cf652003 Simplify wrenCompileSource(). 2018-03-17 09:13:51 -07:00
Bob Nystrom bd3897278c Use newer GYP. 2018-03-14 08:06:06 -07:00
Bob Nystrom a95077cd9f Don't build the libuv tests on Linux. 2018-03-14 07:27:29 -07:00
Bob Nystrom 011e8fab96 Fix off-by-one error in arg checking. 2018-03-14 07:27:29 -07:00
Bob Nystrom 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
Bob Nystrom 3ce9ecfc65 Merge pull request #506 from adsr/patch-readme
Fix embedding link in README
2018-02-20 14:23:39 -08:00
Bob Nystrom c4d08bcb81 Fix missing return error. 2017-10-31 22:07:07 -07:00
Bob Nystrom 7b326d804b Merge pull request #475 from KyleCharters/master
Correct method examples in Range docs
2017-10-31 16:24:58 -07:00
Bob Nystrom 8d37b20783 Compile imports to actual instructions instead of core library calls. 2017-10-31 15:58:59 -07:00
Bob Nystrom 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
Bob Nystrom 88ff8f90ef Merge pull request #474 from minirop/typo-in-doc
missing language specifier and variable declaration
2017-10-19 22:12:25 -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 e043a95e4e Edit docs. Docs docs docs. 2017-10-19 19:52:05 -07:00
Bob Nystrom f8076c2c1c Revise embedding docs. 2017-10-19 07:02:18 -07:00
Bob Nystrom 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
Bob Nystrom 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
Bob Nystrom 97b2e1c818 Add web server to doc generator. 2017-10-12 06:38:34 -07:00
Bob Nystrom 91853a7fa9 Fix comment on foreign allocate function.
Fix #453.
2017-10-12 06:37:49 -07:00
Bob Nystrom 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
Bob Nystrom c4b0f83cb3 "ClassCompiler" -> "ClassInfo".
Fix #469.
2017-10-09 06:47:42 -07:00
Bob Nystrom 973b43eb7f Simplify statement compiler code a little. 2017-10-08 10:47:31 -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 18449102e8 Parenthesize macro arguments in ALLOCATE_FLEX and ALLOCATE_ARRAY.
Fix #457.
2017-10-08 09:45:06 -07:00
Bob Nystrom fec54d5021 Avoid undefined pointer difference behavior.
Fix #458.
2017-10-08 09:42:35 -07:00
Bob Nystrom eba0b97aa2 Merge pull request #472 from KyleCharters/master
Add Num .round
2017-10-06 07:51:55 -07:00
Bob Nystrom 8963a870ff Abort all fibers along a call chain when one aborts. 2017-10-06 07:39:00 -07:00
Bob Nystrom 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
Bob Nystrom 61f5e56e93 Merge pull request #460 from skybrian/fixcomment
Remove obsolete comment
2017-10-05 06:51:48 -07:00
Bob Nystrom 2bb531d860 Tweak Fiber.error docs. 2017-10-05 06:50:45 -07:00
Bob Nystrom d390e16a99 Kill duplicate test.
Fix #438.
2017-04-08 12:53:33 -07:00
Bob Nystrom 7aa3fc1ce7 Merge pull request #435 from Nelarius/vs
Modernize the Visual Studio solution
2017-04-08 12:48:47 -07:00
Bob Nystrom 6ccdc0cf19 Merge pull request #443 from nathanhourt/nathanhourt-typo-fixes
One more typo fix
2017-04-08 12:40:31 -07:00
Bob Nystrom 889cae5ff1 Free imported module source strings after compiling them.
Fix #430.
2017-04-08 12:38:36 -07:00
Bob Nystrom a6424e94b1 Merge pull request #440 from nathanhourt/patch-1
Fix typos in documentation
2017-04-04 07:07:57 -07:00
Bob Nystrom 417ed7aeed Add wren.hpp. 2017-03-25 10:05:33 -07:00
Bob Nystrom b32c445f96 Show constructing "blondie" instance in functions doc.
Fix #432.
2017-03-23 21:22:07 -07:00
Bob Nystrom 44a95e65c6 Set the token type after an invalid character error.
Otherwise, it still has the previous token's type. This can cause it
to get stuck in a loop in some places in the compiler.

Fix #428.
2017-03-23 21:19:20 -07:00
Bob Nystrom 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
Bob Nystrom 907db83e1c Merge branch 'user-data' of https://github.com/foobit/wren into foobit-user-data 2017-03-22 07:12:26 -07:00
Bob Nystrom 8d313be3ce Make it an error to skip or take a negative count. 2017-03-15 07:22:44 -07:00
Bob Nystrom 9f93119377 Merge branch 'take_and_skip' of https://github.com/bjorn/wren into bjorn-take_and_skip 2017-03-15 07:15:00 -07:00
Bob Nystrom c84b8109a4 Tweak comments. 2017-03-15 07:10:23 -07:00
Bob Nystrom 627e9edc23 Merge branch 'fix362' of https://github.com/bytemaster/wren into bytemaster-fix362 2017-03-15 07:09:31 -07:00
Bob Nystrom 9efb18bae2 Typo: "seperator" -> "separator". 2017-03-15 07:06:07 -07:00
Bob Nystrom 9fcdf3dc0a Merge branch '201703_split_replace' of https://github.com/JonesAndrew/wren into JonesAndrew-201703_split_replace 2017-03-15 07:04:56 -07:00
Bob Nystrom 860e596b8a Test wrenSetSlotNull(). 2017-03-03 07:57:50 -08:00
Bob Nystrom f14d13a6bf Mention libm in docs. 2017-03-02 07:17:03 -08:00
Bob Nystrom 22ae382ac5 Proofread configuring the VM. 2017-02-12 14:58:16 -08:00
Bob Nystrom 18f8f48bb6 Docs for configuring the VM. 2017-02-12 11:04:38 -08:00
Bob Nystrom 996a607026 More work on embedding docs.
- Revise the earlier pages and tighten them up some.
- Write the docs for foreign methods.
2017-02-12 10:14:37 -08:00
Bob Nystrom 4fe3ad3f8b Docs for Num.log and Num.pow(). 2017-01-20 07:24:46 -08:00
Bob Nystrom 3faec25c4c Merge branch 'num-features' of https://github.com/underscorediscovery/wren into underscorediscovery-num-features 2017-01-20 07:20:55 -08:00
Bob Nystrom c6eb0be990 Remove the negative number tests for bitwise not.
They were inadvertently relying on undefined behavior in C and we get
different results on some compilers.

Until we decide how we want the operation to behave, for now, just
leave it unspecified.
2017-01-12 22:17:33 -08:00
Bob Nystrom d301fefac2 Add a comment explaining the ci targets. 2017-01-12 21:55:35 -08:00
Bob Nystrom 5ddd783ff5 Use strtoll() for hex literals to handle 64-bit ones even on 32-bit. 2017-01-12 21:53:21 -08:00
Bob Nystrom 0cc00c41c0 Simplify test runner output a little. 2017-01-12 21:38:06 -08:00
Bob Nystrom 33a73ef1d5 Avoid using fpclassify() to detect infinity and nan.
It's not supported in C++98. Instead, use isnan() and isinf(), which
seem to work? If nothing else, they are used elsewhere in Wren, so if
we're not going to use them here, we should fix the other places too.
2017-01-12 21:34:11 -08:00
Bob Nystrom e8dfb1bf10 Don't test bitwise operations on operands that don't fit in u32.
The current behavior is undefined in C when converting the double to a
u32, so the tests fail on some compilers. For now, I'm just removing
those parts of the tests because I'm not sure what I want the behavior
to be. Modulo? Truncate? Runtime error?
2017-01-12 21:32:50 -08:00
Bob Nystrom 252265c80b Merge branch 'travis-build-configurations' of https://github.com/iwillspeak/wren into iwillspeak-travis-build-configurations 2017-01-12 20:19:52 -08:00
Bob Nystrom f03647cbf0 Merge branch 'gc-32-bugfix' of https://github.com/iwillspeak/wren into iwillspeak-gc-32-bugfix 2017-01-12 18:53:14 -08:00
Bob Nystrom 479ca7ec6d Improve explanation of single-expression blocks.
Fix #390.
2017-01-12 11:05:03 -08:00
Bob Nystrom 0a2bc4a8a7 More copy editing. 2017-01-12 07:11:01 -08:00
Bob Nystrom fc6a7e5d18 Tweak some docs a little. 2017-01-12 07:10:19 -08:00
Bob Nystrom b9f53f71fb Reset API stack a fiber is aborted from wrenCall(). 2016-11-01 08:40:16 -07:00
Bob Nystrom 51e50e6cc4 Free libuv data before resuming after an error. 2016-11-01 08:39:30 -07:00
Bob Nystrom 57f34fab95 Fix assignment test. 2016-10-08 10:51:19 -07:00
Bob Nystrom e7cabbb5e4 Reset the API stack after a foreign constructor returns. 2016-08-28 08:23:27 -07:00
Bob Nystrom d331cbf43d Ensure macro parameter is parenthesized. 2016-08-27 21:44:39 -07:00
Bob Nystrom b59eeaf2d1 Support "--version" in the CLI to print the version. 2016-08-27 17:38:14 -07:00
Bob Nystrom 09ef904d32 Use DBL_MIN instead of DBL_EPSILON for Num.smallest. 2016-08-27 17:25:32 -07:00
Bob Nystrom b8b0f36521 Merge branch 'num-properties' of https://github.com/Nelarius/wren into Nelarius-num-properties 2016-08-27 17:18:21 -07:00
Bob Nystrom 0a4f1b370c Revise embedding docs a bit. 2016-08-26 07:11:50 -07:00
Bob Nystrom a8cf1c9d71 Const correct a couple of functions.
Thanks, Michel!
2016-08-16 07:43:54 -07:00
Bob Nystrom febb1b0437 Use a map to check for constant collisions.
Doing an O(n) lookup was too slow.
2016-08-16 07:43:34 -07:00
Bob Nystrom 08eceb7382 Check for duplicates when adding constants.
This saves a little memory, but, more importantly, allows us to support
functions with large numbers of repeated constants.
2016-08-16 07:24:04 -07:00
Bob Nystrom 500c7b0426 Add List constructors to docs. 2016-08-04 06:28:41 -07:00
Bob Nystrom 3666eae013 Tweak new list constructors.
- Remove List.new(_). I was convinced by the issue discussion that
  using it is probably a bad idea. We don't want to encourage more nulls
  in the world than there are already are. So let's see if we can live
  without it and just have List.filled(). That way users think about
  what they're creating a list *of*.
- Added some more tests.
- Correctly handle being given a negative size.
2016-08-03 22:42:31 -07:00
Bob Nystrom 3de394e8a1 Merge branch 'new-list-constructors' of https://github.com/mooxen/wren into mooxen-new-list-constructors 2016-08-03 22:34:08 -07:00
Bob Nystrom 6845328661 Tweak String.indexOf(_,_) a bit.
- Simplify the arithmetic a little in wrenStringFind().
- Allow the start to be negative.
- Even more tests.
- Docs.
2016-08-03 22:19:34 -07:00
Bob Nystrom e5dce527ac Merge branch 'string-indexof-startindex' of https://github.com/underscorediscovery/wren into underscorediscovery-string-indexof-startindex 2016-08-03 21:51:46 -07:00
Bob Nystrom 83bb043327 Merge branch 'forgotten-bytecode' of https://github.com/minirop/wren into minirop-forgotten-bytecode 2016-08-03 21:45:09 -07:00