1
0
forked from Mirror/wren
Commit Graph

1701 Commits

Author SHA1 Message Date
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
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
05e18fa95f Merge branch 'unify_string' of https://github.com/mhermier/wren into mhermier-unify_string 2018-04-28 10:22:42 -07:00
d03ef9e8b0 Move test and tweak code a bit. 2018-04-28 10:08:42 -07:00
4d056b6ec3 Merge branch 'master' of https://github.com/jclc/wren into jclc-master 2018-04-28 10:00:59 -07:00
8fae8e4f1e Don't overflow signature string if there are too many parameters.
Fix #494.
2018-04-27 09:13:40 -07:00
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
64f8bf7ae3 Merge pull request #524 from bjorn/master
Small documentation fixes
2018-04-25 21:09:48 -07:00
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
e66115c9fc add regression test for #520 2018-04-10 18:53:56 +03:00
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
4034a6d65a crunched BOM skipping 2018-04-07 06:04:32 +03:00
67ed36e79a don't publish docs from PRs, only from merges into master 2018-04-06 20:04:34 +01:00
f7a61df634 only upload docs from the master branch 2018-04-06 19:53:53 +01:00
372cd3e197 Small documentation fixes 2018-04-06 10:34:12 +02:00
4442b37411 fixed typo, function declares data, body uses file 2018-04-05 23:02:30 +02:00
492763205b introduced docs auto publish step to travisci 2018-04-04 20:37:05 +01:00
fe2ca0e89a remove extra line 2018-04-04 05:14:05 +03:00
8858161484 skip UTF-8 BOM 2018-04-04 05:11:59 +03:00
e4901c51d8 Add wrenStringEqualStrLength and wrenStringsEqual. 2018-03-29 09:12:32 +02:00
3c39f7e0af Make symboltable use ObjString.
* Avoid to have 2 different string representation in the code.
* Reduce memory creation in meta API, by reusing created strings.
2018-03-28 18:12:50 +02:00
3e9bf0277b Move Obj* type definition to wren_common.h.
Uniformize structure naming, and should help file includes.
2018-03-28 17:51:34 +02:00
7487eeab49 Merge pull request #515 from kjk/patch-1
fix bindForeignMethod() example
2018-03-26 07:52:26 -07:00
af9fda5e60 Merge branch 'master' of https://github.com/munificent/wren 2018-03-26 07:50:49 -07:00
8c7174d1c6 Merge branch 'fix-assert' of https://github.com/maxdeviant/wren into maxdeviant-fix-assert 2018-03-26 07:50:16 -07:00
8852e5accc Merge pull request #500 from mhermier/critical_fixes
[critical] Fix getNumArguments and wrenBindMethodCode opcodes data.
2018-03-26 07:49:54 -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
e1f105fd8e Merge pull request #484 from feiss/patch-1
parameter missing in errorFn
2018-03-22 10:31:01 -07:00
bcc31e63a2 add() method is bound as static but bindForeignMethod responds to non-static 2018-03-20 17:13:28 -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
7612b6bc8c Merge pull request #513 from snocl/replfix
Fix REPL being broken by latest commit
2018-03-19 14:08:04 -07:00
92cb88366b Fix REPL being broken by latest commit. 2018-03-19 21:50:12 +01: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
89ae3f92ec Add @maxdeviant to AUTHORS 2018-01-18 00:48:02 -05:00
e493e6679b Fix variable in assert
Fixes #493
2018-01-18 00:46:58 -05:00
a2cf3c34ad Fix getNumArguments and wrenBindMethodCode opcodes data.
Some instructions data in these 2 functions are out of syncs, and can try to
patch the code in bad manner.
2018-01-11 12:20:35 +01:00
d1a772e820 parameter missing in errorFn 2017-11-14 16:56:16 +01: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