Commit Graph

484 Commits

Author SHA1 Message Date
Bob Nystrom
8436ce1934 Add a random module. 2015-10-17 11:03:15 -07:00
Will Speak
d45c0d7f82 Add Support for \U Style Unicode Escapes
This allows fuky things such as 🚀 and 😀 to be Direclty encoded in
Wren strings.
2015-10-17 10:35:46 +01:00
Bob Nystrom
d431c2eaa8 Start sketching in support for reading from stdin. 2015-10-16 21:05:24 -07:00
Bob Nystrom
d5b9f0096c Move Meta to a separate module.
Also cleaned up some of the code around loading the core module.
2015-10-15 18:08:56 -07:00
Bob Nystrom
8980d34ee5 Only close an upvalue for a local if there actually is one for it. 2015-10-08 08:06:29 -07:00
Bob Nystrom
24cbb7f399 Fix closures in methods.
A local name inside a method should always resolve to a self send even
if there is a local variable with that name outside of the method.
2015-10-05 07:44:51 -07:00
Bob Nystrom
812bc15380 Get rid of the special "call" primitive result type.
Instead, Fn.call(...) is a special *method* type that has the same
special sauce. The goal is eventually to get rid of the primitive
result type entirely.
2015-10-03 19:04:11 -07:00
Bob Nystrom
b7ed774da3 Reading files!
- File.close()
- File.open()
- File.read()
- file.readBytes()

And a few other little methods. Still lots more work to do, but it's a
start.
2015-09-30 21:13:36 -07:00
Bob Nystrom
bacbd85543 Add .isInfinity and .isInteger to Num. 2015-09-30 08:41:43 -07:00
Bob Nystrom
b05a74da19 Revamp how runtime errors and fiber switching is handled.
- Add Fiber.transferError(_).
- Primitives place runtime errors directly in the fiber instead of on
  the stack.
- Primitives that change fibers set it directly in the VM.
- Allow a fiber's error to be any object (except null).
2015-09-29 22:57:03 -07:00
Bob Nystrom
79354f5a97 Do some work on wrenCall().
- Add an explicit va_list version. That lets variadic functions
  forward to it.
