Commit Graph
100 Commits
Author SHA1 Message Date
Bob Nystrom ee04f1cf9c Correctly check bounds for method table. 2014-02-08 20:25:33 -08:00
Bob Nystrom e9ee4eb147 Add FFI support for returning strings and null. 2014-02-05 06:30:20 -08:00
Bob Nystrom 7726ee5131 Handle extra and missing arguments to fn.call. 2014-02-04 09:34:05 -08:00
Bob Nystrom 8d316396e1 Move clock into IO. 2014-02-04 08:49:16 -08:00
Bob Nystrom 4e10445952 Work on class docs a bit. 2014-02-04 08:45:08 -08:00
Bob Nystrom 36df70dba1 Move IO into a separate module. 2014-02-04 08:44:59 -08:00
Bob Nystrom ba06a4fd8a Define error type enum. 2014-02-03 06:51:44 -08:00
Bob Nystrom ac7cb594f4 Handle invalid string literals. 2014-02-02 10:31:46 -08:00
Bob Nystrom 7e850637f9 Allow passing a suite to make test. 2014-02-02 10:30:58 -08:00
Bob Nystrom b576d546e9 Add DROP() macro for popping and discarding the result.
Avoids unused-value warnings where the result of POP() isn’t used.
2014-02-01 10:44:47 -08:00
Bob Nystrom 0b641939d4 Merge pull request #10 from gaodayue/fixbuild
hack unused-value warning on POP() to pass build
2014-02-01 10:42:09 -08:00
Bob Nystrom 4606d80a61 Tweak doc generation script a bit. 2014-01-31 20:55:37 -08:00
Bob Nystrom 498e163580 Merge pull request #9 from zeckalpha/master
Recopy css if it has been modified.
2014-01-31 20:51:30 -08:00
Bob Nystrom 3bc79af83a Docs for lists. 2014-01-31 17:51:09 -08:00
Bob Nystrom 25a6565f9f Merge pull request #7 from zeckalpha/master
#!/usr/bin/env python
2014-01-31 16:40:17 -08:00
Bob Nystrom 66f0b57bf3 Allow ranges in list subscript operator. 2014-01-30 09:12:44 -08:00
Bob Nystrom f2aeb30b31 Hack on the docs a bit. 2014-01-30 06:51:52 -08:00
Bob Nystrom a5e65faf0d Put the class name on the stack instead of as an arg. 2014-01-29 07:47:09 -08:00
Bob Nystrom 5c2cf641ae Make classes know their name. 2014-01-28 15:31:11 -08:00
Bob Nystrom 9739bc7b30 Get rid of separate CODE_SUBCLASS instruction.
Just pushes null to indicate "inherits from Object". Unifies a
bit of code.
2014-01-26 17:25:38 -08:00
Bob Nystrom 27f458de8e Fix nasty bug in patching loop exits. 2014-01-26 17:24:59 -08:00
Bob Nystrom 96d728cc5d Reorganize makefile and scripts. 2014-01-23 23:29:50 -08:00
Bob Nystrom a4162a2eb3 Fix #6. Handle Ctrl-D in REPL. 2014-01-21 15:41:07 -08:00
Bob Nystrom 74d045540b Merge branch 'master' of git://github.com/zeckalpha/wren into zeckalpha-master 2014-01-21 15:29:43 -08:00
Bob Nystrom b4915e70e3 Remove unneeded increment. 2014-01-21 08:23:30 -08:00
Bob Nystrom ac8fe926dc Moving marking in wren_value.c. 2014-01-21 08:20:00 -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 7b1b39bd2c Clean up runtime error string handling. 2014-01-20 22:55:11 -08:00
Bob Nystrom 95d239cd21 Lots of work on docs. 2014-01-20 21:44:51 -08:00
Bob Nystrom 90d1ed6aa6 Make null falsey. 2014-01-20 18:12:55 -08:00
Bob Nystrom 8c5ef693d0 Remove some stale TODOs. 2014-01-20 13:57:44 -08:00
Bob Nystrom 232eb9fab5 Clean up a bit of VM code. 2014-01-20 13:54:14 -08:00
Bob Nystrom ce2b45de53 Use for loop in binary_trees benchmark. 2014-01-20 13:46:37 -08:00
Bob Nystrom d16e68b208 Use for loop in List.toString. 2014-01-20 13:43:22 -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 d40d04f0c5 Include numeric loop in for benchmark. 2014-01-20 08:43:10 -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 2a68c8ee1d Reorganize code for tracking enclosing class. 2014-01-18 14:03:52 -08:00
Bob Nystrom 8027143381 Static field tokens. 2014-01-18 09:33:18 -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 1d808cf49c Include function name in assertion message. 2014-01-17 17:21:38 -08:00
Bob Nystrom f163afb865 Don’t allow fields in static methods. 2014-01-16 07:09:43 -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 9e30fa67ed Fix a few typos in the docs. 2014-01-13 20:23:11 -08:00
Bob Nystrom 7580c05013 Merge pull request #1 from b01dface/master
Minor typos and documentation updates.
2014-01-13 20:22:10 -08:00
Bob Nystrom 788762c970 Add LuaJIT to benchmark. 2014-01-13 07:29:47 -08:00
Bob Nystrom 4b8b676ffe Handle errors with fiber usage. 2014-01-13 06:58:27 -08:00
Bob Nystrom 52a6d6d69c Free GC objects when VM is freed. 2014-01-13 06:48:53 -08:00
Bob Nystrom 8e8bb4b9b9 Allow returns without an explicit value. 2014-01-12 19:37:11 -08:00
Bob Nystrom cf623844c4 Other escape codes. 2014-01-12 19:24:30 -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 86d93296ab Fix doc. 2014-01-12 10:58:13 -08:00
Bob Nystrom a8b51f6c8b Fill in some more mathematical functions. 2014-01-08 07:47:14 -08:00
Bob Nystrom 9645ddcb26 Add a little ASCII art Mandelbrot example. 2014-01-07 23:04:30 -08:00
Bob Nystrom 8f316f39f8 Support longer jumps. 2014-01-07 23:03:38 -08:00
Bob Nystrom 074c016c89 Num.floor. 2014-01-07 23:03:25 -08:00
Bob Nystrom e64d8ace9a Ensure upvalue value is initialized.
Avoids a crash if a GC happens before the upvalue is closed.
2014-01-07 23:03:15 -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 90a769b6d1 Correctly terminate debug function name. 2014-01-06 07:54:00 -08:00
Bob Nystrom 46e1e7f069 Make string buffer for converting number to string large enough. 2014-01-06 07:53:41 -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 f82a034b57 Add time to GC tracing. 2014-01-03 13:17:14 -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 a0c32f2e6e Clean up compiler initialization a bit. 2014-01-02 07:31:31 -08:00
Bob Nystrom e46b4b30b9 Make Buffer "generic".
This lets us make a growable line-number buffer.
2014-01-01 22:23:03 -08:00
Bob Nystrom a6fd0b2dd2 Move SymbolTable to wren_utils. 2014-01-01 20:57:58 -08:00
Bob Nystrom b750ece08b Move object freeing over to wren_value.
That's where allocation is, so it makes sense.
2014-01-01 13:31:19 -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 45456733aa Fix a few GC bugs.
Adding a to a symbol table can trigger a GC, so we need to make
sure we don't do that while sitting on an unpinned object.
2013-12-30 07:30:50 -08:00
Bob Nystrom c8fe27d6c4 Allow empty blocks. 2013-12-29 10:46:21 -08:00
Bob Nystrom a9323376ec "native" -> "foreign". 2013-12-29 10:14:38 -08:00
Bob Nystrom 63d1255566 Start sketching in the FFI. 2013-12-29 10:06:35 -08:00
Bob Nystrom 667d393fbb Write a bunch of docs. 2013-12-28 09:37:41 -08:00
Bob Nystrom afdcafcecb Remove explicit calls to free() and malloc(). 2013-12-27 09:07:35 -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 3506a39e27 Pass in all data when creating function. 2013-12-26 17:28:33 -08:00
Bob Nystrom 24686eb4be First step towards making FnObjs smarter about size.
Currently, they have a hardcoded number of constants and 
bytecodes. That wastes memory in most cases and fails 
catastrophically when there is too much bytecode.

