Commit Graph

348 Commits

Author SHA1 Message Date
10f149f359 Add "def" syntax sugar for named function definitions.
This is technically redundant but it makes functional/procedural code
look a *lot* more natural.
2015-12-01 08:05:46 -08:00
c3e2f17758 Allow infix () and {} to call "call" on the left-hand side.
- Allow this for both argument lists and block arguments.

- Tweak precedence to make "." higher than infix "{}" to avoid a
  class body being parsed as the superclass clause's block argument.

- Convert all uses of ".call" to use this. (There was not a single
  case in the repo that ran into the getter ambiguity.)
2015-12-01 07:49:04 -08:00
9df6aa2f8a Remove support for implicit self sends and convert everything to '@'.
This fixes the nasty case where "foo(bar)" is context-sensitive, and
generally simplifies the compiler a lot since there is a clear
distinction between lexical and dynamic scope.

Also:

- Remove the special handling of capitalized names since all names are
  lexical now.
- Allow methods to close over local variables in enclosing functions.
- Allow implicit definition of all lexical names.
2015-11-30 22:46:11 -08:00
2e425ae840 Allow "@method()" syntax for explicit self sends, like CoffeeScript. 2015-11-30 21:44:12 -08:00
37b70db1b0 Make delta_blue more idiomatic Wren. 2015-11-30 20:58:08 -08:00
78655c68b0 Simple string interpolation.
This allows "%(...)" inside a string literal to interpolate the
stringified result of an expression.

It doesn't support custom interpolators or format strings, but we can
consider extending that later.
2015-11-11 07:55:48 -08:00
7ae9888c4f It turns out "is" is just a normal overridable operator. Who knew? 2015-11-07 13:00:24 -08:00
2ff8acbe1a Tweak a few things in the new GC.
- Make sure it handles an empty gray set.
- Make sure growing the gray stack doesn't itself trigger a GC.
- Make sure it works when stress testing is enabled.
- Ensure the tests kick off a GC.
2015-10-29 07:38:09 -07:00
e3c9324dd9 Merge branch 'master' into iwillspeak-iterative-gc 2015-10-28 07:46:06 -07:00
e985e6fe07 Make sure binary_trees_gc actually stresses GC. 2015-10-28 07:45:52 -07:00
cea71c2fe4 Remove Recursive Mark from GC
The previous GC implementation used a recursive mark method. This can
result in stack overflows when attempting to mark deeply nested objects.

This commit replaces the recursive approach with an iteritive one,
moving the state stack from the C call stack to the `WrenVM` structure.

As objects are 'grayed' they are pushed onto the VM's gray stack. When
we have grayed all of the root objects we iterate until the stack is
empty graying any obejcts which haven't been marked as dark before. At
the end of the process we clean up all unmarked objects as before.

This commit also adds a few new tests which check garbage collection by
allocating some new deeply nested objects and triggering the GC a few
times in the process.
2015-10-25 09:02:57 +00:00
b365c07d7a Add a benchmark that explicitly invokes the GC. 2015-10-24 11:00:17 -07:00
720c03cf49 Add System.gc(). 2015-10-24 10:56:27 -07:00
3ca480cbf4 Merge branch 'master' of https://github.com/iwillspeak/wren into iwillspeak-master 2015-10-17 20:07:52 -07:00
8436ce1934 Add a random module. 2015-10-17 11:03:15 -07:00
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
d431c2eaa8 Start sketching in support for reading from stdin. 2015-10-16 21:05:24 -07:00
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
8980d34ee5 Only close an upvalue for a local if there actually is one for it. 2015-10-08 08:06:29 -07:00
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
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
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
bacbd85543 Add .isInfinity and .isInteger to Num. 2015-09-30 08:41:43 -07:00
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
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
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
8ef4ea6186 Allow super calls in static methods. 2015-09-19 15:19:41 -07:00
dc527c8d86 Add "io" module with beginnings of a File class. 2015-09-16 07:34:49 -07:00
251752fcfb Make join() require parentheses without a separator. 2015-09-16 07:15:48 -07:00
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