- Fix a GC bug in wrenCall() with return values.
- Make the call API test not re-enter the VM.
2015-09-29 19:29:10 -07:00
Bob Nystrom
f757c9efac Better embedding API support (and tests!) for strings with null bytes.
- Test that a foreign method can return strings.
- Test that a foreign method can return a string with null bytes.
- Test wrenCall().
- Allow passing NULL for "v" to wrenCall().
- Allow "a" for passing an explicit length byte array to wrenCall().
2015-09-24 08:02:31 -07:00
Bob Nystrom
8ef4ea6186 Allow super calls in static methods. 2015-09-19 15:19:41 -07:00
Bob Nystrom
dc527c8d86 Add "io" module with beginnings of a File class. 2015-09-16 07:34:49 -07:00
Bob Nystrom
251752fcfb Make join() require parentheses without a separator. 2015-09-16 07:15:48 -07:00
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
1a27593993 Error if a class tries to inherit from null.
Fix #246.
2015-09-12 10:14:04 -07:00
Bob Nystrom
e1f979e78a Don't use string length in map benchmark (since it's slow now). 2015-09-12 09:59:30 -07:00
Bob Nystrom
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
Bob Nystrom
c0b5ec9f15 Move codePointAt() to separate CodePointSequence class. 2015-09-11 07:56:01 -07:00
Bob Nystrom
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
Bob Nystrom
783a5b750a Get ranges working in string subscripts (again).
Now with UTF-8 hotness!
2015-09-01 22:14:55 -07:00
Bob Nystrom
2e83f056c1 No more default constructors.
Fixes #296.
2015-09-01 08:16:04 -07:00
Bob Nystrom
36f3059e48 Get finalizers working. 2015-08-31 21:56:21 -07:00
Bob Nystrom
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
Lukas Werling
d7eed08774 Add some tests with invalid trailing commas 2015-08-31 06:41:09 -07:00
Lukas Werling
b20c9a1b38 Allow trailing comma in list literal 2015-08-31 06:41:09 -07:00
Lukas Werling
e1d3596643 Allow trailing comma in map literal 2015-08-31 06:41:09 -07:00
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
f33b362cc0 Clean up delta_blue benchmark. 2015-08-27 06:25:24 -07:00
Bob Nystrom
7be1fb543b Fix test name. 2015-08-20 22:04:42 -07:00
minirop
0c539af6ac added scientific notation 2015-08-16 11:50:45 +02:00
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
9845ed5126 Tests for Timer.sleep(). 2015-08-08 07:17:30 -07:00
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
0631f3b109 Fix deadlock bug in map insertion. 2015-08-06 06:55:30 -07:00
Bob Nystrom
71ab3ca887 Use "construct" instead of "this" to define constructors. 2015-07-21 07:24:53 -07:00
Bob Nystrom
bc822cd4c7 Merge branch 'master' into constructor-methods 2015-07-19 12:49:23 -07:00
Bob Nystrom
d91c06d18b Tweak IO library a bit:
- Reword some docs.
- Make IO.printAll() public.
- Require () on read.
2015-07-18 14:09:00 -07:00
Bas van den Berg
df6b5cfde1 Added string_equals.py 2015-07-10 19:40:10 +02:00
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
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
Bob Nystrom
4a15653c66 Add isEmpty to Sequence.
Thanks, Michel and Thorbjørn!
2015-06-30 06:52:29 -07:00
Bob Nystrom
bf730bb953 More tests for invalid code points. 2015-06-27 08:11:58 -07:00
Bob Nystrom
06feba4861 Merge branch 'master' into fix-super 2015-05-27 06:57:20 -07:00
Bob Nystrom
d66556b713 Add API tests for returning null or numbers. 2015-05-24 10:04:24 -07:00
Bob Nystrom
7084d6bfd5 Add infrastructure to test embedding API. 2015-05-24 09:23:30 -07:00
Bob Nystrom
e861b86563 Revert 40897f3348.
It leaks memory in the case of runtime errors.
2015-05-19 06:50:17 -07:00
Bob Nystrom
8834dcfe1d Add (failing) tests. 2015-05-19 06:47:42 -07:00
Bob Nystrom
40897f3348 Don't stackoverflow on recursive lists and maps. Fix #3. 2015-05-03 11:13:05 -07:00
Bob Nystrom
3f06553f7f Allow fibers as map keys. 2015-05-03 11:12:17 -07:00
Bob Nystrom
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
Bob Nystrom
a907c143c8 Test referring to lowercase class name inside class.
Fix #251.
2015-04-25 10:47:55 -07:00
Bob Nystrom
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
Bob Nystrom
75a3051fae .list -> .toList
Fix #248.
2015-04-03 11:22:34 -07:00
Bob Nystrom
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
Bob Nystrom
561d46ef1d Merge pull request #241 from bjorn/sequence_each
Added Sequence.each
2015-04-01 07:10:21 -07:00
Bob Nystrom
92a054f76a Don't make locals in scope in their own initializer. 2015-04-01 07:05:40 -07:00
Thorbjørn Lindeijer
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
Thorbjørn Lindeijer
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
Bob Nystrom
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
Bob Nystrom
53ee453f0f Merge pull request #239 from bjorn/sequence_list
Added Sequence.list
2015-03-28 09:06:49 -07:00
Bob Nystrom
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
Thorbjørn Lindeijer
b409569b6f Added Sequence.list
This helper method turns any sequence into a List.
2015-03-27 22:59:58 +01:00
Bob Nystrom
7d45dda383 String.fromCodePoint(). Fix #219. 2015-03-27 07:43:36 -07:00
Bob Nystrom
322eea1af5 Generate a runtime error if a foreign method was not found. 2015-03-26 07:17:09 -07:00
Bob Nystrom
d99a82e6d8 Merge branch 'meta-library' of git://github.com/gsmaverick/wren into gsmaverick-meta-library 2015-03-25 19:21:58 -07:00
Bob Nystrom
c9226256ff Merge pull request #220 from bjorn/count_predicate
Added Sequence.count(predicate)
2015-03-23 07:35:17 -07:00
Bob Nystrom
89ebffb582 Rearrange a bit. 2015-03-23 06:48:08 -07:00
Gavin Schulz
a937bd1cf9 Adds a Meta library with an eval function for interpreting code inline. 2015-03-22 14:17:02 -07:00
Gavin Schulz
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
Bob Nystrom
1301410142 Merge branch 'num_methods' of git://github.com/bjorn/wren into bjorn-num_methods 2015-03-21 12:54:08 -07:00
Thorbjørn Lindeijer
07951bbeae Added Num.pi and some tests 2015-03-19 21:12:50 +01:00
Thorbjørn Lindeijer
94804fe1a0 Added Sequence.count(predicate)
Returns the number of elements in the sequence that pass the
`predicate`.

