Commit Graph
425 Commits
Author SHA1 Message Date
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 5fb2d5af71 Use flexible array for upvalues in closure. 2013-12-15 22:02:22 -08:00
Bob Nystrom 9e67cd3220 Use stdbool.h and bool for booleans. 2013-12-14 23:41:23 -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 5c807c0ec5 Track memory during deallocation correctly.
It used to subtract the number of bytes during deallocation, but
that required knowing the size of an object at free time. That
isn't always available. The old code could read a freed object
while doing this. Bad!

Instead, this tracks how much memory is still being used by
marked objects. It's correct, and is also a bit less code and
faster.
2013-12-14 14:17:16 -08:00
Bob Nystrom 3fd7fa56fb Inline wrenObjectToValue().
Seems to give a slight speed bump. Inlining the wrenIs___
functions doesn't seem to help (may make it a bit worse.)
2013-12-14 11:34:49 -08:00
Bob Nystrom 088b1be98c Clean up config #defines. 2013-12-14 11:06:54 -08:00
Bob Nystrom 165cf29db0 Special "constructor methods" -> "new" instruction.
This simplifies the call instruction a bit (and is overall
less code).
2013-12-13 11:32:47 -08:00
Bob Nystrom d54bca3067 Get basic superclass method calls working. 2013-12-13 08:37:49 -08:00
Bob Nystrom 4957728893 Move OP_CLOSURE and OP_LIST down.
Since they're less frequently used, pushing them down speeds
things up a little bit.
2013-12-13 06:47:34 -08:00
Bob Nystrom 8e71660ce6 Reorder the method types.
Seems to slightly improve perf.
2013-12-12 07:39:27 -08:00
Bob Nystrom 4ba5c38bbf Generate default constructors at compile time.
Also re-ordered a few of the cases in the interpret loop. 
Removing a bit of code from CODE_CLASS and CODE_CALL triggered
some branch alignment issues which had a negative perf impact.
The new ordering seems to cancel that out.
2013-12-12 07:34:16 -08:00
Bob Nystrom e191424a70 Make "super" a reserved word. 2013-12-11 08:02:17 -08:00
Bob Nystrom 6e16df08f0 Add note about default constructor. 2013-12-11 08:00:25 -08:00
Bob Nystrom c1cfe1b9f6 Handle inherited fields correctly. 2013-12-10 16:13:25 -08:00
Bob Nystrom 42b04c6c90 Fix bug in loops.
It was still popping the stack for the body even though loop
bodies are statements now.
2013-12-07 18:47:40 -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 c14b115c02 Use char* instead of offsets for tokens.
Simplifies a bunch of code that works with token strings.
2013-12-01 15:22:24 -08:00
Bob Nystrom e4043d69b4 Unify code for ending compiler.
There's now a single code path for the end of a chunk of bytecode, so
we can eventually put code there for capturing closures.
2013-12-01 14:59:56 -08:00
Bob Nystrom 19811143a0 Always use provided allocator for allocation. 2013-12-01 10:22:32 -08:00
Bob Nystrom d2e82d8967 Clean up parsing a bit. 2013-12-01 00:04:46 -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 edb9032052 Get binary_trees benchmark working.
Wren is actually doing well in it:

wren      mean: 1.9441 median: 1.9428 std_dev: 0.0260
lua       mean: 3.5992 median: 3.6033 std_dev: 0.0156
python    mean: 3.6667 median: 3.7097 std_dev: 0.1340
ruby      mean: 1.3941 median: 1.3914 std_dev: 0.0091
2013-11-29 16:19:13 -08:00
Bob Nystrom ce89dd9c2f Fix compiling constructors. 2013-11-29 16:17:43 -08:00
Bob Nystrom 8c9ce024ee Move debug code into separate module. 2013-11-29 16:17:33 -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 1b353e9380 Make pinned list a linked list instead of hardcoded array. 2013-11-29 09:18:13 -08:00
Bob Nystrom 715fecdc7c Rename files and add some docs. 2013-11-28 08:11:50 -08:00
Bob Nystrom 9d9f9c11ca Clean up "primitive" code. 2013-11-28 08:00:55 -08:00
Bob Nystrom 1fc9fe131d Clean up value code. 2013-11-27 20:00:03 -08:00
Bob Nystrom c2f4345af4 Remove stale TODO. 2013-11-27 11:34:35 -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 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 af6b73208c Start defining actual API for embedding Wren. 2013-11-25 07:47:02 -08:00
Bob Nystrom f9b2aed4dd Unify to a single reallocation function. 2013-11-25 07:14:51 -08:00
Bob Nystrom ece3f3b83b Add optional support for computed gotos.
In my benchmark, this gives like a 5% speed boost. But I'm not sure
it's taking full advantage of it. The XCode project is using LLVM,
which has support for it, but may not optimize it as much as GCC.

There are also some GCC flags I may need to set (-fno-gcse?) to get the
best perf on GCC. Needs more investigation.
2013-11-24 21:48:47 -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 acf9cc024f Remove some unneeded casts. 2013-11-23 17:35:11 -08:00
Bob Nystrom a5bbe81280 Start to get instance fields working. 2013-11-23 14:55:05 -08:00