1
0
forked from Mirror/wren
Commit Graph

319 Commits

Author SHA1 Message Date
58e4d26648 "IO" -> "System".
Get rid of the separate opt-in IO class and replace it with a core
System class.

- Remove wren_io.c, wren_io.h, and io.wren.
- Remove the flags that disable it.
- Remove the overloads for print() with different arity. (It was an
  experiment, but I don't think it's that useful.)
- Remove IO.read(). That will reappear using libuv in the CLI at some
  point.
- Remove IO.time. Doesn't seem to have been used.
- Update all of the tests, docs, etc.

I'm sorry for all the breakage this causes, but I think "System" is a
better name for this class (it makes it natural to add things like
"System.gc()") and frees up "IO" for referring to the CLI's IO module.
2015-09-15 07:46:09 -07:00
66b89a493f Combine io.c and vm.c.
(This is mainly to free up io.c as a built in module.)
2015-09-13 22:29:47 -07:00
ea5c3b01eb Add module for Scheduler.
Also reorganizes some code to make it easier to add more modules.
2015-09-13 11:32:39 -07:00
1a27593993 Error if a class tries to inherit from null.
Fix #246.
2015-09-12 10:14:04 -07:00
e1f979e78a Don't use string length in map benchmark (since it's slow now). 2015-09-12 09:59:30 -07:00
fe143644b3 Rationalize string lengths.
The .count getter on string returns the number of code points. That's
O(n), but it's consistent with the rest of the main string API.

If you want the number of bytes, it's "string".bytes.count.

Updated the docs.

Fixes 68. Woo!
2015-09-11 21:33:26 -07:00
c0b5ec9f15 Move codePointAt() to separate CodePointSequence class. 2015-09-11 07:56:01 -07:00
bda9ad880a Flesh out string byte handling a bit:
- Get rid of public byteAt(_) method on strings. It's redundant and
  longer than .bytes[_].
- Implement bytes.count natively so it's O(1).
2015-09-10 23:52:18 -07:00
783a5b750a Get ranges working in string subscripts (again).
Now with UTF-8 hotness!
2015-09-01 22:14:55 -07:00
2e83f056c1 No more default constructors.
Fixes #296.
2015-09-01 08:16:04 -07:00
36f3059e48 Get finalizers working. 2015-08-31 21:56:21 -07:00
2b044666ee Reorganize trailing comma code a bit.
- Split out syntax error tests.
- Avoid redundant handling of empty literals.
2015-08-31 07:23:36 -07:00
d7eed08774 Add some tests with invalid trailing commas 2015-08-31 06:41:09 -07:00
b20c9a1b38 Allow trailing comma in list literal 2015-08-31 06:41:09 -07:00
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