It could also have been implemented as:

  count(f) { reduce(0) {|a, b| f.call(b) ? a + 1 : a } }

But I considered the simple version more readable.

Also documented Sequence.count.
2015-03-19 21:10:05 +01:00
Bob Nystrom
a3abf31da0 Merge pull request #222 from bjorn/sequence_contains
Moved List.contains to Sequence.contains, added tests and docs
2015-03-18 07:54:55 -07:00
Bob Nystrom
be11d09bd8 Store hash code in strings.
Makes string equality and string map keys much faster.
Also did some other general string clean-up.
2015-03-18 07:09:03 -07:00
Bob Nystrom
b80ba29b0e Merge branch 'master' of https://github.com/munificent/wren 2015-03-17 07:01:09 -07:00
Bob Nystrom
b4fa4acce1 Handle empty string map keys. 2015-03-17 07:00:54 -07:00
Thorbjørn Lindeijer
d7a91117ac Reverse the argument order of List.insert
The previous order, insert(element, index), was counter-intuitive.
I'm not aware of any list API that uses this order. I've checked:

* Ruby Array.insert(index, obj...)
* JavaScript array.splice(start, deleteCount[, item1[, item2[, ...]]])
* C++ / QList::insert(int i, const T & value)
* C++ / std::vector::insert
* Lua table.insert (list, [pos,] value)
* C# List<T>.Insert(int index, T item)
* Java Interface List<E>.add(int index, E element)
* Python list.insert(i, x)

So it seemed to me more like an oversight in Wren.
2015-03-15 22:51:24 +01:00
Thorbjørn Lindeijer
fc1dc4c54b Moved List.contains to Sequence.contains, added tests and docs 2015-03-15 15:59:42 +01:00
Bob Nystrom
64eccdd9be Reorganize tests and benchmark scripts.
Mainly to get rid of one top level directory. But this will
also be useful when there are tests of the embedding API.
2015-03-14 12:45:56 -07:00
Bob Nystrom
5459993857 Add Class.supertype.
Thanks, Michel!
2015-03-14 09:48:45 -07:00
Bob Nystrom
69567c5eb5 Control string representation of infinity. 2015-03-13 07:35:10 -07:00
Bob Nystrom
b36b71d3c6 Merge pull request #212 from soveran/io-read-eof
Change IO.read to return null on EOF
2015-03-07 13:47:07 -08:00
Bob Nystrom
05ba7d9fbf Add fiber features needed for to write an external scheduler:
- Allow yielding the main fiber. This exits the interpreter. The
  host can resume it by calling a method.
