Commit Graph

1281 Commits

Author SHA1 Message Date
6dfbea1ea4 Don't use generic function for finding method duplicates and add tests 2016-03-12 19:14:19 -08:00
4cc3afd38b Fix and optimize duplicate method check 2016-03-12 18:29:44 -08:00
3fd151036c Forbid duplicate methods 2016-03-12 18:29:43 -08:00
22a95265f2 Simplify the formatting used to print compile errors.
Avoids using multiple calls to fprintf() to print a single compile
error. This should make it easier to allow the host to provide a
callback function to print errors.
2016-03-11 21:30:54 -08:00
5be9377d93 Simplify shebang parsing. 2016-03-11 17:23:31 -08:00
485e91ab05 Redo metrics script. 2016-03-07 07:56:44 -08:00
fb0e01bfe9 Fix some nits in the FAQ. 2016-03-07 07:41:00 -08:00
139b447898 Compile functions in place instead of copying when done.
The compiler used to maintain all of the data that defines a function,
which it incrementally built up. Then, when it was done, it copied all
of that to a new ObjFn. In theory, that was to trim down some memory
and avoid unneeded fields in ObjFn.

In practice, the performance benefit is negligible and the memory saving
is nullified by the fact that it copies anyway.

This moves all of that mutable state directly into ObjFn. The compiler
creates a new empty ObjFn at the beginning and then just fills it in
in place.

This shaves off about 40 lines of code, is simpler, and doesn't seem to
impact perf.
2016-03-04 07:49:34 -08:00
f2f779d3b8 Fix bug with the compiler root not being popped. 2016-03-03 17:48:47 -08:00
a3505fa060 Simplify runtime error reporting. 2016-03-03 17:11:52 -08:00
9fda7cb526 Unify Fiber.try() with the other methods to execute fibers. 2016-03-03 17:00:33 -08:00
d717ddf817 Simplify how assignment expressions are compiled. 2016-03-03 16:30:48 -08:00
84bcb5801c Add a test for creating a VM without a config. 2016-03-03 14:31:47 -08:00
41e30f47d8 wrenNewVM NULL check
My first attempt to embed VM in project ended with crash. Fortunately I'm not so easly scared and managed to found out that despite comment in "wren.h" no check for null is performed. I took the liberty of fixing that. 
Btw. nice project, keep up the good work!
2016-03-03 17:58:50 +01:00
223d66a01c I can spell gooder. 2016-02-27 16:23:48 -08:00
0a83697bd4 Minor janitorial work. 2016-02-27 16:05:50 -08:00
1e4b9e5175 File.realPath().
Not tested yet, because we can't create symlinks from Wren and I don't
want to check symlinks into the repo, but it seems to do the right
thing.
2016-02-27 15:53:02 -08:00
e6b48de598 Fix precedence table in docs.
It was out of sync with the actual implemented precedence in a few
places.
2016-02-27 10:14:09 -08:00
fa2598c601 Upgrade to libuv 1.8.0. 2016-02-27 09:19:56 -08:00
b7e189fe11 Desugar import statements to core library calls.
This is simpler than having special opcodes for them. It's also a bit
faster, and gets some non-critical code out of the interpreter loop.

Also, this is good prep work for being able to write some of the module
loading process in Wren to make things more flexible for embedders and
the CLI.
2016-02-26 22:43:54 -08:00
edca85827a Combine block() and statement().
The separation between the two didn't really do anything useful.
2016-02-25 07:04:48 -08:00
d46dfc9500 Allow "*" on lists and strings to repeat them.
This is not implemented on Sequence because, at least for lists and
strings, I think users expect an eager result. Multiplying a string
should give you back a string, not a lazy sequence of repeated
characters.

This also mirrors "+" on strings and lists, which is eager. I like the
idea of having a general guideline that operators are eager.

