Calvin Rose
efb2ab06cb
Remove array_init and array_deinit
...
These functions made it very easy to create memory
leaks, and are better replaced with functions in vector.h or
simply using non-stack allocated arrays.
2019-06-05 16:19:51 -04:00
Calvin Rose
6e8beff0a0
Add optional argument to parser/where to set index.
...
DSLs that use the parser API can use this to more accurately
report source location.
2019-06-03 10:48:16 -04:00
Calvin Rose
c82aac1365
Refer to @ as atsign not ampersand.
2019-06-01 23:40:59 -04:00
Calvin Rose
e697cc3811
Make os/execute not leak memory on panics.
...
Since many calls can panic, it's best
to only use scratch memory for temporary values.
2019-06-01 23:38:10 -04:00
Calvin Rose
c150f2f2c1
Add scratch memory API.
...
This should make it easier to write
code that does not leak memory on panics.
2019-06-01 23:31:39 -04:00
Calvin Rose
e1bd24c2ab
Make os/execute on windows closer to posix version
2019-05-31 15:02:44 -04:00
Calvin Rose
1f30ea66e9
Windows quick fix.
2019-05-31 13:45:39 -04:00
Calvin Rose
c43aaf8986
More work to os/execute.
...
Use environ when eflag not given. Also try to escape windows
command line strings correctly.
2019-05-31 13:44:14 -04:00
Calvin Rose
2acc81d1c5
Add noreturn attribute to panic functions.
2019-05-31 10:10:20 -04:00
Calvin Rose
d005ac6888
Appease MSVC.
2019-05-30 19:21:11 -04:00
Calvin Rose
7fdb098a20
Add process.h.
2019-05-30 19:14:54 -04:00
Calvin Rose
a4a200e037
Spawn.h not found in windows.
2019-05-30 19:13:13 -04:00
Calvin Rose
15d95d8803
Windows include issue.
2019-05-30 18:50:52 -04:00
Calvin Rose
46950a8cb3
Convert os/execute to use posix_spawn.
2019-05-30 18:40:10 -04:00
Calvin Rose
c8cf7c2445
Appease MSVC.
2019-05-29 22:12:24 -04:00
Calvin Rose
1b63215aad
Remove extra functions.
2019-05-29 22:00:47 -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
31f502b508
Add more to util.h to help with amalg build.
2019-05-29 12:07:53 -04:00
Calvin Rose
4d47d92a4a
Windows WEXITSTATUS fix?
2019-05-29 11:53:57 -04:00
Calvin Rose
b39ad97a87
Fix up close to return proper exit code.
2019-05-29 11:50:46 -04:00
Calvin Rose
af23040d9c
file/close returns an integer.
...
If opened with popen, returns the exit code. Otherwise
returns nil.
2019-05-29 11:40:58 -04:00
Calvin Rose
fd2d706e33
Add os/remove.
2019-05-29 11:31:19 -04:00
Andrew Chambers
3c304ddc35
Add api for checking build compatibilty.
2019-05-28 13:51:40 +12:00
Calvin Rose
010e2e4652
Add keyword arguments via &keys.
...
This makes it easier to document functions that
take keyword arguments and also prevents some allocations
with these functions. Before, this was possible via normal
variadic functions but created an intermediate tuple, and
the generated docstrings did not document the keys.
2019-05-24 17:03:22 -04:00
Calvin Rose
ddedae6831
Reenable computed gotos - they were disabled.
2019-05-24 13:54:23 -04:00
Calvin Rose
a303704a7d
Add some tests for the amalgamated source/
...
Adds tests to Makefile and CI on Poisx platforms.
2019-05-23 10:34:01 -04:00
Calvin Rose
411fc77ecf
Make env optional for compile.
2019-05-20 11:34:07 -04:00
Calvin Rose
55d8e8b56b
Fix issue with compilation with source name.
...
Also add tuple/sourcemap and tuple/setmap.
2019-05-20 04:02:38 -04:00
Andrew Chambers
ec43afb426
Minor documentation fixes.
2019-05-17 20:58:06 +12:00
Calvin Rose
56d903d75b
Remove extra closing paren.
2019-05-16 12:12:55 -04:00
Calvin Rose
dde5351d11
Small changes to some doc strings.
2019-05-16 11:43:21 -04:00
Calvin Rose
f2313b9959
file/read on eof will return nil.
...
Also add documentation for :exit in import.
Address issue #91
Partially adress issue #93
2019-05-14 11:05:19 -04:00
Calvin Rose
805b3bbb88
Numbers require at least 1 significant digit.
...
Address issue #96
2019-05-14 08:44:38 -04:00
Calvin Rose
232ea22dc5
Add string/triml, string/trimr, and string/trim.
2019-05-10 16:09:49 -04:00
Calvin Rose
7a313f6038
Update CHANGELOG, string/has-suffix?|prefix?
...
string/has-suffix? and string/has-prefix? can now accept
all byte data types for both arguments.
2019-05-09 13:42:14 -04:00
Calvin Rose
bbcfaf1289
Fix use after free bug in buffer/format when printing self.
2019-05-08 15:25:25 -04:00
Calvin Rose
bfb0cb331e
No temporary buffer in PR #87
2019-05-08 10:53:23 -04:00
Andrew Chambers
1759252071
Fix use after free in buffer/push-string.
2019-05-08 10:49:25 -04:00
Calvin Rose
fff60b053b
Use memmove in buffer/blit when needed.
2019-05-08 09:29:21 -04:00
Calvin Rose
65ac17986a
Address similar issue to #86
...
buffer/blit could trigger a use after free if a buffer is
blitted with itself and modifies its length.
2019-05-08 08:55:43 -04:00
Calvin Rose
ff720f1320
Expose current fiber via janet_current_fiber().
2019-05-04 19:07:04 -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
4fa1b28cad
Update changelog (string module)
...
Also run `make format` on code.
2019-05-04 10:11:52 -04:00
Andrew Chambers
c70d59edee
Add string/has-prefix? and string/has-suffix?.
2019-05-04 10:05:58 -04:00
Calvin Rose
1cfc7b3b0d
Add preliminary debugger to default repl.
...
Also upddate colors, and fix formatting.
2019-05-02 17:11:30 -04:00
Calvin Rose
bfb354b469
Fix 32 bit platforms.
2019-04-28 16:22:24 -04:00
Calvin Rose
0bad523913
Fix wrap functions.
2019-04-27 19:47:32 -04:00
Calvin Rose
5b36199aea
Fix MSVC warning.
2019-04-27 16:50:40 -04:00
Calvin Rose
f10028d41a
Add function versions of macro API bindings.
...
This should help address #81 . Also hide janet_exit
and janet_assert, as they are really meant for internal usage.
I have not verified that this yet actually works with Rust's
bindgen.
2019-04-27 15:47:12 -04:00
Calvin Rose
73b81e0253
Fix os/date doc typo.
2019-04-23 22:43:51 -04:00
Calvin Rose
9100794cea
Drop leading and trailing newlines in longstrings.
...
Long, heredoc style strings can now have
a non semantic leading newline character. This makes it
easier to define large columns of text.
2019-04-21 13:34:41 -04:00
Calvin Rose
4ddf90e301
Make nanboxing on 64 bit platforms not the default.
...
64 bit nanboxing is kind of sketchy on non x86 architectures.
32 bit architectures seem to work better as the 32 implementation
doesn't rely on the format of the address space and layout of
double's in memory.
2019-04-18 12:52:28 -04:00
Calvin Rose
d1eca1cf52
Add all-dynamics to list current dynamic bindings.
2019-04-17 09:47:33 -04:00
Calvin Rose
7918add47d
Allow dynamically setting output for printers
...
Some functions like print and debug/stacktrace print
to a file, usually stdout. This file can now be optionally set
via a dynamic variable.
2019-04-16 21:44:19 -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
7527142549
Prepare for 0.4.1 release
2019-04-14 11:42:41 -04:00
Calvin Rose
4e6193b67e
Fix parse insert bug.
2019-04-13 14:38:30 -04:00
Calvin Rose
1596511175
Fix undefined behavior bug with errors.
...
janet_vm_return_reg should only be set when janet_continue
is called. Otherwise, a panic may dump it's error message in
the wrong place, resulting in undefined behavior (often showing
the last return value or worse, segfaulting).
2019-04-10 23:29:40 -04:00
Calvin Rose
675c1030fd
Fix error message on an arity mismatch.
...
janet_call had a bad janet_printf.
2019-04-07 23:53:50 -04:00
Calvin Rose
ed65d04b81
Fix peg bug with arguments.
...
By holding on a reference to argv for a long time, we
may trigger a use after free bug if the stack is resized. In
janet c function, argv is only vvalid up until the next stack operation
on the fiber. We could say that this is the dynamic lifetime of
argv.
To fix this, we copy extra arguments into a tuple, which is properly
garbage collected.
2019-04-07 15:14:54 -04:00
Calvin Rose
fa1c5c85b5
Remove no-capture mode in pegs.
...
Some peg grammars could not capture values based on their position in a
larger grammar. This is a design limitation inheritted from LPeg, but no
longer needed as the replace mode is superseded by the accumulator mode,
which is more general if slightly harder to use.
2019-04-06 11:38:00 -04:00
Calvin Rose
ee35786c8f
semicolon
2019-04-05 14:45:45 -04:00
Calvin Rose
ec6e2cfd62
os/stat returns nil if file does not exist.
2019-04-05 14:45:04 -04:00
Calvin Rose
cd6c009c03
Reformat and use new os/stat capabilities.
2019-04-01 11:21:45 -04:00
Calvin Rose
b15cf193a0
Update os/stat
...
os/stat can now take a keyword as the second argument
to avoid creating a table if one only wants on value
from stat.
2019-04-01 11:11:15 -04:00
Calvin Rose
e239980da7
Quasiquoting bracketed tuples.
2019-03-31 14:15:26 -04:00
Calvin Rose
1709bce77e
Add os/rm and os/rmdir
2019-03-30 15:39:24 -04:00
Calvin Rose
d6ba2de888
Fix os/dir on windows.
2019-03-30 13:46:52 -04:00
Calvin Rose
61c0a4bc87
Windows has different defines for file modes.
2019-03-30 13:09:35 -04:00
Calvin Rose
8af28d3fa5
Windows bump.
2019-03-30 13:06:24 -04:00
Calvin Rose
970923d0e5
Update os/dir for windows.
2019-03-30 13:01:57 -04:00
Calvin Rose
5d7dc0a57c
Add os/dir support for linux/posix.
2019-03-30 12:36:27 -04:00
Calvin Rose
c5090606a4
Add os/stat function.
...
Allows getting more information about files. This
is really useful for writing software that needs to inspect
the file system (like a static site generator). We still need
a way to iterate directories though.
2019-03-30 12:06:14 -04:00
Calvin Rose
bf2d9ae634
Mess with includes for os.c
2019-03-28 23:34:24 -04:00
Calvin Rose
53c7f2eedd
Add more os module functions.
2019-03-28 23:23:58 -04: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
J.-F. Cap
22d75d017f
fix AbstractType get/set error message
2019-03-26 21:47:12 -04:00
Calvin Rose
082639319e
Add colors to repl and string/format.
...
This makes the repl look nicer using ANSI
color codes, which are widely supported. The codes
can also be turned off via the -m flag.
2019-03-24 15:00:22 -04:00
Calvin Rose
2c9195b507
More updates to meson
...
Redo amalg script so we can more easily run
it from Meson.
2019-03-23 13:50:50 -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
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
22e24fb47b
Remove some dead code in bigint.
2019-03-19 12:30:44 -04:00
Calvin Rose
93f0d5f626
Quiet appveyor warnings.
2019-03-18 22:00:20 -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
a07d76b264
use custom string to bigint reader in place of strtol
...
for better compatibility with default janet number reader
2019-03-18 18:36:53 -07:00
J.-F. Cap
1db6d0e0bc
Trap INT64_MIN / -1 exception
2019-03-18 18:36:53 -07:00
J.-F. Cap
34849ea7b3
added (u)int64 typed arrays back
2019-03-18 18:36:53 -07:00
J.-F. Cap
5a9f7c3a85
added in place op! operators
2019-03-18 18:36:53 -07:00
J.-F. Cap
15c6300608
added bitwise operators and guard for division by zero
2019-03-18 18:36:53 -07:00
J.-F. Cap
c6a4485623
code cleanup
2019-03-18 18:36:53 -07:00
J.-F. Cap
090c6ac975
added marshal/unmarshal
2019-03-18 18:36:53 -07:00
J.-F. Cap
319575c864
bigint operators and some tests
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
9bc899ccf2
added core/bigint.c
2019-03-18 18:36:53 -07:00
J.-F. Cap
d29e3a1199
first experiment with bigint
2019-03-18 18:36:53 -07:00
rncar
41bb6a9833
Added a getter to the new pointer type.
2019-03-14 14:21:44 -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
31e2415bbb
Fix some indentation problems.
2019-03-12 20:56:16 -04:00
Calvin Rose
2a5234b390
Properly bail on parse and compile errors
...
If -p flag is not set, we should bail on all three kinds
of errors, not just runtime errors. This includes
parse and compile errors. Before, parse and compile errors
were not properly affected by the :exit parameter to require, which
in turn caused scripts to not bail on parse or compile errors.
2019-03-12 20:41:17 -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
a246877c1e
Remove iterate-template from exported core symbols.
2019-03-11 01:01:59 -04:00
Calvin Rose
51a9c7104d
Hide each-template
2019-03-10 13:31:42 -04:00
Quan Nguyen
75dc08ff21
Fix nil error on drop-until fn
2019-03-10 12:39:55 -04:00
Quan Nguyen
609a9621af
Correct doc for drop-until fn
2019-03-10 11:36:27 +07:00
Calvin Rose
8ba1121161
Add early returns via break.
...
Inside a while loop, the argument to
break does nothing as while loops always
return nil.
2019-03-09 22:01:10 -05:00
Calvin Rose
9a080197e7
Switch some instances of loop in core
...
Several instances of loop in the core library are
switched over to the simpler each and for macros.
2019-03-09 21:01:47 -05:00
Calvin Rose
e65375277a
Update the loop macro.
...
Using the new break special form, the loop
macro was cleaned up. Loop bindings are also
able to be used immediately after declaration, so
forms like (loop [x :range [0 10] :while (< x 5)] (print x)) will
now compile correctly.
2019-03-09 20:47:07 -05:00
Calvin Rose
4a111b38b1
Add break special.
...
The break special form can break out of both loops
and functions with an early (nil) return. Mainly useful
for generated code in macros, and should probably be discouraged
in user written code.
2019-03-09 17:15:50 -05: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
687a3c91f5
Add array/remove and update CHANGELOG.
2019-03-08 10:24:21 -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
Calvin Rose
69dcab2b55
Silence some casting size_t to double errors.
2019-03-07 22:44:17 -05:00
Calvin Rose
c4f6f1d256
janet_marshal_bytes, janet_unmarshal_bytes size_t
...
Instead of a int32_t as the length argument, use
size_t to match up better with typearray.c and probably
most idiomatic C libraries.
Janet uses int32_t for length internally for consistency, space
efficiency, ability to fit int32_t in double, and various
other reasons.
2019-03-07 22:23:46 -05:00
Calvin Rose
b57e530553
Some more small changes to typedarray.c.
...
We want to compile janet with MSVC warning free.
2019-03-07 22:12:06 -05:00
Calvin Rose
021b71ad62
Allow proper serialization of size_t in marsh.c
...
Typed arrays used size_t in serialization: C APIs will
also often use it, so it makes sense to add first class support
for it rather than assume it will will fint into an integer.
These changes should quiet some visual studio warnings.
Also make some spacing more consistent.
2019-03-07 22:08:44 -05:00
Calvin Rose
0ee2ff1b05
Add :fiber-flags options to run-context.
...
This also improves eval-string error behavior.
2019-03-07 18:55:19 -05:00
Calvin Rose
dc9dc98e80
Update for issue #62
2019-03-07 16:17:18 -05:00
Calvin Rose
4a2d4f52b5
Allow inverted ranges with negative steps.
2019-03-04 15:44:56 -05:00
Calvin Rose
8d37e544ab
Fix BSD builds.
...
Try to silence some more undefined C warnings
with -fsanitize=undefined.
2019-03-04 12:16:49 -05:00
Calvin Rose
b07adce2b9
Fix some issues found with -fsanitize=undefined
...
Leave in issues with calling memcpy with size=0. If these
become a problem, will probably add a janet_memcpy as memcpy
is used so much in the code without 0 checks.
2019-03-04 11:17:34 -05:00
Calvin Rose
1b9591b5e3
Add :down verb to loop macro.
...
Also remove with-idemp from core, which was both confusing
(to the author) and not generally useful.
2019-03-03 23:52:20 -05:00
Calvin Rose
8cc2c964c1
Add :export option to import
...
Also allow NULL ptr to janet_getfile for flags.
2019-03-02 11:46:31 -05:00
J.-F. Cap
7fef5be3af
Merge remote-tracking branch 'upstream/master' into register-corefile
2019-03-02 15:38:31 +01:00
J.-F. Cap
1753f8bc18
Added janet_getfile C API function and revert core/file AT registering
2019-03-02 15:36:34 +01:00
Calvin Rose
3014a59c3e
Fix parse error with comment on last line.
...
If a comment is not followed by a newline character, then
we got a false parse error. This is because the comment
state is left on the parse stack when we finished parsing, and
since the parse stack was not emtpy, we assumed an error.
This commit adds the parser/eof function, which lets the parser know
that an eof was reached. Before, we simply added a fake newline
character in some cases, and in the case of reading a file, we did
nothing, hence the bug.
2019-02-27 13:59:25 -05:00
J.-F. Cap
d70049dbb1
Register core/file abstract type
2019-02-27 10:54:10 +01:00
Calvin Rose
4713219317
Update whitespace and some doc strings.
2019-02-25 23:48:04 -05:00
J.-F. Cap
59393fc73b
Added some guards in ta_view unmarshalling
...
to protect against bad marshalled data.
2019-02-26 02:28:24 +01:00
J.-F. Cap
3eb44f1f79
Fix buffer allocation
2019-02-26 00:21:03 +01:00
J.-F. Cap
fb5119bf43
Added some tests (suite 5)
2019-02-25 18:49:04 +01:00
J.-F. Cap
febfefa4b2
Added tarray/slice and fix buffer size
2019-02-25 02:21:10 +01:00
J.-F. Cap
632b920e97
fix C format
2019-02-24 22:36:35 +01:00
J.-F. Cap
c81bf42f6b
Merge remote-tracking branch 'upstream/master' into typed-array-work
2019-02-24 22:25:33 +01:00
J.-F. Cap
4147c0ce1f
Added typed array C API
2019-02-24 22:24:18 +01:00
Calvin Rose
602e30a421
Add "\v" string esca[e sequence.
2019-02-24 14:46:16 -05:00
Calvin Rose
9495be328c
Be more careful about data alignment
...
Alingment issues can happen anywhere we do casting
on pointer types. Be more careful in the peg module about
ensuring that pointers are aligned well.
2019-02-24 13:43:38 -05:00
J.-F. Cap
0eae75a5c2
added MARSH_EOS check
2019-02-24 18:45:14 +01:00
J.-F. Cap
8e0d7f2539
Merge remote-tracking branch 'upstream/master' into typed-array
2019-02-24 03:06:26 +01: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
Calvin Rose
327d2ed849
Remove extra "compile error: " string.
2019-02-23 15:38:49 -05:00
J.-F. Cap
db64a682be
fix incompatibilities with upstream/master changes in marsh.c
2019-02-23 17:54:09 +01:00
J.-F. Cap
4d3c655058
Merge remote-tracking branch 'upstream/master' into typed-array
2019-02-23 17:36:38 +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
Calvin Rose
115bc6140b
Fix NULL ptr issue.
2019-02-22 17:12:34 -05:00
Calvin Rose
b14fcb068b
Update janet_pcall interface
...
The programmer can now not only get the used fiber, but
provide a fiber to reuse if many calls are made in succession.
2019-02-22 17:10:24 -05:00