1
0
forked from Mirror/wren
Commit Graph

505 Commits

Author SHA1 Message Date
60a0353a27 Tweak list C API:
- Rename "size" -> "count" to be consistent with other usage.
- Remove "Slot" from the function names, since that's implicit.
- Make the getListElement() just move the element to another slot. This
  matches other APIs where we distinguish accessing a value and
  converting it to some specific type.
2016-07-28 08:06:36 -07:00
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
244faa5700 renamed filler constructor in list to match issue 2016-07-17 12:24:19 +10:00
45d9794476 added extra arguments to list constructors for default size/ value 2016-07-17 12:01:50 +10:00
1f84a10f44 Implement String indexOf(needle, startIndex) 2016-07-14 01:23:01 -02:30
5418e4f8f3 Add MapEntry to core to let maps be directly iterated.
Fix #372.
2016-07-06 07:17:07 -07:00
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
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
59e9eb127e Add wrenAbortFiber().
Thanks, @underscorediscovery!
2016-06-09 19:14:21 -07:00
2b0878ec6d Platform.isWindows. 2016-05-21 12:53:21 -07:00
6002cc4d65 Add Stdin.isTerminal. 2016-05-21 12:51:11 -07:00
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
0a060a9678 WrenValue -> WrenHandle. 2016-05-20 20:55:28 -07:00
5d98d20175 Add Stdin.isRaw. 2016-05-20 15:19:18 -07:00
500dd41ccd Add Stdin.readByte(). 2016-05-20 11:50:14 -07:00
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
2ce5913501 Correctly count subscript parameters in wrenMakeCallHandle().
Fixes #351.
2016-05-04 06:29:44 -07:00
694186810b Test that multiple closures of the same code are unequal. 2016-03-26 14:22:38 -07:00
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
38699e3a81 Rearrange the code a bit for duplicate method detections. 2016-03-15 07:15:55 -07:00
6dfbea1ea4 Don't use generic function for finding method duplicates and add tests 2016-03-12 19:14:19 -08:00
9fda7cb526 Unify Fiber.try() with the other methods to execute fibers. 2016-03-03 17:00:33 -08:00
84bcb5801c Add a test for creating a VM without a config. 2016-03-03 14:31:47 -08:00
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
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
60162575ee More file system checking functions:
- Stat#isFile
- Stat#isDirectory
- Directory.exists()
- File.exists()
2016-02-21 12:23:33 -08:00
b331915259 Add stat instance method to File. 2016-02-21 10:18:45 -08:00
8e90e3577b More file IO!
Can now create, delete, and write to files.
2016-02-20 09:23:42 -08:00
ef3aa07d84 Add API to get the type of object in a slot. 2016-02-19 07:18:00 -08:00
fa0a507b48 Error on jump distance overflow. 2016-02-19 06:57:38 -08:00
b8e85c83a8 Fix test and add skynet example. 2016-02-14 22:21:50 -08: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
79558d95e5 Move File.stat() -> Stat.path().
Thanks, Michel!
2016-02-07 09:56:16 -08:00
fde6cfc142 Generate wrenAllocateForeign() to match the other setSlot methods.
Thanks, Michel!
2016-01-24 09:25:04 -08:00
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
f9d1e9954a Make File.stat() directory test less file system sensitive. 2016-01-05 07:32:51 -08:00
94208647ab Test File.stat() on a directory. 2016-01-01 10:05:31 -08:00
5cd8a06fa0 File.stat(). 2016-01-01 09:58:44 -08:00
b054526df8 Add an optional offset to File.readBytes(). 2015-12-30 08:13:19 -08:00
2c31985e54 Make Directory.list() create and return a list from C. 2015-12-29 08:37:47 -08:00
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
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
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
9512ce74c3 Merge branch 'master' into api
# Conflicts:
#	src/module/io.c
2015-12-26 20:42:53 -08:00
1d16e85a85 Add an API to load a top-level variable into a slot. 2015-12-26 10:53:14 -08:00
0ac793d4f8 Add Directory.list() to io. 2015-12-24 10:12:12 -08:00
15043b897f Add a benchmark for wrenCall(). 2015-12-23 17:29:53 -08:00
b7e62926ab Merge branch 'master' into api 2015-12-23 09:22:49 -08:00