- Allow getting a reference to the current fiber.
2015-03-07 12:32:11 -08:00
Michel Martens
542a783cb4 Change IO.read to return null on EOF 2015-03-07 09:10:18 +00:00
Bob Nystrom
632a01d584 Merge branch 'num_methods' of git://github.com/MarcoLizza/wren into MarcoLizza-num_methods 2015-03-06 22:43:02 -08:00
Bob Nystrom
d35e3c917c Add count to Sequence. 2015-03-06 07:01:02 -08:00
Marco Lizza
d56e2d6398 Removing old tests. 2015-03-05 11:27:56 +01:00
Marco Lizza
130d0df957 Fixing the test a bit. 2015-03-05 11:24:54 +01:00
Marco Lizza
fde6f74d15 Adding tests. 2015-03-04 16:12:08 +01:00
Bob Nystrom
90aa43450b Merge branch 'master' of git://github.com/bjorn/wren into bjorn-master 2015-03-03 07:23:47 -08:00
Bob Nystrom
28005ed47a Refactor number parsing a bit. 2015-03-03 07:17:56 -08:00
Gavin Schulz
0ec31433c8 Generate an error if a number literal is too large to be represented with the Num class. 2015-03-03 00:07:55 -08:00
Thorbjørn Lindeijer
8f985847d4 Added Sequence.any as complement to Sequence.all 2015-03-01 23:14:32 +01:00
Bob Nystrom
c27a094882 Reorganize superclass validation a bit. 2015-02-27 08:08:27 -08:00
Bob Nystrom
46713a5bb3 Merge branch 'issue-70' of git://github.com/verpeteren/wren into verpeteren-issue-70 2015-02-27 07:41:25 -08:00
Bob Nystrom
96ceaa528b Allow empty argument list methods.
- Compile them as calls and definitions.
- Use them for call(), clear(), run(), try(), and yield().
- Update the docs.
2015-02-26 23:08:36 -08:00
Bob Nystrom
1aaa8cff52 Use more comprehensive signature strings for methods. 2015-02-26 21:56:15 -08:00
Peter Reijnders
f05d6143f5 Generating a runtime error on subclassing of builtins
As discussed in https://github.com/munificent/wren/issues/70, it is not allowed to subclass built-in types.
2015-02-25 20:13:37 +01:00
Bob Nystrom
6a10d9740c Merge pull request #187 from MarcoLizza/bitwise_precedence
Bitwise precedence
2015-02-25 07:14:31 -08:00
Bob Nystrom
fc2ed6f6e1 Don't allow trailing non-number characters when parsing a string to a number. 2015-02-25 07:07:54 -08:00
Marco Lizza
cec1f9160a Moving bitwise precedence-test to the correct folder. 2015-02-25 16:00:53 +01:00
Gavin Schulz
f4a39bc943 Code review changes. 2015-02-25 01:20:53 -08:00
Marco Lizza
dfa1b51663 Add bitwise operators precedence test. 2015-02-23 17:29:31 +01:00
Gavin Schulz
03a5b96040 Add a fromString static method on Num that converts strings to numbers. 2015-02-22 20:06:17 -08:00
Bob Nystrom
0f9e15833f Unify argument parsing. Fix #24. 2015-02-22 10:42:49 -08:00
Bob Nystrom
ae88ee539d Merge branch 'master' of https://github.com/munificent/wren 2015-02-18 07:55:38 -08:00
Bob Nystrom
b2ca4c0381 Allow zero or multiple imported names. 2015-02-17 07:32:33 -08:00
Marco Lizza
00cdef303c Adding new bitwise operands tests. 2015-02-16 11:30:15 +01:00
Bob Nystrom
a44d479643 Basic import syntax. 2015-02-14 16:46:00 -08:00
Bob Nystrom
bc5a793c41 Split out the core and main modules.
- Implicitly import everything in core into every imported module.
- Test cyclic imports.
2015-02-11 10:06:45 -08:00
Bob Nystrom
2005e1e0a2 Add ".wren" to modules in the embedder. 2015-02-06 11:52:05 -08:00
Bob Nystrom
bb647d4247 Start getting module loading working.
Right now, it uses a weird "import_" method on String which
should either be replaced or at least hidden behind some syntax.

But it does roughly the right thing. Still lots of corner cases to
clean up and stuff to fix. In particular:

- Need to handle compilation errors in imported modules.
- Need to implicitly import all core and IO types into imported module.
- Need to handle circular imports.
  (Just need to give entry module the right name for this to work.)
