1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-26 07:03:16 +00:00
Commit Graph

174 Commits

Author SHA1 Message Date
Calvin Rose
ee646dadf2 Merge branch 'master' into threads-3 2019-12-07 12:14:44 -06:00
Calvin Rose
4a0ee5df7d Address #215
Also update docs for module/expand-path.
2019-12-06 19:54:11 -06:00
Calvin Rose
a1f35e21c7 Merge branch 'master' into threads-3 2019-12-03 18:11:32 -06:00
Calvin Rose
cecc7e6b9d Rename 'get' opcode to 'in', add new 'get' opcode.
This makes the names of the opcodes match their implied functionality.
We also rename the C functions to match the opcodes and source level
functionality.
2019-12-02 21:26:28 -06:00
Calvin Rose
70c8b6838d Use make-image-dict and load-image-dict in thread/new
Rather than messing with janet_core_dictionary, we
instead cache the core enevironment, and pull out the
needed tables from there. This is more flexible, more correct, and
also exposes janet_resolve_core, which can be easily used from the C
API.
2019-12-02 04:15:22 -06:00
Calvin Rose
5b1e59b535 Merge branch 'master' of github.com:janet-lang/janet into threads-3 2019-12-01 21:26:22 -06:00
Calvin Rose
779d788efa
Merge pull request #204 from andrewchambers/get_permissive
New capi janet_get_permissive
2019-12-01 22:06:44 -05:00
Andrew Chambers
6233d804c8 New capi janet_get_permissive
The janet_get_permissive function implements the core semantics
of the 'get' function. The original janet_get implements the semantics of
the 'in' function and also the OP_GET opcode. This slight oddity is
to avoid a backwards incompatible change.
2019-12-02 15:49:51 +13:00
Calvin Rose
6a763aac95 Work on threads.
Add send and receive.
2019-12-01 20:28:12 -06:00
Calvin Rose
5cd6580c2d Merge branch 'threads-3' of github.com:janet-lang/janet into threads-3 2019-12-01 20:25:57 -06:00
Andrew Chambers
8a58be81ba Update documentation for in and get builtins.
Try to clarify documentation and teach users the correct
way to read the 'in' so it is less likely to be confused
with python's usage of the keyword.
2019-12-02 12:35:54 +13:00
Calvin Rose
570f04ca05 Fix typo. 2019-11-30 21:27:36 -05:00
Calvin Rose
bca0392738 First work on threading.
Posix only, needs to be disabled on windows. Also
the Makefile needs to be configurable, and meson.build
needs to take pthreads into account.
2019-11-26 23:13:53 -06:00
Calvin Rose
d37c43716a Lots of work on improving debugging.
doc macro can take no arguments and print out
all bindings. Fix an issues with the vm skipping
over a breakpoint in some situations.

Add examples/debugger.janet for proof of concept
debugger.
2019-11-24 17:45:53 -06:00
Calvin Rose
aee1687215 Add RNG functionality to the math/ module.
The new RNG wraps up state for random number generation, so
one can have many rngs and even marshal and unmarshal them.
Adds math/rng, math/rng-uniform, and math/rng-int.

Also introduce `in` and change semantics for
indexing out of range. This commit enforces stricter
invariants on keys when indexing via a function call
on the data structure, or the new `in` function.

The `get` function is now more lax about keys, and will
not throw an error when a bad key is used for a data structure, instead
returning the default value.
2019-11-08 17:40:04 -06:00
Calvin Rose
026f26f05f Improve error message in slice functions.
Check the first argument before trying to do range
checks.
2019-11-05 09:41:30 -06:00
Calvin Rose
cf2d3861d6 Make slice a c function.
This will allow future integration into the compiler
for more general destructuring.
2019-11-05 09:29:32 -06:00
Calvin Rose
ab782d8896 Add optional default value to get.
Also update CHANGELOG.md
2019-08-06 18:12:00 -05:00
Calvin Rose
44e752d737 Add shorthand function literals to janet.
These are similar to the function literals from Clojure
(also Fennel), and should make short functions for maps, filters, etc.
easier to write.
2019-08-04 12:25:52 -05:00
Calvin Rose
8bbe518696 Executables linking to natives working on linux.
This involves a bunch of machinery in cook.janet
and even a little bit in the janet C API.
2019-07-28 13:27:20 -05:00
Calvin Rose
7e97687c9e Update windows installation and automation. 2019-07-27 21:44:44 -04:00
Calvin Rose
dfe00fee94 Building standalone binaries on linux working.
Mostly changes to cook and jpm. Also some
code for file associations in the windows installer, and
adding the :linux value from os/which (instead of just :posix).
2019-07-26 22:43:54 -05:00
Calvin Rose
e0fe8476aa Address issue #143
Fix some logic in module/expand-path.
2019-07-15 17:39:50 -05:00
Calvin Rose
b8032ec61d Add propagate function and opcode
This allows better stacktraces when manually intercepting
signals to clean up resources. Also allows functionality
from Common Lisp's unwind-protect, such as calling cleanup code
while unwindinding the stack, restarting on certain signals, and
just in general having more control over signal and signal propagation.

