Commit Graph
401 Commits
Author SHA1 Message Date
Bob Nystrom b8675e2d91 Merge branch 'get_slot_list_values' of https://github.com/dradtke/wren into dradtke-get_slot_list_values 2016-07-28 07:53:19 -07:00
Bob Nystrom 5418e4f8f3 Add MapEntry to core to let maps be directly iterated.
Fix #372.
2016-07-06 07:17:07 -07:00
Bob Nystrom 4e94195f26 Properly handle tombstones when inserting items into a map.
Previously, you could get into a state where a key was present in the
map, but after a tombstone in the probe sequence. If they key was added
again, it stopped at the first tombstone and added it there, resulting
in the key being in the map multiple times.

Fix #373.
2016-06-27 07:14:52 -07:00
Bob Nystrom f47e128978 Tab-completion in REPL based on module variables. 2016-06-09 19:16:41 -07:00
Bob Nystrom 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
Bob Nystrom 59e9eb127e Add wrenAbortFiber().
Thanks, @underscorediscovery!
2016-06-09 19:14:21 -07:00
Bob Nystrom 2b0878ec6d Platform.isWindows. 2016-05-21 12:53:21 -07:00
Bob Nystrom 6002cc4d65 Add Stdin.isTerminal. 2016-05-21 12:51:11 -07:00
Bob Nystrom 06731f66d4 Add a Platform class.
- Rename the "process" module to "os".
- Add Platform to it.
- Static "name" method.
- Static "isPosix" method.
- Docs and tests!
2016-05-21 12:44:17 -07:00
Bob Nystrom 0a060a9678 WrenValue -> WrenHandle. 2016-05-20 20:55:28 -07:00
Bob Nystrom 5d98d20175 Add Stdin.isRaw. 2016-05-20 15:19:18 -07:00
Bob Nystrom 500dd41ccd Add Stdin.readByte(). 2016-05-20 11:50:14 -07:00
Damien Radtke cf258b9074 Add support for retrieving list values from a slot
This PR adds support for retrieving list information from a slot. Rather
than take the whole list, two different methods are provided for
retrieving a) the length of the list, and b) a specific value in the
list.
2016-05-19 14:11:48 -05:00
Bob Nystrom 2ce5913501 Correctly count subscript parameters in wrenMakeCallHandle().
Fixes #351.
2016-05-04 06:29:44 -07:00
Bob Nystrom 694186810b Test that multiple closures of the same code are unequal. 2016-03-26 14:22:38 -07:00
Bob Nystrom a6739819b2 Report undefined variable errors on the line where they are used.
This also more importantly ensures the error message for one has a
bounded length even if the variable name is pathologically long.
2016-03-16 08:00:28 -07:00
Bob Nystrom 38699e3a81 Rearrange the code a bit for duplicate method detections. 2016-03-15 07:15:55 -07:00
Stephen Belanger 6dfbea1ea4 Don't use generic function for finding method duplicates and add tests 2016-03-12 19:14:19 -08:00
Bob Nystrom 9fda7cb526 Unify Fiber.try() with the other methods to execute fibers. 2016-03-03 17:00:33 -08:00
Bob Nystrom 84bcb5801c Add a test for creating a VM without a config. 2016-03-03 14:31:47 -08:00
Bob Nystrom 1e4b9e5175 File.realPath().
Not tested yet, because we can't create symlinks from Wren and I don't
want to check symlinks into the repo, but it seems to do the right
thing.
2016-02-27 15:53:02 -08:00
Bob Nystrom d46dfc9500 Allow "*" on lists and strings to repeat them.
This is not implemented on Sequence because, at least for lists and
strings, I think users expect an eager result. Multiplying a string
should give you back a string, not a lazy sequence of repeated
characters.

This also mirrors "+" on strings and lists, which is eager. I like the
idea of having a general guideline that operators are eager.