2015-02-06 07:01:15 -08:00
Bob Nystrom
55caae343b Add "." to comments. :) 2015-02-04 20:26:29 -08:00
Bob Nystrom
ddd20c687e Merge branch 'master' into MarcoLizza-8_bit_strings_tests 2015-02-04 20:25:12 -08:00
Bob Nystrom
878be6fb6b Clean up wrenStringFind() a bit. 2015-02-04 20:23:50 -08:00
Marco Lizza
d73b19967d Adding 8-bit strings test cases. 2015-02-04 13:58:16 +01:00
Bob Nystrom
0aa4d7c2bd Fix crash when doing a lookup on an empty map. 2015-01-28 19:19:04 -08:00
Gavin Schulz
f482a53d0e Define equality on ranges. 2015-01-25 19:50:54 -08:00
Bob Nystrom
41d9ba9b3d Merge branch 'hex-literals' of git://github.com/gsmaverick/wren into gsmaverick-hex-literals 2015-01-25 17:49:05 -08:00
Bob Nystrom
4579171afa Add remove() to Map. 2015-01-25 17:42:36 -08:00
Gavin Schulz
0ad7a7d9ff Code review changes. 2015-01-25 13:02:44 -08:00
Bob Nystrom
0e6a90443e Add containsKey() to Map, and validate key types. 2015-01-25 12:39:19 -08:00
Bob Nystrom
492c730e6f Key and value iteration for maps. Also toString. 2015-01-25 10:27:38 -08:00
Bob Nystrom
251b623c65 Map "clear" method. 2015-01-25 08:39:44 -08:00
Bob Nystrom
e740a4c95a Map literals! 2015-01-24 23:21:50 -08:00
Bob Nystrom
abe80e6d4b Initial map implementation.
Still lots of methods missing and clean up and tests to do.
Also still no literal syntax.

But the core hash table code is there and working. The supported
key types are all, uh, supported.
2015-01-24 22:27:35 -08:00
Gavin Schulz
12102b19ef Adds support for hexadecimal literals. 2015-01-24 22:07:46 -08:00
Bob Nystrom
cff08f989b Rename a couple of tests. 2015-01-24 14:42:25 -08:00
Bob Nystrom
438e7bae3f Merge branch 'list-join' of git://github.com/gsmaverick/wren into gsmaverick-list-join 2015-01-24 14:39:45 -08:00
Gavin Schulz
4977083904 Abstract List's toString method to a more general join method on Sequence. 2015-01-24 14:01:16 -08:00
Bob Nystrom
efd161cea2 Add "arity" getter to Fn. 2015-01-23 20:33:05 -08:00
Bob Nystrom
eb424f5c1a Make strings iterable over their code points.
I'm not sure why, but this also regresses perf:

binary_trees - wren            ..........  3290  0.30s   96.68% relative to baseline
delta_blue - wren              ..........  7948  0.13s   99.06% relative to baseline
fib - wren                     ..........  3165  0.32s   95.90% relative to baseline
for - wren                     ..........  8242  0.12s   96.00% relative to baseline
method_call - wren             ..........  5417  0.18s   78.74% relative to baseline

