Commit Graph

14 Commits

Author SHA1 Message Date
33cf8f7b31 Fall back to a simpler REPL if it seems like ANSI escapes won't work. 2016-06-09 19:16:41 -07:00
f47e128978 Tab-completion in REPL based on module variables. 2016-06-09 19:16:41 -07:00
bc7f1de758 Execute input in the REPL.
Guesses whether the input is an expression or statement and handles it
appropriately. Finally, after over a year, the Wren REPL automatically
prints "3" if you type in "1 + 2". \o/
2016-06-09 19:16:41 -07:00
6dc4286ffa Always wrap functions in closures.
This has a couple of pros:

- It simplifies some code that used to have to check whether a called
  thing is a bare function or a closure.
- It's faster because we don't need to do the above checks every time
  something is called.
- It lets us more precisely type some fields that used to be Obj*
  because they could hold an ObjClosure* or ObjFn*.

The cost is that we allocate a closure every time a function is
declared, even if it has no upvalues. Since functions are called way
more often than they are declared, this is still a net win.

On my Mac laptop:

api_call - wren            0.06s 0.0020 104.73%
api_foreign_method - wren  0.32s 0.0040 101.89%
binary_trees - wren        0.23s 0.0057  98.82%
binary_trees_gc - wren     0.79s 0.0170  98.46%
delta_blue - wren          0.13s 0.0031 101.36%
fib - wren                 0.23s 0.0038 103.15%
fibers - wren              0.04s 0.0017  98.97%
for - wren                 0.08s 0.0017 107.81%
method_call - wren         0.12s 0.0024  98.60%
map_numeric - wren         0.31s 0.0052 103.93%
map_string - wren          0.11s 0.0113  97.97%
string_equals - wren       0.20s 0.0023 107.75%
2016-03-26 14:00:17 -07:00
a5f95b90e9 Lazy load optional libraries and let the host override them. 2016-03-17 07:49:43 -07:00
8b36e2f00b Add sample(_) and sample(_,_) to Random. 2016-02-09 07:24:45 -08:00
d4a4b26203 Add Random.shuffle(). 2016-02-07 10:38:39 -08:00
fde6cfc142 Generate wrenAllocateForeign() to match the other setSlot methods.
Thanks, Michel!
2016-01-24 09:25:04 -08:00
a447b66380 Make slots available to the API outside of foreign methods.
At any point in time, the user can call wrenEnsureSlots() which will
implicitly create a fiber and point to its stack if needed.
2015-12-28 07:49:47 -08:00
7fcdcf2f1a wrenReturn___() -> wrenSlotSet___().
This turns those functions into general-purpose functions for writing
raw C values into slots on the foreign call stack.

Writing a return just means writing a value to slot 0.
2015-12-16 13:00:13 -08:00
4b3c818ec5 Start moving embedding API towards "slot" register-API.
- wrenGetArgumentCount() -> wrenGetSlotCount()
- wrenGetArgument___() -> wrenGetSlot___()

Also, the get functions assert that the value is the right type instead
of checking at runtime. This puts the onus on the caller to be safe,
but maximizes performance.
2015-12-16 10:22:42 -08:00
55beda3ea9 Simplify the foreign call preamble a bit.
We don't need to store the number of arguments since we can calculate
it from the start and top of the stack.
2015-12-15 17:10:02 -08:00
902289d7dd Document the "random" module. 2015-11-09 07:37:06 -08:00
f145662158 "Auxiliary" -> "optional".
Fixes #309.
2015-10-24 09:23:25 -07:00