David Tolnay
21309bc6d7
Error on bytecodes longer than 0xFFFF ( fix #269 )
...
This lets us use uint16_t for the program counter. JVM
languages have the same limit on method size so it is a
reasonable limit.
2015-07-26 16:19:20 -07:00
David Tolnay
1628bbf95f
Clean up trailing whitespace
2015-07-19 09:38:50 -07:00
Nicolas Williams
aaf305868c
Restore import into caller's namespace
2015-06-26 23:40:37 -05:00
David Tolnay
4a316fbb5a
fix errors flagged by clang static analyzer
...
builtin.c: bug - free of uninitialized jv
compile.c: missing assertion
jq_test.c: buggy logic / unreachable code
jv.c: missing assertion
jv_alloc.c: false positive - intentional read of uninitialized memory
jv_file.c: dead code
2015-06-20 16:08:56 -05:00
Nicolas Williams
b9c2a326ba
Fix #814 : raise on div-0, add inf isinf nan isnan
2015-06-17 19:58:55 -05:00
David Tolnay
d3343d5113
array and object destructuring ( fix #533 )
...
`. as [$i, $j, $k] | ...`
`. as {a: $i, b: $j} | ...`
`. as [[[$i]], {a: $j}] | ...`
`foreach . as [$i, $j, $k] (...)`
`reduce . as {a: $i, b: $j} (...)`
2015-06-09 17:29:48 -05:00
Nicolas Williams
215b4c0fe1
Use jv_mem_alloc() in compile.c ( fix #771 )
2015-04-28 10:37:37 -05:00
Nicolas Williams
ae7f8d6ab9
Further module system revamp ( fix #659 )
...
To import a module now use:
# Import module.jq file:
import "relative/path/to/module" as foo;
# Use the module's defs as foo::<def-name>
To import a JSON file:
# Read file.json:
import "relative/path/to/file" as $foo;
#
# Use as $foo::foo
Using `-L` now drops the builtin library path and appends the requested
path to the empty array (or the result of an earlier `-L`).
Support for the `$JQ_LIBRARY_PATH` environment variable has been
removed.
2014-12-31 20:09:53 -06:00
Nicolas Williams
7dc34b92af
Add label $name | EXP
; fix break
...
This is to fix the problem where `break` is dynamic, not lexical.
With this it should be possible to do this sort of thing:
label $break | inputs | if ... then $break|error else . end
This is a backwards-incompatible change for master, but the previous
`break` hadn't shipped yet.
Still needed:
- testing
2014-12-30 11:42:45 -06:00
Nicolas Williams
e51e916e31
Fix foreach
non-progation of errors
...
Errors were being re-propagated as "break".
Also add `error/0` builtin, which made this fix easier.
2014-12-26 23:05:20 -06:00
Nicolas Williams
7243989c52
Fix refcount leak, fix #618
2014-11-29 15:24:43 -06:00
William Langford
f7a2af7052
Properly handle when objects cannot be folded
...
Fix #579 .
2014-09-22 20:14:46 -04:00
Nicolas Williams
1ba8c2cfa6
Add module
directive, modulemeta
builtin
...
Fix #425 .
2014-08-14 03:26:26 -05:00
Nicolas Williams
9f13afa20f
Add jq_report_error() function; use it
...
Put a stop to fprintf(stderr, ...) where we shouldn't.
2014-08-14 03:21:35 -05:00
Nicolas Williams
c321c3b86b
Constant fold objects
2014-08-09 20:47:03 -05:00
Nicolas Williams
f87521183f
Fold constant arrays
2014-08-09 20:27:08 -05:00
Nicolas Williams
32c08d48f3
Add def f($arg):
syntax ( fix #524 )
2014-08-08 19:16:01 -05:00
William Langford
a25950a58c
Remove duplicate TOP insertions, drop unused defs.
2014-08-05 00:46:10 -04:00
Nicolas Williams
2e2538ccb8
Fold constants ( fix #504 )
2014-07-27 17:48:49 -05:00
William Langford
38b939688a
Added library system with -l, -L, and JQ_LIBRARY_PATH
...
Created util.[ch] to hold common utilities.
2014-07-22 22:51:11 -05:00
Nicolas Williams
c38e5b1b2c
Lib defs don't bind to each other; fix #479 again
2014-07-13 18:36:27 -05:00
Nicolas Williams
cadf8c3cb0
Revert "Library defs don't bind to each other; fix #479 "
...
This reverts commit 6b6e3f4262
. It was
the wrong fix.
2014-07-13 02:04:27 -05:00
Nicolas Williams
6b6e3f4262
Library defs don't bind to each other; fix #479
2014-07-12 18:38:55 -05:00
Nicolas Williams
539dccae90
Add break
builtin for foreach
2014-07-07 19:33:17 -05:00
Nicolas Williams
8780bc0b8e
Better check for lib has only functions ( fix #138 )
2014-07-07 16:03:32 -05:00
Nicolas Williams
5a863bf010
Add foreach
and limit
2014-07-06 19:40:05 -05:00
Nicolas Williams
7fce34292e
Add try EXP catch EXP
2014-07-06 01:29:42 -05:00
Nicolas Williams
3a647d3e47
Multi-arity needs better errors ( fix #438 )
2014-07-02 02:18:10 -05:00
Nicolas Williams
088a42fc53
Allow multiple functions with different arities
2014-06-16 00:05:30 -05:00
Nicolas Williams
54635000c5
Conditionally #define _GNU_SOURCE in compile.c
2013-12-04 18:21:42 -06:00
Stephen Dolan
b49d65a276
Fold opcode.{c,h} into bytecode.{c,h}
2013-06-18 01:36:18 +01:00
Stephen Dolan
824ce76cec
Simplify block functions for variables
2013-06-18 01:07:18 +01:00
Stephen Dolan
9b91eafac4
Make array construction use LOADVN (slightly faster)
2013-05-16 15:09:59 +01:00
Stephen Dolan
bc42812715
Remove the insane "fold" operation, replace with saner "reduce".
2013-05-16 15:07:53 +01:00
Stephen Dolan
a1e4dfa324
Better debug info for struct bytecode.
...
--debug-dump-disasm produces more comprehensible output now.
2013-05-16 00:51:17 +01:00
Stephen Dolan
f8644c31a3
Only generate code for those builtin functions actually used.
...
Makes output of --debug-dump-disasm much simpler.
2013-05-15 01:37:15 +01:00
Stephen Dolan
1e2851cdb3
Remove the YIELD opcode (use RET instead)
2013-05-15 01:23:06 +01:00
Stephen Dolan
8c708f3c7a
Refactor path logic.
2013-05-13 15:00:05 +01:00
Stephen Dolan
5be97463ec
Add a --arg option to allow variables to be passed from the cmdline.
...
Closes #107
2013-05-06 14:21:00 +01:00
Stephen Dolan
47e015e946
Make a few constant globals actually const.
...
This means the .data and .bss sections are empty, a good thing
in a shared library (see #98 ).
2013-05-05 22:59:53 +01:00
Stephen Dolan
c013b557a2
Change APPEND opcode to directly modify a variable.
...
Avoids a big O(n^2) loop in constructing arrays. Fixes #61 .
2013-01-03 12:51:33 +00:00
Stephen Dolan
d5fdf70434
Refactor assignment.
...
New version is much more elegant and probably slower. Uses
library functions implemented in jq rather than dedicated opcodes.
2012-12-29 16:43:36 +00:00
Stephen Dolan
417899f9a0
Fold operation (code/docs/test)
2012-12-28 15:05:34 +00:00
Stephen Dolan
04daafbde3
Add wrappers for malloc/realloc/free. See #43 .
2012-12-18 16:53:51 +00:00
Stephen Dolan
dcc93042d3
some words explaining struct inst a little
2012-12-10 22:35:33 +00:00
Stephen Dolan
616e8f9924
Refactor function argument passing into what it always should have been.
...
Most visible change is that error messages when a function is called
with the wrong number of arguments are much better.
2012-12-04 00:39:21 +00:00
Stephen Dolan
5f6a95c7b5
General cleanup - rename a few things, delete dead code.
2012-12-03 20:02:02 +00:00
Stephen Dolan
ea9db414ed
Clean up implementation of builtin functions.
2012-12-02 22:12:08 +00:00
Stephen Dolan
b6f2fbbe62
Move all the includes one place to the left
2012-12-02 21:25:54 +00:00
Stephen Dolan
125e278502
Clean up calls to C functions, unify opcodes
2012-12-02 20:45:55 +00:00