Repetition is useful for arbitrary sequences, but for that maybe we
should add a "repeat()" method.
2016-02-24 07:48:03 -08:00
Bob Nystrom 60162575ee More file system checking functions:
- Stat#isFile
- Stat#isDirectory
- Directory.exists()
- File.exists()
2016-02-21 12:23:33 -08:00
Bob Nystrom b331915259 Add stat instance method to File. 2016-02-21 10:18:45 -08:00
Bob Nystrom 8e90e3577b More file IO!
Can now create, delete, and write to files.
2016-02-20 09:23:42 -08:00
Bob Nystrom ef3aa07d84 Add API to get the type of object in a slot. 2016-02-19 07:18:00 -08:00
Bob Nystrom fa0a507b48 Error on jump distance overflow. 2016-02-19 06:57:38 -08:00
Bob Nystrom b8e85c83a8 Fix test and add skynet example. 2016-02-14 22:21:50 -08:00
Bob Nystrom 8b36e2f00b Add sample(_) and sample(_,_) to Random. 2016-02-09 07:24:45 -08:00
Bob Nystrom d4a4b26203 Add Random.shuffle(). 2016-02-07 10:38:39 -08:00
Bob Nystrom 79558d95e5 Move File.stat() -> Stat.path().
Thanks, Michel!
2016-02-07 09:56:16 -08:00
Bob Nystrom fde6cfc142 Generate wrenAllocateForeign() to match the other setSlot methods.
Thanks, Michel!
2016-01-24 09:25:04 -08:00
Bob Nystrom 71e2458a6c Add API for accessing command-line arguments.
- Add process module with Process class.
- Add "arguments" and "allArguments" methods.
- Docs for same.
- Support passing additional arguments to command line.
- Add "--help" support to command line.
2016-01-22 07:57:26 -08:00
Bob Nystrom f9d1e9954a Make File.stat() directory test less file system sensitive. 2016-01-05 07:32:51 -08:00
Bob Nystrom 94208647ab Test File.stat() on a directory. 2016-01-01 10:05:31 -08:00
Bob Nystrom 5cd8a06fa0 File.stat(). 2016-01-01 09:58:44 -08:00
Bob Nystrom b054526df8 Add an optional offset to File.readBytes(). 2015-12-30 08:13:19 -08:00
Bob Nystrom 2c31985e54 Make Directory.list() create and return a list from C. 2015-12-29 08:37:47 -08:00
Bob Nystrom e0ac88c22a Revamp wrenCall to work with slots.
Now, you call wrenEnsureSlots() and then wrenSetSlot___() to set up the
receiver and arguments before the call. Then wrenCall() is passed a
handle to the stub function that makes the call. After that, you can
get the result using wrenGetSlot___().

This is a little more verbose to use, but it's more flexible, simpler,
and much faster in the VM. The call benchmark is 185% of the previous
speed.
2015-12-29 07:58:47 -08:00
Bob Nystrom ed6fad6153 Get rid of fiber for finalizers.
Instead, finalizers just get access to the foreign object's raw bytes.
This is deliberately limiting, since it discourages the user from
interacting with the VM in the middle of a GC.
2015-12-28 08:06:29 -08:00
Bob Nystrom 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
Bob Nystrom 9512ce74c3 Merge branch 'master' into api
# Conflicts:
#	src/module/io.c
2015-12-26 20:42:53 -08:00
Bob Nystrom 1d16e85a85 Add an API to load a top-level variable into a slot. 2015-12-26 10:53:14 -08:00
Bob Nystrom 0ac793d4f8 Add Directory.list() to io. 2015-12-24 10:12:12 -08:00
Bob Nystrom 15043b897f Add a benchmark for wrenCall(). 2015-12-23 17:29:53 -08:00
Bob Nystrom b7e62926ab Merge branch 'master' into api 2015-12-23 09:22:49 -08:00
Bob Nystrom 1ebc711c30 Allow call and unary expressions as map keys. 2015-12-22 16:00:50 -08:00
Bob Nystrom 6f37d379f4 Add C API functions for working with lists:
- wrenEnsureSlots()
  Lets you go the foreign slot stack to make room for a temporary work
  area.

- wrenSetSlotNewList()
  Creates a new empty list and stores it in a slot.

- wrenInsertInList()
  Takes a value from one slot and inserts it into the list in another.

Still need more functions like getting elements from a list, removing,
etc. but this at least lets you create, populate, and return lists from
foreign methods.
2015-12-16 16:28:26 -08:00
Bob Nystrom 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
Bob Nystrom 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