Commit Graph

118 Commits

Author SHA1 Message Date
Calvin Rose f4077b678a Allow calling next on abstracts.
This will allow the creation of infinte
streams, low cost generators, etc.
2020-01-18 18:09:20 -06:00
Calvin Rose bbd7355313
Merge pull request #259 from andrewchambers/futureproofhash
Make hash api more future proof.
2020-01-18 09:45:47 -06:00
Calvin Rose a8e4c4bed0 Add special forms and sort completions.
Also fix case when no completion is needed.
2020-01-18 00:17:08 -06:00
Andrew Chambers 344f0b743d Make hash api more future proof. 2020-01-17 17:25:40 +13:00
Calvin Rose 23c7c3bf1c Allow disabling keyed hash function (prf) in conf
In some cases, one might want to disable what is currently
SipHash for speed / better security mechansims. For example, using
red black trees for caches rather than hash tables.
2020-01-16 21:06:03 -06:00
Calvin Rose 3d117804dd Merge branch 'master' into HEAD 2020-01-16 20:08:34 -06:00
Andrew Chambers ea02b2fde9 Use siphash for string hashing.
The hash key still needs to randomly initialized
for the security advantage, but this patch is a
step closer to avoiding hash based DOS.

Further work may including exposing the raw hash
function for use by abstract types who also choose to
implement hash.
2020-01-17 12:06:55 +13:00
Calvin Rose bc2bac8cd3 Fix memory issue in allocating decode buffer.
Since the decode table is currently a single table
per thread, we just make it a thread local to avoid
issues.
2020-01-15 19:58:14 -06:00
Calvin Rose 2df8660f8b Avoid buffer overrun
On very long binding names > 256 characters, a buffer overrun would be
trigger in janet_cfuns. Not a huge issue, since this is not really code
that would ever be user facing, but we can fix this.
2020-01-12 11:31:41 -06:00
Calvin Rose a68ee7aac6 Update Copyright 2020. 2020-01-12 10:50:37 -06:00
Calvin Rose 3d40c95e80 Add ability to Janet signal from C functions.
While C functions are not re-entrant, signaling from a C function
can be used to implement async returns. When resuming a fiber that
signalled from within a C function, the fiber is started after the
instruction that emitted the signal. The resume argument is used
as the return result from the c function.
2020-01-10 20:44:16 -06:00
Calvin Rose 6c7f376410 Try to remove potential overflow bugs.
Also make integer to size_t casts explicit rather than relying on
int32_t * sizeof(x) = size_t. This is kind of a personal preference for
this problem.
2020-01-02 22:08:17 -06:00
Calvin Rose 9dd152dc28 Add features.h for feature test macros.
Because we use an amalgated build, feature
test macros should be set in a single file that
is included before any other headers, and is placed
at the top of the amalgamated build.
2019-12-30 19:06:15 -05:00
Calvin Rose 022be217a2 Remove ==, not==, and order[<,<=,>,>=].
This unifies equality and comparison checking. Before, we had
separate functions and vm opcodes for comparing general values vs.
for comparing numbers, where the numberic functions were polymorphic and
had special cases for handling NaNs. By unfiying them, abstract types
can now better integrate with other number types and behave as keys.

For now, the old functions are aliased but will eventually be removed.
2019-12-28 16:04:15 -05:00
Calvin Rose f1afc5b0b4 Address #214
This adds several common patterns, which are defined in
boot.janet. This essentially gives more primitive patterns
to work with out of the box.

