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
Bob Nystrom
f41be80e5f
Use a growable buffer for globals.
...
Also allows more than 256.
2014-04-06 16:16:15 -07:00
Bob Nystrom
9a8f2edda4
List.addAll().
2014-04-06 08:37:37 -07:00
Bob Nystrom
2da8025cd4
Fiber.create -> new Fiber
2014-04-04 18:24:55 -07:00
Bob Nystrom
f5a9f39568
Check argument type in new Fn.
2014-04-04 18:13:13 -07:00
Bob Nystrom
4a8cf3a7bf
Move newline handling down into parser.
...
This lets us make it a grammar feature and not a lexer trick.
Newlines are explicitly ignored in some parts of the grammar. This
lets, for example, things like "|" ignore the newline when used as
an operator, but not when used as a parameter delimiter in a block
argument.
2014-04-04 07:51:18 -07:00
Bob Nystrom
da4cadf16b
Unify body handling.
...
Blocks, functions, and methods now have the same code for handling
their bodies.
This means that single-line methods work like single-line functions:
they return the result of their expression.
2014-04-03 07:48:19 -07:00
Bob Nystrom
d146018559
Convert all fns to block arg syntax.
2014-04-02 19:41:53 -07:00
Bob Nystrom
a550d6cea4
Change how new operators are compiled.
...
Instead of an instruction that always instantiates an instance,
the "new" is compiled to a method call on the class, followed by a
method call on the (presumably) new instance.
The former lets built-in types like Fn do special stuff instead of
allocating an instance. In particular, it means:
new Fn { ... }
can just return the block argument.
2014-04-02 17:42:30 -07:00
Bob Nystrom
cc56ac4da7
Convert fiber tests to use block arguments.
2014-04-02 17:31:58 -07:00
Bob Nystrom
9a959c9eb9
Error if argument to new is not a class.
2014-03-06 06:51:16 -08:00
Bob Nystrom
44e68a5db9
Fix #31 . Bitwise operators on numbers.
2014-02-24 07:27:43 -08:00
Kyle Marek-Spartz
df4c1fa6b2
Changed phrasing, fixed and added a test.
2014-02-23 21:53:49 -06:00
Kyle Marek-Spartz
d25504eb4e
Put custom bitwise operator tests into existing operators test file.
2014-02-16 19:42:49 -06:00
Kyle Marek-Spartz
c43dbe96d3
Make custom bitwise operators work, add tests
2014-02-16 12:01:40 -06:00
Bob Nystrom
f8a9d7f321
Make Sequence base class.
...
This lets us share functionality between List and Range (and
other user-defined sequence types).
2014-02-16 09:20:31 -08:00
Bob Nystrom
e535d7a9e7
Conditional operator.
2014-02-15 11:36:01 -08:00
Bob Nystrom
4728687ca5
Merge branch 'feature/list-where' of git://github.com/zeckalpha/wren into zeckalpha-feature/list-where
...
Conflicts:
builtin/core.wren
src/wren_core.c
2014-02-15 11:21:24 -08:00
Kyle Marek-Spartz
3409d588e5
Added List.where method and tests.
2014-02-15 00:42:14 -06:00
Kyle Marek-Spartz
1d31c95872
Cleanups for merging map method
2014-02-15 00:34:30 -06:00
Kyle Marek-Spartz
83ea5aaf45
Add List.map method and test
2014-02-14 23:06:29 -06:00
Bob Nystrom
b1bae8fc6c
Fix #17 .
2014-02-14 20:15:49 -08:00
Bob Nystrom
ea3cfa05bd
Allow [0..-1] and [0...0] to work on empty lists.
2014-02-14 20:10:41 -08:00
Bob Nystrom
ca7ff222fe
Fix iterating over an empty list.
2014-02-14 17:24:06 -08:00
Kyle Marek-Spartz
e519ecbc49
Third try. ;) Concat operator, tests. Now [1,2,3] + (4..6) works! Inlined helper functions to keep core lib small.
2014-02-14 11:16:57 -06:00
Bob Nystrom
edd360a934
More fiber tests.
2014-02-14 07:16:56 -08:00
Bob Nystrom
ca4f4d6660
Test "this" in static methods.
2014-02-14 06:37:37 -08:00
Bob Nystrom
59bb7eec7a
Remove some outdated TODOs.
...
They’re TODONE!
2014-02-13 08:38:44 -08:00
Bob Nystrom
756fe0d920
Make "this" the implicit receiver!
2014-02-12 17:33:35 -08:00
Bob Nystrom
ec7e159017
Fix shrinking list capacity.
2014-02-10 07:55:14 -08:00
Bob Nystrom
7726ee5131
Handle extra and missing arguments to fn.call.
2014-02-04 09:34:05 -08:00
Bob Nystrom
ac7cb594f4
Handle invalid string literals.
2014-02-02 10:31:46 -08:00
Bob Nystrom
66f0b57bf3
Allow ranges in list subscript operator.
2014-01-30 09:12:44 -08:00
Bob Nystrom
5c2cf641ae
Make classes know their name.
2014-01-28 15:31:11 -08:00
Bob Nystrom
ce6ec301cf
Check that RHS of "is" is a class.
2014-01-21 07:52:03 -08:00
Bob Nystrom
635d695083
Validate number comparison operand types.
2014-01-21 07:44:11 -08:00
Bob Nystrom
90d1ed6aa6
Make null falsey.
2014-01-20 18:12:55 -08:00
Bob Nystrom
46c1ba9249
Fix #2 . Finish implementing Range.
...
Covers error and edge cases and fully tested now.
2014-01-20 13:20:22 -08:00
Bob Nystrom
97bf314f4b
Make Range a native object type.
...
Still need to implement better semantics, but this is an
important first step. It's much faster now too, which is good.
2014-01-20 08:45:15 -08:00
Bob Nystrom
83b5968340
Get static methods fully working.
...
They are compiled as local variables defined in an implicit
scope surrounding the class. This has the right semantics and,
better, means that there's no VM support needed for them.
They're purely syntax sugar.
2014-01-19 13:01:51 -08:00
Bob Nystrom
e8791b6bab
Don't inherit metaclasses.
...
Also disallow super() in static methods. It won't do anything
useful (it always just delegates to Class) anyway.
2014-01-17 17:29:10 -08:00
Bob Nystrom
e493ac7cf4
Check for number of field overflow.
2014-01-15 07:59:10 -08:00
Bob Nystrom
eb1c0284dd
Handle references to fields with inheritance in closures.
2014-01-15 07:03:24 -08:00
Bob Nystrom
4b8b676ffe
Handle errors with fiber usage.
2014-01-13 06:58:27 -08:00
Bob Nystrom
8e8bb4b9b9
Allow returns without an explicit value.
2014-01-12 19:37:11 -08:00
Bob Nystrom
f3a1f7e677
Fibers!
...
Still have some edge cases to implement but the basics are in
place and working now.
2014-01-12 11:02:07 -08:00
Bob Nystrom
a8b51f6c8b
Fill in some more mathematical functions.
2014-01-08 07:47:14 -08:00
Bob Nystrom
3be059a137
Fix scoping and break statements.
...
Variables declared in the loop were not properly disposed of
when you broke out of the loop.
2014-01-06 08:01:04 -08:00
Bob Nystrom
b979272305
Clean up text handling a bit:
...
- Rename IO.write -> IO.print.
- Make IO.write not print a newline.
- Support \u Unicode escapes in strings.
2014-01-05 12:27:12 -08:00
Bob Nystrom
870f3b8b93
Allow more than 256 methods and constants.
...
Class symbol tables now grow on demand, and the relevant
instructions take 16-bit arguments. There's a small perf hit
for this, but only a few percent, which is good.
2014-01-04 11:08:31 -08:00
Bob Nystrom
058c2606b0
Better argument validation for core methods.
2014-01-03 10:47:26 -08:00
Bob Nystrom
a89386b4e8
Better argument validation for some list methods.
2014-01-02 07:32:00 -08:00
Bob Nystrom
48db3a9620
Start adding support for runtime errors:
...
- Primitives can now signal an error.
- An error prints a callstack and ends the current (and right
now only) fiber.
- Arithmetic operators error if the operand is not a number.
- Real error for method not found.
- Associate source file name, and method names with functions.
- Debug line number info for functions.
Unfortunately, this regresses perf on fib about 15%, mostly
because of the better checking in arithmetic ops.
There's still a bunch of clean up to do, but this is a big step
in the right direction.
2014-01-01 13:25:24 -08:00
Bob Nystrom
c8fe27d6c4
Allow empty blocks.
2013-12-29 10:46:21 -08:00
Bob Nystrom
a8c725ea3f
Use growable buffers for bytecode and strings.
...
Ensures the compiler can handle long chunks of code and strings.
2013-12-27 07:22:43 -08:00
Bob Nystrom
507e89d3b3
Range operators!
...
Added ".." and "..." infix operators. Num implements them to
return Range objects. Those in turn implement the iterator
protocol, so now numeric for loops are easy:
for (i in 1..10) { ... }
I also cleaned up the Wren benchmarks to use this.
In the process, I discovered the method_call benchmark really
just showed loop peformance, so I unrolled the loops in all of
the languages to stress method calls.
2013-12-25 15:01:45 -08:00
Bob Nystrom
e6e7b2594c
For loops!
2013-12-24 21:04:11 -08:00
Bob Nystrom
1e0401bfc1
Allow statement bodies for flow control.
...
This means this works now:
if (foo) return bar
2013-12-24 10:27:48 -08:00
Bob Nystrom
8c85232b90
Break statements.
2013-12-24 10:15:50 -08:00
Bob Nystrom
5a2fde0c2c
Collapse duplicate constants and check for overflow.
2013-12-23 15:08:47 -08:00
Bob Nystrom
c8cb0be816
Better handling for lexing errors.
2013-12-23 14:51:06 -08:00
Bob Nystrom
1503e74233
Get rid of unused DUP instruction.
2013-12-23 11:37:47 -08:00
Bob Nystrom
9235a7e38f
Fields in closures.
2013-12-23 11:17:40 -08:00
Bob Nystrom
ad1fcf66bc
Superclass calls in closures.
2013-12-22 20:46:12 -08:00
Bob Nystrom
3c8b4c009f
Allow variables without initializers.
2013-12-22 18:47:58 -08:00
Bob Nystrom
7868287f89
Make IO.write() call toString on its argument.
2013-12-22 11:50:00 -08:00
Bob Nystrom
2ec01c558f
Clean up the root of the class/metaclass hierarchy.
2013-12-21 20:44:37 -08:00
Bob Nystrom
6c3aa85228
Make IO a static class instead of a singleton.
2013-12-21 19:25:09 -08:00
Bob Nystrom
24a6f4cd8c
Closing over "this".
2013-12-21 15:55:08 -08:00
Bob Nystrom
76ac818eaf
Subscript setters.
2013-12-21 09:37:59 -08:00
Bob Nystrom
f2b036420d
Fix a bunch of test TODOs.
...
- Added a bunch of tests.
- Removed some TODOs for stuff that's already done.
- Made list literals handle newlines better.
2013-12-20 12:42:11 -08:00
Bob Nystrom
e83d0bb360
Setters!
2013-12-20 07:05:31 -08:00
Bob Nystrom
f9099791a1
Add another test for constructor syntax.
2013-12-19 09:10:45 -08:00
Bob Nystrom
4d67f2270a
Use more conventional syntax for constructors.
...
They are now invoked like "new Foo".
Also, superclass constructors are now much less semantically
and syntactically weird. Since the instance is created before
any constructor is called, there's no point in time where the
instance isn't there.
2013-12-19 07:02:27 -08:00
Bob Nystrom
e7cf8ffe2e
Make method_call benchmark use inheritance.
...
This also fixes a bug where constructors weren't being bound
correctly, and eliminates some unneeded instructions when
compiling ifs.
I also tweaked the other method_call languages to match Wren's.
Since Wren needs to do a super call to get to the parent _count,
the other languages do now too.
This is nice too because it means we're benchmarking super
calls.
2013-12-18 07:37:41 -08:00
Bob Nystrom
271fcec81b
Start getting superclass constructors working.
...
This also means the metaclass inheritance hierarchy parallels
the regular inheritance chain so that the subclass can find
the superclass constructor.
2013-12-17 09:39:05 -08:00
Bob Nystrom
70e548657e
Don't allow "super" outside of methods.
2013-12-15 22:08:40 -08:00
Bob Nystrom
f5e4f95069
Write some more scope edge case tests.
2013-12-14 16:36:19 -08:00
Bob Nystrom
7fe60499db
Get rid of my name from TODOs. Anyone can do them.
2013-12-14 15:28:18 -08:00
Bob Nystrom
d54bca3067
Get basic superclass method calls working.
2013-12-13 08:37:49 -08:00
Bob Nystrom
510e3fc383
Add test for default constructor.
2013-12-10 21:58:02 -08:00
Bob Nystrom
c1cfe1b9f6
Handle inherited fields correctly.
2013-12-10 16:13:25 -08:00
Bob Nystrom
3f24515496
Don't allow method names to overflow.
2013-12-06 20:09:43 -08:00
Bob Nystrom
6a0d550562
Bitwise ~ operator.
2013-12-04 22:09:31 -08:00
Bob Nystrom
c91fcd12cc
Treat ";" like newlines.
2013-12-04 19:12:21 -08:00
Bob Nystrom
157944aa27
Get closures working!
...
In the process, I had to change the grammar. There is now a strong
separation between statements and expressions. The code was just wrong
before when it popped locals at the end of a block scope because there
could be temporaries on the stack if the block was in expression
position. This fixes that.
Still need to implement closing over `this`.
2013-12-04 07:43:50 -08:00
Bob Nystrom
60c97b5c2f
Make sure we don't go over the maximum number of locals.
2013-11-30 18:51:27 -08:00
Bob Nystrom
88852960ca
Handle local variable shadowing.
2013-11-30 18:28:01 -08:00
Bob Nystrom
b390bdf604
Clean up constructor tests.
2013-11-29 15:21:36 -08:00
Bob Nystrom
325bb281a5
Allow 16 arguments, and handle going over that correctly.
2013-11-29 15:08:27 -08:00
Bob Nystrom
5f1d5cfa85
Do not allow fields outside of classes.
2013-11-29 10:53:56 -08:00
Bob Nystrom
1bfa252a70
List.removeAt().
2013-11-27 10:20:32 -08:00
Bob Nystrom
f8ded27376
List.clear and List.insert().
2013-11-26 23:11:11 -08:00
Bob Nystrom
56449cdbef
Reorganize tests.
2013-11-26 22:52:00 -08:00
Bob Nystrom
897a396599
List.add() method.
2013-11-26 18:02:10 -08:00
Bob Nystrom
eaeec01dc6
Get inheritance and core classes more correctly wired up.
2013-11-26 07:52:37 -08:00
Bob Nystrom
c99f4d7834
Subscript operator for lists.
2013-11-24 19:08:46 -08:00
Bob Nystrom
7a343f2ecf
List literals.
2013-11-24 13:38:31 -08:00
Bob Nystrom
f9b008e283
Subscript operators!
2013-11-24 10:45:07 -08:00
Bob Nystrom
e3e1f7f3d4
Start working on string escapes.
2013-11-23 21:00:47 -08:00
Bob Nystrom
a5bbe81280
Start to get instance fields working.
2013-11-23 14:55:05 -08:00