Also fix a bug encountered while implementing with-resource in the
compiler. Desturcturing arguments that were not the last argument
would often result in bad code generation, as slots used to destructure
the earlier arguments would invalidate the later parameters. This is
fixed by allocating all named parameters before doing any destructuring.
2019-06-24 12:44:13 -04:00
Calvin Rose
cf05ff610f Add some fixes for serializing complex grammars. 2019-06-19 23:23:27 -04:00
Calvin Rose
19a0444f41 Appease MSVC 2019-06-19 09:45:56 -04:00
Calvin Rose
9ba8728176 Update module system.
Add relative imports and path normalization. This should
help towards a more composable build/dependency system.
2019-06-18 22:10:13 -04:00
Calvin Rose
802a2d6b71 Add more dynamic bindings for printing. 2019-06-08 15:27:13 -04:00
Calvin Rose
d9a4ef05ac Update docstring format.
Also add :p flag to fiber/new, change implemntation of with-dyns, and
make meson build install static library by default.
2019-06-08 10:30:43 -04:00
Calvin Rose
c8cf7c2445 Appease MSVC. 2019-05-29 22:12:24 -04:00
Calvin Rose
bcbe42ab23 Add API version checking for modules.
Checking now actively implemented for dynamic modules
in a fully backwards compatible way.
2019-05-29 21:58:20 -04:00
Calvin Rose
56d903d75b Remove extra closing paren. 2019-05-16 12:12:55 -04:00
Calvin Rose
88b8418253 Add simple tracing functionality to VM.
Also disable debugger for normal errors.
2019-05-04 15:05:00 -04:00
Calvin Rose
513d551df6 Move print in source code to io module.
print now reads the dynamic binding for :out
when choosing where to write to.
2019-04-16 19:10:01 -04:00
Calvin Rose
2d7df6b78e Many changes for adding dynamic (fiber-level) scope.
- Allow passing a table to fibers, which make fiber level scope easier.
- Add fiber/getenv, fiber/setenv, dyn, and setdyn
- Remove meta, *env*, and *doc-width*
- Some functions changed dignatures, and no longer take an env
2019-04-16 15:41:45 -04:00
Calvin Rose
7f1b5d4d70 Merge core.janet into boot.janet
This simplifies the build machinery a bit.
core.janet is never actually included in the final
binary, it is just used to generate an image file.
2019-03-22 18:34:50 -04:00
Calvin Rose
25aa7a26c5 Add experimental meson build.
Should help with IDE integration.
2019-03-22 18:07:10 -04:00
Calvin Rose
cb2caecbb3 Add janetconf.h for configuring builds.
Rather than edit the Makefile or the janet.h header yourself, use
janetconf.h to configure builds. This has the benefit of making it
easier to configure janet in a persitent but easy way.
2019-03-22 14:33:30 -04:00
Calvin Rose
bad040665f Renamed bigint -> inttypes / int
A lot of refactoring larger integer types. Fix a number
of casting errors, but mostly rename things. Also try to
limit use of template-like macros as they bloat the binary
if not used in moderation. We were able to reduce the size of
typed array code as well by using a single view types.
2019-03-18 18:36:53 -07:00
J.-F. Cap
42a0af3b1b bigint pretty printing 2019-03-18 18:36:53 -07:00
J.-F. Cap
d29e3a1199 first experiment with bigint 2019-03-18 18:36:53 -07:00
Calvin Rose
31e2415bbb Fix some indentation problems. 2019-03-12 20:56:16 -04:00
Calvin Rose
d42bdf2443 Add proper optional arguments.
Use &opt in the parameter list to get optional arguments.
2019-03-12 00:23:14 -04:00
Calvin Rose
a363dce943 Allow proper overriding of cfunctions in the core.
Allow overriding functions in the core libray to provide better
functionality on startup. Used to include our getline function in
the repl but use a simpler version in the core library.
2019-03-08 11:39:18 -05:00
J.-F. Cap
4d3c655058 Merge remote-tracking branch 'upstream/master' into typed-array 2019-02-23 17:36:38 +01:00
Calvin Rose
340a6c4d8d Update marsh.c to use janet_panic for errors.
Before, we used a local setjmp/longjmp for error handling.
Using janet_panic means errors can be more easily expressive and
code can be smaller.