Need to investigate.
2015-01-22 20:58:22 -08:00
Bob Nystrom
a5b00cebe7 Clarify how string subscripting handles UTF-8. 2015-01-22 16:38:03 -08:00
Bob Nystrom
a92e58c804 Add tests for string methods that support UTF-8 already. 2015-01-22 15:28:54 -08:00
Bob Nystrom
c5e67953b8 Allow non-ASCII UTF-8 characters in string literals. 2015-01-22 15:18:30 -08:00
Evan Shaw
513af6df65 Fix precedence of % operator
It previously had the same precedence as + and -.
2015-01-22 09:49:53 +13:00
Bob Nystrom
9453acf1e6 User-defined subscript operators. 2015-01-20 18:25:54 -08:00
Bob Nystrom
b55eb7de7a Merge branch 'string-range-subscript' of git://github.com/gsmaverick/wren into gsmaverick-string-range-subscript 2015-01-20 15:01:14 -08:00
Gavin Schulz
bfc2f9c0ee Adds range subscripting for strings. 2015-01-18 22:55:30 -08:00
Bob Nystrom
d8b678356e Raise precedence of "is". Fix #119. 2015-01-18 10:20:13 -08:00
Luchs
82740d2668 Add a test demonstrating folding order 2015-01-16 09:48:59 +01:00
Luchs
4bc06a3acc Add reduce test for ranges 2015-01-16 09:33:23 +01:00
Luchs
d764581a3d Add test for empty reduce 2015-01-16 09:29:45 +01:00
Luchs
5cfb638fd1 Use @munificent's single-argument reduce 2015-01-16 09:26:19 +01:00
Luchs
4c6b819ed1 Add reduce function on Sequence 2015-01-16 09:24:59 +01:00
Bob Nystrom
64c2bd7633 Make all types support "!" so "if (!foo)" works reliably for all objects. 2015-01-15 21:50:01 -08:00
Gavin Schulz
2ddf0a9586 Fix some overlooked references to forall. 2015-01-15 19:05:58 -08:00
Bob Nystrom
4249f92571 Rename tests. 2015-01-15 06:54:16 -08:00
Bob Nystrom
78e99c6c99 Merge branch 'list-forall' of git://github.com/gsmaverick/wren into gsmaverick-list-forall 2015-01-15 06:52:43 -08:00
Gavin Schulz
b829ce67af Rename forall to all. 2015-01-14 23:19:31 -08:00
Bob Nystrom
c50e46725f Implicitly define nonlocal names.
If a capitalized name cannot be resolved, a new top-level
variable with its name is implicitly declared. If a real
definition is not found later, a compile time error is raised.

Mutual recursion at the top level works now!

Fix #101. Fix #106.
2015-01-14 23:08:25 -08:00
Gavin Schulz
f2b334d7d2 Add more forall test cases. 2015-01-14 22:51:34 -08:00
Gavin Schulz
7716ad6263 Adds forall method on Sequences. 2015-01-13 23:47:01 -08:00
Bob Nystrom
a8e2ba233c Add support for "nonlocal" (capitalized) names, and change how variable lookup works.
Inside a method, all local variable lookup stops at the method boundary. In other
words, methods, do not close over outer local variables.

If a name is not found inside a method and is lowercase, it's a method on this.
If it's capitalized, it's a global variable.
2015-01-13 21:36:42 -08:00
Bob Nystrom
1d9445d9bc Tests for IO.read(). 2015-01-11 21:47:29 -08:00
Bob Nystrom
73b041a78a Merge branch 'master' of git://github.com/Alek900/wren into Alek900-master
Conflicts:
	src/wren_compiler.c
2015-01-11 20:01:30 -08:00
Bob Nystrom
21e740d5c3 Test that carriage returns are treated like whitespace. 2015-01-11 19:58:30 -08:00
Bob Nystrom
be0032cc40 Merge branch 'segfault_on_top_level_super_with_no_args' of git://github.com/zeckalpha/wren into zeckalpha-segfault_on_top_level_super_with_no_args 2015-01-11 19:42:26 -08:00
Bob Nystrom
bc29e0929e Rename a couple of files and tweak some docs. 2015-01-11 19:13:15 -08:00
Gavin Schulz
7557c91b3c Adds some common methods to strings. 2015-01-11 16:06:56 -08:00
Kyle Marek-Spartz
c376d88e61 super at top level: Allow the compiler to continue compilation after erroring. Added two more tests. 2015-01-11 17:44:10 -06:00
Kyle Marek-Spartz
3490c8d2f3 Segfault when calling super at top-level with no arguments.
If enclosingClass is null, we can't proceed with compilation since we don't have its name.
2015-01-09 15:14:06 -06:00
Bob Nystrom
3116bf97de Use correct buffer size in string subscript operator. 2015-01-09 07:12:25 -08:00
Bob Nystrom
bcf052436f Merge pull request #94 from edsrzf/fix-neg-number
Don't treat negative numbers as literals
2015-01-09 07:00:12 -08:00
Evan Shaw
75d28c083c Don't treat negative numbers as literals
Fixes #93.

