Commit Graph

386 Commits

Author SHA1 Message Date
Wes McNamee
9ba4b2ac86 test: Run Make Checks for all versions 2020-01-25 07:45:07 +01:00
Wes McNamee
d28d7d79af test: add Make Check to Travis 2020-01-25 07:45:07 +01:00
Wes McNamee
99980ef423 feat: add asdf integration for bazel
Add support for asdf-managed versions of bazel

https://github.com/asdf-vm/asdf
2020-01-25 07:45:07 +01:00
Weston McNamee
16dc50b566 feat: add Makefile
This streamlines and simplifies local development by adding
a Makefile based on the commands in the README.md
2020-01-25 07:45:07 +01:00
Carlos Cobo
e90ff27a27 Fix git clone in build instructions 2020-01-22 11:08:43 +01:00
Stanisław Barzowski
fe82a78401 Adaptive string representation
When adding long strings, don't copy them immediately. Instead
build long strings only when their contents are requested.

This allows to build a long string from parts, using a regular
operator+ in linear time. This lets users to worry much less
about using std.join etc.

If indexing the string is mixed with building it using operator+
the behavior can still be quadratic. We may want to address it in
a later change.
2020-01-04 23:28:21 +01:00
Stanisław Barzowski
b44e63e102 Bump officially supported Go version to 1.11
Go 1.8 has been unsupported for more than a year.
2019-12-20 15:48:45 +01:00
Alexander Petrov
4b0052a9e3 Python package now is called _gojsonnet for avoiding package collision 2019-12-19 18:09:09 +01:00
Alexander Petrov
f3b46ad15c Code review: fixed comments 2019-12-19 18:09:09 +01:00
Alexander Petrov
d8f0505fc9 Implemented python gojsonnet get_version 2019-12-19 18:09:09 +01:00
Alexander Petrov
741eec05fe Added python tests CI 2019-12-19 18:09:09 +01:00
Alexander Petrov
3be91c4752 Changed python package name to gojsonnet 2019-12-19 18:09:09 +01:00
Alexander Petrov
441e4cc581 Use backed by go-jsonnet for python extension 2019-12-19 18:09:09 +01:00
Dave Cunningham
0959f85501 break up parseObjectRemainder 2019-11-06 19:46:26 +00:00
Dave Cunningham
407c0f311a Fix #331 missing comma error 2019-10-16 22:15:28 +02:00
Alexander Petrov
acf0e5cfbf Implemented jsonnet_import_callback c-binding (#330)
Implemented jsonnet_import_callback c-binding
2019-10-14 20:49:24 +02:00
sh0rez
42cb19ef24 feat(parser): export parser.Children (#327)
* feat(parser): export parser.Children

As parser was moved to internal/parser, it is not possible to import it into
external projects anymore.

However, parser.Children() is handy to use in static analysis tools, so it is
worth exporting. This does that by adding a stub package
`github.com/google/go-jsonnet/parser` that wraps the internal function.

Signed-off-by: sh0rez <me@shorez.de>
2019-10-06 22:38:37 +02:00
Alexander Petrov
56da397819 Code review fixes: Removed unnecessary vm handle checks 2019-10-06 21:20:15 +02:00
Alexander Petrov
4abec72f46 Code review fixes:
* Renamed jsonValue obj field to val
* Renamed jsonValue children field to owned + added an explicit comment about this field
* Got rid of unnecessary vm handle checks
* Renamed arg to param, identifiers to paramNames
* Raised maxID value to 100 000
* Removed freedIDs entry check
2019-10-06 21:20:15 +02:00
Alexander Petrov
3504d5001e Removed ';' in compat_test 2019-10-06 21:20:15 +02:00
Alexander Petrov
ba37440e4f * Added more tests on native callback
* Fixed jsonnet_json_array_append, jsonnet_json_object_append bugs
* jsonValue now stores the list of related struct_JsonnetJsonValue
instead of handles ids
2019-10-06 21:20:15 +02:00
Alexander Petrov
6e9943c99d * Implemented jsonnet_native_callback
* Moved handles workflow to handles.go
* Replaced JsonnetJsonValue c++ implementation with go
* Added jsonnet_json_* integration tests
2019-10-06 21:20:15 +02:00
Dave Cunningham
dc5c94ac78
Add fodder to AST nodes (#319)
* Preserve fodder during parsing.
2019-09-24 12:11:22 +01:00
Stanisław Barzowski
21c00f1b9e Better importing (caching & public API)
* It adds new API which allows using VM for importing
  files in external tools "just as Jsonnet would". This is
  primarily intended for use in static analysis tools.
* Imports are now cached between evaluate calls. This may improve
  performance significantly for some users. I would like to add
  some way of achieving this with commandline in the future.
* Additional layer of caching was internally added - AST level.
  This was necessary so that Jsonnet could always return the same
  exact AST when asked multiple times (meaning the same pointers).
2019-09-23 15:37:10 +02:00
alldroll
8f0e634bb6 Disallow unary + on Object 2019-09-23 13:07:05 +02:00
alldroll
f00242da42 Add runtime check for binary +-* operations for numbers 2019-09-19 14:34:14 +01:00
Stanisław Barzowski
fbde25be21 Release v0.14.0 2019-09-16 16:15:48 +02:00
Stanisław Barzowski
0d5e73c8b0 Check Bazel in Travis 2019-09-11 01:01:01 +02:00
Stanisław Barzowski
ab95594eea Add missing cases in specialChildren
Namely:
1) function body and optional params
2) object locals
2019-09-10 15:41:17 +02:00
Stanisław Barzowski
85fd887750 Unexport a bunch of symbols
Many things were exported for no particular reason.
2019-09-09 16:11:00 +02:00
Stanisław Barzowski
6490cb1973 Builtin implementation for std.sort
Sort is something that is highly optimized in most languages
and users can expect it to be fast. We can piggyback on
the Go implementation.

This change results in 100x speedup on bench.06.jsonnet.
2019-09-09 13:37:12 +02:00
Stanisław Barzowski
e4e1d9112a Fix Bazel config 2019-09-09 13:31:08 +02:00
Stanisław Barzowski
45f3912215 Make parser package internal
There is no reason for external users to directly depend
on parser. It had a few random things exported as well,
namely errors and "children" functions (helpers for AST
traversal).

It was easy to extract the errors package, but I needed to leave
children in parser for now. The errors package was also
made internal, but it's a candidate for making it public
again potentially (if someone wants to display error messages
just like us). For now it's probably too incomplete anyway.

This change has a potential of breaking the existing users
since we technically remove public APIs. These were not needed
or even helpful for actually running Jsonnet code, but perhaps
someone used them anyway.
2019-09-03 17:28:33 +02:00
Stanisław Barzowski
c77f22c99f Eliminate the unnecessary ast.StdAst
The initially empty ast.StdAst was created to break the circular
dependency. The generation of stdlib AST used to depend on
the primary "jsonnet" package, which meant that "jsonnet"
could not depend on it directly. Hence stdlib needed to be put
in the ast package. Now dumpstdlibast no longer depends on Jsonnet,
so we can get rid of this complication.

All code using ast.StdAst should now use astgen.StdAst.
2019-09-01 21:17:29 +02:00
Stanisław Barzowski
e6c74ca7a6 Address review comments 2019-08-28 20:16:47 +01:00
Stanisław Barzowski
82f949e7fe Extract AST processing to separate packages
Making it independent from the jsonnet package breaks the circular
dependency during stdast generation.
2019-08-28 20:16:47 +01:00
Stanisław Barzowski
197b8c58d0 Prevent autogenerated header in BUILD.bazel
Before this change updating BUILD.bazel file with Gazelle
would add `c-bindings/libgojsonnet.h` to `srcs/`.

It was prevented manually, but someone is going to let it slip
in at some point, so it's better to just not include it there
in the first place.
2019-08-27 11:54:11 +02:00
Jason Cooke
13437c69e1 docs: fix typo 2019-08-24 22:06:58 +02:00
Stanisław Barzowski
71a3e16958 Bump cpp-jsonnet (#306) 2019-08-12 23:12:43 +01:00
Stanisław Barzowski
11e63b6703 Make golint happy (#296) 2019-07-24 13:02:12 -04:00
Stanisław Barzowski
3190aff1d4 Fix crash when using empty object comprehension (#301)
The object was not properly created when object comprehension
was empty.
2019-07-24 12:58:59 -04:00
Stanisław Barzowski
e5e27c0f01 Object field caching
This change adds caching to objects fields, i.e. now subsequent
references to an object field are going to be served from cache.

Cache is kept within an object. Objects created with operator +
start with a clean cache (they have to, because in general all
the fields may have changed their values due to late binding).

This change comes naturally with a change of structure of objects,
now valueObject is a concrete struct which keeps "uncachedObject"
which is roughly equivalent to old objects.
2019-07-23 21:57:36 +02:00
Steve Harris
4996d46471 Allow use of Bazel repository externally 2019-07-04 13:09:47 +02:00
Steven E. Harris
8cd516f2ad Eliminate Bazel repository for "cpp-jsonnet" (#290)
Treating the "cpp-jsonnet" Git submodule as a separate local Bazel
repository precludes use of the "go-jsonnet" repository from other
workspaces, as Bazel misinterprets the relative path to the local
"cpp-jsonnet" repository. Instead, use the Git submodule content
directly along the package path from the workspace root.
2019-06-24 21:41:01 +01:00
Stanisław Barzowski
7081ee085e Fix double desugaring in array comps
Accidentally the array we were iterating over was desugared
two times, which resulted in crash when an object was there.
2019-06-23 10:32:22 +02:00
Carlos Eduardo
3ad064e626 Update x/sys to a newer version that supports Risc-V architecture (#284)
Update x/sys to a newer version that supports Risc-V architecture
2019-06-17 15:10:00 +01:00
Steve Harris
7614fd519c Correct a few complaints reported by "staticcheck" 2019-06-15 01:34:11 +02:00
Steve Harris
b6bb47abee Move escaped filename tests into separate function
Write the files with verboten names (within some operating systems) to
a temporary directory, in order to avoid committing them to the VCS
repository.
2019-06-15 01:34:11 +02:00
Steve Harris
2e6c559964 Don't automatically install the std AST into "ast" 2019-06-15 01:34:11 +02:00
Steve Harris
3e7d3b16a4 Commit astgen/stdast.go file for use with "go get" 2019-06-15 01:34:11 +02:00