However, we still need to make vector memory get gc collected, as
panics can cause the runtime to skip janet_v_frees.
2019-02-22 10:12:25 -05:00
J.-F. Cap
1d50fd9485 First exeperiments with JS style Binary Typed Arrays 2019-02-21 00:15:48 +01:00
Calvin Rose
27a274b686 Update some corelib functions.
Some corelib functions that were created via janet_quickasm
were missing some flags for arity checking, so they were marked as
accepting any arity.
2019-02-19 23:41:16 -05:00
Calvin Rose
9d4effc02e Add make format to format code.
A consistent style should help with contributors and
readability. We use astyle as the formatter as can make a pretty
good approximation of the current style and my preferred style.

Astyle can be found at http://astyle.sourceforge.net/astyle.html
2019-02-19 20:51:34 -05:00
Calvin Rose
ed72dcf82d Rename the header <janet/janet.h> to <janet.h>
Makes it easier to use and remember, and makes the
variable `module/*headerpath*` make more sense.
2019-02-18 20:13:35 -05:00
Calvin Rose
540b326c54 Simpler way to set JANET_PATH at compile time. 2019-02-18 14:48:29 -05:00
Calvin Rose
660a2b41ae Set module/*syspath* to JANET_PATH at build time
The takes out the hardcoded reference to /usr/local/
2019-02-18 14:31:23 -05:00
Calvin Rose
1e70c97ef0 Allow enabling/disabling of peg module.
Use compiler define -DJANET_NO_PEG to turn off the peg module.
2019-02-17 21:22:03 -05:00
Calvin Rose
fe27df528c Boot core library from image rather than source
This should speed up start time and reduce malloc/free
usage to about 15% of what is what previously for startup.
The current cost is slightly larger binary as the representaion
of the image is currently less compact than source code.
2019-02-08 00:44:30 -05:00
Calvin Rose
611543c48b Add source amalgamation
The amalgamated source concatenates all sources
to a file janet.c which can be used for
embedding janet, much in the same way as sqlite
or mongoose.
2019-01-24 00:15:58 -05:00
Calvin Rose
bf8d5da3dc Fix possible memory leak on buffer overflow.
(All buffer push functions can panic (longjmp), skipping
 deinit. Instead, we should use the garbage collected api).
2019-01-19 12:32:52 -05:00
Calvin Rose
798c88b4c8 Update peg to allow functions over captures. Update C API
to make janet function calls easier and faster from C (still
needs an object pool for fibers, though). Fix bug in scan-number
and add many more peg tests.
2019-01-12 17:31:15 -05:00
Calvin Rose
40845b5c1b Initial peg implementation. Tree walk interpretted with
no captures, so not yet ready.
2019-01-11 19:22:24 -05:00
Calvin Rose
6f3bc3d577 Update copyright date, fix types, remove trailing whitespace. 2019-01-06 03:23:03 -05:00
Calvin Rose
5865692401 Surround embedded documentation with a macro so it
can be disabled in a future build.
2019-01-06 01:49:56 -05:00
Calvin Rose
b626e73d19 Add extra argument to (native) to allow for passing
in custom environment to add stuff to.
2019-01-05 23:37:10 -05:00
Calvin Rose
0fdd404a71 Remove duplicate functionality in string.c 2019-01-05 21:23:44 -05:00
Calvin Rose
338b31f5a2 Add janet_fixarity. Update emscripten source. 2019-01-05 20:45:24 -05:00
Calvin Rose
b60e3e302a Update C API to use friendlier functions rather than macros.
Error handling is implemented with setjmp/longjmp so code
can be more concise. This required a very large but straight forward refactor for all
of the libraries.
2019-01-05 20:09:03 -05:00
Calvin Rose
337a498edb Fix some keyword related issues. 2019-01-02 22:08:51 -05:00
Calvin Rose
e9c94598e6 Add native keyword type to replace symbols with leading ':'
character.
2019-01-02 19:41:07 -05:00
Calvin Rose
6b95326d7c First commit removing the integer number type. This should
remove some complexity and unexpected behavior around numbers in
general as all numbers are the same number type, IEEE 754 double
precision numbers. Also update examples and tests, some of which were
out of date.

Some more testing may be needed for new changes to numbers.
2018-12-27 13:05:29 -05:00
Calvin Rose
cc5b4eac0a Update documentation, fix life example. 2018-12-17 21:28:45 -05:00
Calvin Rose
77ea11c603 Update documentation to include source
location of bindings.
2018-12-17 12:06:50 -05:00
Calvin Rose
99e14a9b70 Rename bitwise operators. 2018-12-16 22:13:48 -05:00
Calvin Rose
e8c0dcd14e Make source mapping use byte offset instead of line and col
for better debugging support in repl. Add debug module for better
debugging support.
2018-12-13 18:46:53 -05:00
Calvin Rose
6185af7227 Try to remove build issues on windows. 2018-12-08 17:20:24 -05:00
Calvin Rose
16e514b351 Update version schema - now have version number
and build number.
2018-12-08 14:17:03 -05:00
Calvin Rose
7668cd5772 Don't use generated headers for embedded janet
code, use object files.
2018-12-06 14:30:11 -05:00
Calvin Rose
4e4dd31164 Change syntax for namespaces.
Add quasiquote, unquote, and unquote-splicing
as specials rather than a macro.
2018-11-30 22:49:21 -05:00
Calvin Rose
d791077e25 Fix abstract? function. 2018-11-23 15:33:49 -05:00
Calvin Rose
fcbd24cedc Add lots of documentation for all functions. 2018-11-16 16:24:10 -05:00
Calvin Rose
945b72468c Add a lot of documentation for functions. 2018-11-16 02:09:38 -05:00
Calvin Rose
4d119e4e03 Begin adding more complete documentation. 2018-11-15 15:45:41 -05:00
Calvin Rose
98f2c6feab Add lookups for marshalling and unmarshalling.
Allow generating lookup tables from the current environment.
2018-10-21 01:35:07 -04:00
Calvin Rose
c1923c5ada Web assembly build with emscripten. 2018-10-16 23:08:26 -04:00
Calvin Rose
e963672977 Make the assembler optional during compilation. 2018-09-29 10:58:57 -04:00
Calvin Rose
c8ef2a0d88 Rename to janet 2018-09-05 22:18:42 -04:00
Calvin Rose
75c66ea6dd Refactor native module declarations. marshal can now
serialize entire environment.
2018-08-26 14:35:01 -04:00
Calvin Rose
45d0597294 Remove apply1 and optimize apply. 2018-08-26 12:53:39 -04:00
Calvin Rose
634ec85b07 Fix funcdef flags when marshaling. 2018-08-21 15:07:37 -04:00
Calvin Rose
910cfd7ddf Lots of updates. Function marshaling WIP. 2018-08-19 20:21:27 -04:00
Calvin Rose
48c2654312 Local changes. 2018-08-07 00:54:47 -04:00
Calvin Rose
f3480c1c1d Try to silence some appveyor warnings. 2018-08-05 21:32:32 -04:00
Calvin Rose
44b8c5a8c8 Merge branch 'master' of https://github.com/bakpakin/dst 2018-08-05 21:20:45 -04:00
Calvin Rose
ed2f032c15 Remove cmake build to simplify things. 2018-08-05 21:13:14 -04:00
Calvin Rose
1acd2d1de7 Inlining for all built in comparators. 2018-07-09 21:24:22 -04:00
Calvin Rose
b860b0a3c5 Port some cfunctions in math.c to corelib as
assembled functions.
2018-07-08 23:10:02 -04:00
Calvin Rose
5b15ad9ff8 Try and fix os.clock on windows. 2018-07-08 20:54:41 -04:00
Calvin Rose
f63d08efbd Work to replace os.execute command with something safe. 2018-07-06 22:00:41 -04:00
Calvin Rose
3d7fff659a Make native modules optional. 2018-07-04 14:00:11 -04:00
Calvin Rose
1f37919f39 Rename boot.dst to core.dst 2018-07-04 00:21:18 -04:00
Calvin Rose
a018f9f54a Major refactor. Move files around, merge compiler into
core and other changes, work on inlining many c functions.
2018-07-03 23:07:35 -04:00
Calvin Rose
6822400abe Fix large function compilation issue. 2018-07-01 15:53:57 -04:00
Calvin Rose
363a17ff8c Convert get, put and length to normal functions, not c functions. 2018-06-17 13:55:02 -04:00