1
0
forked from Mirror/wren
Commit Graph

505 Commits

Author SHA1 Message Date
e1d3596643 Allow trailing comma in map literal 2015-08-31 06:41:09 -07:00
556af50f83 Revise low level fiber semantics to play nicer with schedulers.
Now that I'm starting to write a real async scheduler on top of Wren's
basic fiber API, I have a better feel for what it needs. It turns out
run() is not it.

- Remove run() methods.
- Add transfer() which leaves the caller of the invoked fiber alone.
- Add suspend() to return control to the host application.
- Add Timer.schedule() to start a new independently scheduled fiber.
- Change Timer.sleep() so that it only transfers control to explicitly
  scheduled fibers, not any one.
2015-08-30 22:15:37 -07:00
91af02ac81 Merge branch 'master' into libuv
# Conflicts:
#	project/xcode/wren.xcodeproj/project.pbxproj
#	script/wren.mk
#	src/cli/main.c
#	src/cli/vm.c
#	src/cli/vm.h
#	test/api/main.c
2015-08-28 23:13:56 -07:00
b4deb30a02 Reorganize build scripts for libuv.
- Create separate libs for each architecture. OS X doesn't need this
  (we just build a universal binary), but it will help Linux.
- Move the libuv build stuff into wren.mk where the actual dependency
  on the lib is.
- Download libuv to deps/ instead of build/. That way "make clean"
  doesn't blow it away.
- Don't redownload libuv unless needed.
2015-08-28 19:31:03 -07:00
f33b362cc0 Clean up delta_blue benchmark. 2015-08-27 06:25:24 -07:00
7be1fb543b Fix test name. 2015-08-20 22:04:42 -07:00
0c539af6ac added scientific notation 2015-08-16 11:50:45 +02:00
48bdbc7745 First pass at implementing foreign classes.
Most of the pieces are there:

- You can declare a foreign class.
- It will call your C function to provide an allocator function.
- Whenever a foreign object is created, it calls the allocator.
- Foreign methods can access the foreign bytes of an object.
- Most of the runtime checking is in place for things like subclassing
  foreign classes.

There is still some loose ends to tie up:

- Finalizers are not called.
- Some of the error-handling could be better.
- The GC doesn't track how much memory a marked foreign object uses.
2015-08-15 12:07:53 -07:00
7a79b8fac6 Simplify the API tests.
Use fewer test suites with more tests in each one since there's so much
boilerplate for defining an API test.
2015-08-13 09:09:27 -07:00
9845ed5126 Tests for Timer.sleep(). 2015-08-08 07:17:30 -07:00
d4acbe8a70 A vertical slice of real libuv integration.
This adds a "timer" module to the CLI that provides a Timer class with
a static sleep() method. Not the most exciting functionality in the
world, but it requires the full hunk of libuv integration:

- The CLI sets up libuv and runs the event loop.
- Added a new directory src/module for CLI modules.
- Updated all the make scripts to handle it.
- Reorganized some other CLI code.
2015-08-07 08:10:55 -07:00
0b97b27cf4 Add an API for storing handles to values outside of the VM.
It's pretty bare bones now, but it lets you get a reference to an object
from a foreign call and then return it later.
2015-08-06 22:24:15 -07:00
0631f3b109 Fix deadlock bug in map insertion. 2015-08-06 06:55:30 -07:00
71ab3ca887 Use "construct" instead of "this" to define constructors. 2015-07-21 07:24:53 -07:00
bc822cd4c7 Merge branch 'master' into constructor-methods 2015-07-19 12:49:23 -07:00
d91c06d18b Tweak IO library a bit:
- Reword some docs.
- Make IO.printAll() public.
- Require () on read.
2015-07-18 14:09:00 -07:00
df6b5cfde1 Added string_equals.py 2015-07-10 19:40:10 +02:00
5fb6186d7d Make constructors just methods.
* Eliminate "new" reserved word.
* Allow "this" before a method definition to define a constructor.
* Only create a default constructor for classes that don't define one.
2015-07-10 09:18:22 -07:00
fa8ac84a8b Fix broken test runner (!).
If a test expected an error and found at least one, it would not fail
on any other expected errors that didn't occur.

Also, some tests were expecting a compile time error message even though
the test script doesn't validate those (yet).

The test function was getting monolithic, so I went ahead and split it
into a separate little class.
2015-07-09 08:06:33 -07:00
2387d4dc31 Grow the call frame array dynamically.
Previously, fibers had a hard-coded limit to how big their stack size
is. This limit exists in two forms: the number of distinct call frames
(basically the maximum call depth), and the number of unique stack
slots.

This fixes the first half of this by dynamically allocating the call
frame array and growing it as needed. This makes new fibers smallers
since they can start with a very small array. Checking and growing as
needed doesn't noticeably regress the perf on the other benchmarks, and
it makes a new fiber benchmark about 45% faster.