Previously, "1 -1" was lexed as two number tokens: a positive literal and
a negative literal. This caused problems when it came to parsing.

Now the '-' and the second number are separate tokens.

Note this is a breaking change, since `-16.sqrt` is now parsed as `-(16.sqrt)`,
as opposed to `(-16).sqrt`.

There is a small bit of overhead to doing it this way, but it might be possible
to optimize that out in the compiler at some point in the future.
2015-01-09 20:17:40 +13:00
Bob Nystrom
a9f1d52ef7 Merge branch 'improve-debugging' of git://github.com/gsmaverick/wren into gsmaverick-improve-debugging 2015-01-08 21:49:20 -08:00
Bob Nystrom
15b0d8777c Handle toString not returning a string in IO.print and IO.write.
Fix #67.
2015-01-08 07:53:37 -08:00
Bob Nystrom
09bb28735c Merge branch 'feature-shebang-support' of git://github.com/mauvm/wren into mauvm-feature-shebang-support 2015-01-04 13:02:42 -08:00
Bob Nystrom
a9bb2387a1 Handle empty (or comment-only) files. Fix #57. 2015-01-04 13:00:53 -08:00
Gavin Schulz
7f90485cff Let the user know the arity of a missing method in the error message. 2015-01-04 14:42:11 -05:00
mauvm
4200f18f83 Rename test for invalid shebang. 2015-01-04 20:09:33 +01:00
mauvm
6c549e0cc5 Use lexError() and add test for invalid shebang. 2015-01-04 19:56:16 +01:00
mauvm
8a54ef9919 Add tests. 2015-01-03 20:53:17 +01:00
Bob Nystrom
c25cfca18b Eliminate semicolons entirely. 2015-01-03 10:02:45 -08:00
Aleksander
d1ac8c314f Added test for whitespace in code 2015-01-03 15:10:04 +01:00
Aleksander
150ea237e9 Added test and fixed skipping whitespace 2015-01-03 14:57:34 +01:00
Bob Nystrom
c967439ead Add Fiber.abort() method. 2015-01-01 10:40:14 -08:00
Bob Nystrom
a94dfdac10 Add test for too many constants in one function. 2014-12-06 16:39:39 -08:00
Bob Nystrom
f6cbb6ad75 Add Fiber.try(). 2014-10-15 06:36:42 -07:00
Bob Nystrom
feb9f7cb53 Fix crash bug in closure capturing. 2014-04-24 17:52:53 -07:00
Bob Nystrom
80a4eb8c9c Better error message on too many inherited fields. 2014-04-22 07:06:26 -07:00
Bob Nystrom
3087daaece Add a closure test. 2014-04-19 17:48:06 -07:00
Bob Nystrom
09c707e16a More tests for super calls. 2014-04-19 11:51:36 -07:00
Bob Nystrom
48dab5323d A few small cleanups. 2014-04-19 11:44:51 -07:00
Bob Nystrom
05717e763d Move tests to right directory. 2014-04-19 11:41:21 -07:00
Bob Nystrom
f03895b17e Symmetric coroutines! 2014-04-14 07:23:05 -07:00
Bob Nystrom
7393e12555 Allow multiple arguments to IO.print(). 2014-04-09 07:48:35 -07:00
Bob Nystrom
b2941cbbb6 Docs for operators and some other stuff. 2014-04-08 21:18:17 -07:00
Bob Nystrom
3a55acfe1a Test string concatenation. 2014-04-08 21:17:49 -07:00
Bob Nystrom
dca58ff747 Require parentheses around operator and setter arguments. 2014-04-08 17:54:37 -07:00
Bob Nystrom
f6dd88937b Support "new" on lists. 2014-04-08 07:31:23 -07:00