Fix build when JANET_REDUCED_OS is defined.
2019-12-14 20:39:14 -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 6a763aac95 Work on threads.
Add send and receive.
2019-12-01 20:28:12 -06:00
Calvin Rose bfd3845218 Fix cfunction debugging issue
Cfunction were not describing themselves very well, as
their names were not be added to the registry.
2019-03-27 00:14:51 -04:00
Calvin Rose 94a2084723 Add tostring method for abstract types.
This lets abstract types customize how they
print for debugging.
2019-03-19 13:36:26 -04:00
Calvin Rose 95e54c66b6 Use one tag type true and false
We moved the literals true and false into one tag
type, so we an extra tag for raw pointer types
(light userdata). These can be used from the C API via
janet_wrap_pointer and janet_unwrap_pointer.
2019-03-13 14:50:25 -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
Calvin Rose 0382dc976b More code to better integrate with size_t
Typed arrays use proper size_t support in more
places now.
2019-03-08 00:44:26 -05:00
J.-F. Cap 9c1c7fb384 Remove AT id use name as tag 2019-02-24 02:51:34 +01:00
J.-F. Cap af48912f11 Simplify Abstract type introspection 2019-02-24 02:02:54 +01:00
J.-F. Cap 2becebce92 fix C source format 2019-02-23 17:13:43 +01:00
J.-F. Cap 0cc6c6ff33 implement typed array marshal/unmarshal and
generic marshaling capabilities to abstract types.
2019-02-23 16:58:47 +01:00
J.-F. Cap 7cb1c7cef2 added ta marshalling 2019-02-22 17:41:27 +01:00
J.-F. Cap db9ac6dba5 marshal buffer ok 2019-02-22 15:57:48 +01:00
J.-F. Cap 59e4b15fad added some abstract type instrospection capabilities
registering abstract type in vm_register table
2019-02-22 10:54:22 +01: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
J.-F. Cap 86ba69c16b Merge remote-tracking branch 'upstream/master' into crazy-brackets 2019-02-08 23:45:55 +01: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
J.-F. Cap 8ab60e475a typo in janet_indexed_view
(no consequence but look strange)
2019-02-08 01:10:07 +01: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 6f3bc3d577 Update copyright date, fix types, remove trailing whitespace. 2019-01-06 03:23:03 -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 fe22a8db39 Fix 32 bit platforms janet number handling. 2018-12-30 14:23:52 -05:00
Calvin Rose d724c5b959 Update number representation so that wrapping numbers isn't
doesn't need to check for NaNs. Change ordering of types.
2018-12-30 12:37:50 -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 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 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 1ba3aeb3cd Make stacktrace part of public API. 2018-09-09 21:20:33 -04:00
Calvin Rose 56c3b8aa94 Add ability to index into structs and dictionaries generically. 2018-09-09 12:13:32 -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 1b009b4f1f Fix dst_register. 2018-08-22 22:12:47 -04:00
Calvin Rose 510feeed7f Allow marshaling of more functions for core.
Fix indentation in some files.
2018-08-22 21:41:25 -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 547529ebb2 Refactor dst_view_* functions. 2018-07-04 13:21:30 -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 363a17ff8c Convert get, put and length to normal functions, not c functions. 2018-06-17 13:55:02 -04:00
Calvin Rose 0cf10946b0 Add first version of marsh (marshaling). 2018-06-12 14:24:45 -04:00
Calvin Rose fb409201b4 Strip trailing whitespace from many files.
Add native modules to import with module.native-path.
2018-05-19 21:16:00 -04:00
Calvin Rose f295692b50 Update copyright to 2018. Add string methods. 2018-05-17 23:41:20 -04:00
Calvin Rose dafc121f4d Change c function macros to be explicitly non functional by
capitalizing them.
2018-05-12 20:31:28 -04:00
Calvin Rose 181a38f412 Add sqlite3 native module to repo. 2018-05-05 23:51:29 -04:00
Calvin Rose 53f9c18669 More work on improving errors. 2018-04-29 20:13:04 -04:00
Calvin Rose 10934bcfb9 Add errorhandling helper functions and macros for writing c functions. 2018-04-28 18:10:57 -04:00
Calvin Rose 027b2a81c2 Shrink the public interface by hiding internal state. 2018-03-31 16:42:41 -04:00
Calvin Rose 855787b292 Add macroexpand and macroexpand1 2018-03-18 14:01:58 -04:00
Calvin Rose 35ddc70888 Move ast into parser. Map keywords to symbols instead of
strings.
2018-02-03 13:55:55 -05:00
bakpakin 911b0b15e8 Fix some bugs with inner closures. 2018-01-21 14:39:32 -05:00
bakpakin 30f62ca454 Major refactor and restructure. Add CMake for anticipated windows
support.
2018-01-19 16:43:19 -05:00