Repetition is useful for arbitrary sequences, but for that maybe we
should add a "repeat()" method.
2016-02-24 07:48:03 -08:00
919605b7ba Couple of tiny tweaks. 2016-02-24 06:52:12 -08:00
2c4e497c54 Fix a couple of doc bugs. 2016-02-22 07:48:53 -08:00
60162575ee More file system checking functions:
- Stat#isFile
- Stat#isDirectory
- Directory.exists()
- File.exists()
2016-02-21 12:23:33 -08:00
c6148f8941 Make Stat a foreign class.
Instead of copying the uv_fs_stat struct to a list of Wren numbers, we
store it directly in the Stat object. This is important because we'll
need to implement later methods like isDirectory() in C so we can use
S_ISDIR(). For that, we need to have access to the original stat data.
2016-02-21 11:34:10 -08:00
b331915259 Add stat instance method to File. 2016-02-21 10:18:45 -08:00
3101d9c499 Fix file flags to be OS-independent. 2016-02-20 17:25:41 -08:00
ff96a179ac Include stdio.h when debugging is enabled. 2016-02-20 13:36:22 -08:00
8e90e3577b More file IO!
Can now create, delete, and write to files.
2016-02-20 09:23:42 -08:00
bec5181bdb Add separate targets for building just the shared or static library.
make static
make shared

Running "make vm" will build both, as usual.

Fixes #322.
2016-02-19 07:22:10 -08:00
ef3aa07d84 Add API to get the type of object in a slot. 2016-02-19 07:18:00 -08:00
fa0a507b48 Error on jump distance overflow. 2016-02-19 06:57:38 -08:00
5b7cd12e76 Don't run the skynet example from the tests.
It's too slow on the Travis bots and times out.
2016-02-14 22:28:14 -08:00
b8e85c83a8 Fix test and add skynet example. 2016-02-14 22:21:50 -08:00
d823896136 Merge branch 'master' of https://github.com/munificent/wren 2016-02-14 22:18:53 -08:00
1a6d3703d2 Merge pull request #320 from 4d47/small-doc-update
Fix two small code samples in doc
2016-02-12 10:35:40 -08:00
edbffc9a95 Simplify method() and defineMethod().
Passing along a Variable lets us get rid of some duplicate code around
loading the class.
2016-02-12 07:43:44 -08:00
68f801a525 Unnecessary strncmp -> memcmp. 2016-02-12 07:27:42 -08:00
5b5c258f55 Make a little Variable struct.
Gets rid of the slightly ugly loadInstruction output parameter that
gets passed around. Now a reference to a variable is a first-class
concept in the compiler.
2016-02-12 07:16:41 -08:00
ff69b12c2c Fix sample in doc/site/error-handling
Add missing constructor.
2016-02-11 18:06:51 -05:00
a2e03279e2 Fix abs code sample in doc/site/modules/core/num
-123.abs returns -123 because the dot has higher precedence so it's
 really -(123.abs).
2016-02-11 17:58:09 -05:00
68ab4e88c0 Merge branch 'master' of https://github.com/munificent/wren 2016-02-09 07:24:55 -08:00
8b36e2f00b Add sample(_) and sample(_,_) to Random. 2016-02-09 07:24:45 -08:00
895136b78c Merge pull request #319 from 4d47/small-doc-update
Update wrenInterpret doc/site/embedding-api
2016-02-08 17:43:05 -08:00
82307232cc Update wrenInterpret doc/site/embedding-api 2016-02-08 08:34:56 -05:00
d4a4b26203 Add Random.shuffle(). 2016-02-07 10:38:39 -08:00
79558d95e5 Move File.stat() -> Stat.path().
Thanks, Michel!
2016-02-07 09:56:16 -08:00
ffb5ada9fb Move the community docs to the wiki. 2016-01-24 15:39:35 -08:00
fde6cfc142 Generate wrenAllocateForeign() to match the other setSlot methods.
Thanks, Michel!
2016-01-24 09:25:04 -08:00