To fix this, we should use growable buffers for both during
compilation and then only create the FnObj when done compiling.

This moves a bunch of stuff around and gets it to the point
where functions are created at the end of compilation. It
doesn't yet size functions appropriately, but all tests are
passing, so this is a good checkpoint.
2013-12-26 16:58:03 -08:00
Bob Nystrom 350c0194b6 "unsigned char" -> "uint8_t". 2013-12-25 16:31:30 -08:00
Bob Nystrom e62bccd7f2 Inline the bytecode array in ObjFn. 2013-12-25 16:19:35 -08:00
Bob Nystrom 8c4a58a0a3 Make CallFrame and Method use Obj* for functions.
There's no point in packing it in a Value since it will always
be an ObjFn or ObjClosure. Leaving it an Obj* is a bit faster.

Also fixed a bug where it was freeing the closure's flexible
array of upvalues.
2013-12-25 16:12:07 -08:00
Bob Nystrom ba0f39a5e0 Tweak README. 2013-12-25 15:03:17 -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 2b65e47747 Use getNumArguments() in method bind. 2013-12-24 22:10:30 -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 a30a5daa29 Clean out a few TODOs. 2013-12-23 15:38:00 -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 c0169896e6 Get rid of ResolvedName. 2013-12-22 20:53:35 -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 034fec6eaa Make fibers real objects. 2013-12-22 14:31:33 -08:00