commit f93ec6430f9629b5a28765a3961379d1e8296e50
Author: Bob Nystrom <robert@stuffwithstuff.com>
Date: Wed Mar 16 08:03:25 2016 -0700
Tiny tweaks.
commit 332a08fe33cddffec82dbd377ee0c941a0066f64
Merge: a67398114b7a08
Author: Bob Nystrom <robert@stuffwithstuff.com>
Date: Wed Mar 16 08:01:00 2016 -0700
Merge branch 'errorFn' of https://github.com/ppvk/wren into ppvk-errorFn
commit 14b7a086ce
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:33:37 2016 -0500
missing semicolon, accessing vm through parser in
commit 924eaa1f9d
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:25:32 2016 -0500
fixed missing errorFn in wren.h
commit 3761df111f
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:23:51 2016 -0500
Added an errorFn to the CLI
commit d51137b4ab
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:21:16 2016 -0500
Added a WrenErrorFn typedef, an errorFn slot in WrenConfiguration. exits early if is not defined, otherwise it runs the errorFn .
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.
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.
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!
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.
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.
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.