The stack array is still hardcoded, but that will be in another commit.
2015-07-01 00:00:25 -07:00
4a15653c66 Add isEmpty to Sequence.
Thanks, Michel and Thorbjørn!
2015-06-30 06:52:29 -07:00
bf730bb953 More tests for invalid code points. 2015-06-27 08:11:58 -07:00
06feba4861 Merge branch 'master' into fix-super 2015-05-27 06:57:20 -07:00
d66556b713 Add API tests for returning null or numbers. 2015-05-24 10:04:24 -07:00
7084d6bfd5 Add infrastructure to test embedding API. 2015-05-24 09:23:30 -07:00
e861b86563 Revert 40897f3348.
It leaks memory in the case of runtime errors.
2015-05-19 06:50:17 -07:00
8834dcfe1d Add (failing) tests. 2015-05-19 06:47:42 -07:00
40897f3348 Don't stackoverflow on recursive lists and maps. Fix #3. 2015-05-03 11:13:05 -07:00
3f06553f7f Allow fibers as map keys. 2015-05-03 11:12:17 -07:00
fcf4197139 Add Object.same(_,_) to access built-in equality even for classes that may override ==.
Had to add a new metaclass for Object since it now has its own static method so we
can't just use Class as its metaclass. (We don't want *every* class to have a same(_,_)
static method.)
2015-05-01 07:55:28 -07:00
a907c143c8 Test referring to lowercase class name inside class.
Fix #251.
2015-04-25 10:47:55 -07:00
82ce1d8be9 Fix up Meta.eval(_).
- Made it use primitives instead of foreign functions.
- This fixed an issue where the interpreter loop was running re-entrantly.
- Which in turn fixed a GC bug.
- Report a runtime error if the argument isn't a string.
- Report a runtime error if the source doesn't compile.
2015-04-03 21:22:58 -07:00
75a3051fae .list -> .toList
Fix #248.
2015-04-03 11:22:34 -07:00
f4a836c66e Merge branch 'deferred_execution' of git://github.com/bjorn/wren into bjorn-deferred_execution
Conflicts:
	builtin/core.wren
	src/vm/wren_core.c
2015-04-01 07:22:02 -07:00
561d46ef1d Merge pull request #241 from bjorn/sequence_each
Added Sequence.each
2015-04-01 07:10:21 -07:00
92a054f76a Don't make locals in scope in their own initializer. 2015-04-01 07:05:40 -07:00
a8ea2a91a6 Use deferred execution for Sequence.map and Sequence.where
The methods Sequence.map and Sequence.where are now implemented using
deferred execution. They return an instance of a new Sequence-derived
class that performs the operation while iterating. This has three main
advantages:

* It can be computationally cheaper when not the whole sequence is
  iterated.

* It consumes less memory since it does not store the result in a newly
  allocated list.

* They can work on infinite sequences.

Some disadvantages are:

* Iterating the returned iterator will be slightly slower due to
  the added indirection.

* You should be aware that modifications made to the original sequence
  will affect the returned sequence.

* If you need the result in a list, you now need to call Sequence.list
  on the result.
2015-03-31 22:25:07 +02:00
c00d6ad694 Added Sequence.each
This is a bit of a style preference since of course you can always write
the same thing with a for loop. However, I think sometimes the code
looks better when using this method.

It also provides an alternative to Sequence.map for cases where you
don't need the resulting list, and one that becomes especially necessary
when Sequence.map is changed to return a new sequence. The example in
the README.md file was using Sequence.map in a way that required this
alternative in that case.
2015-03-31 21:53:29 +02:00
07f9d4d2be Tweak Sequence.all() and Sequence.any().
When possible, they return the actual value from the predicate
instead of always just "true" and "false". This matches && and ||
which evaluate to the RHS or LHS when appropriate.
2015-03-28 10:18:45 -07:00
53ee453f0f Merge pull request #239 from bjorn/sequence_list
Added Sequence.list
2015-03-28 09:06:49 -07:00
72c38a59ce More stuff for working with strings and bytes!
- "\x" escape sequence to put byte values in strings: "\x34"
- String.byteAt(index) gets value of byte in string.
- String.bytes returns a raw sequence of bytes for a string.
- String.codePointAt(index) gets the code point at an offset as a raw number.
2015-03-27 20:44:07 -07:00
b409569b6f Added Sequence.list
This helper method turns any sequence into a List.
2015-03-27 22:59:58 +01:00
7d45dda383 String.fromCodePoint(). Fix #219. 2015-03-27 07:43:36 -07:00
322eea1af5 Generate a runtime error if a foreign method was not found. 2015-03-26 07:17:09 -07:00
d99a82e6d8 Merge branch 'meta-library' of git://github.com/gsmaverick/wren into gsmaverick-meta-library 2015-03-25 19:21:58 -07:00
c9226256ff Merge pull request #220 from bjorn/count_predicate
Added Sequence.count(predicate)
2015-03-23 07:35:17 -07:00
89ebffb582 Rearrange a bit. 2015-03-23 06:48:08 -07:00
a937bd1cf9 Adds a Meta library with an eval function for interpreting code inline. 2015-03-22 14:17:02 -07:00
91c69ccbf0 If module name does not specify a file try to load it as a module package instead. 2015-03-21 16:05:02 -07:00
1301410142 Merge branch 'num_methods' of git://github.com/bjorn/wren into bjorn-num_methods 2015-03-21 12:54:08 -07:00