Commit Graph
409 Commits
Author SHA1 Message Date
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