555 Commits

Author SHA1 Message Date
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
Steve Harris
5b0d9c4da0 dumpstdlibast: Take source file path as parameter 2019-06-15 01:34:11 +02:00
Steve Harris
886fcaca1d Allow building the "c-bindings" program with Bazel 2019-06-15 01:34:11 +02:00
Steve Harris
e7f9dcae99 Augment documentation with use of Bazel 2019-06-15 01:34:11 +02:00
Steve Harris
7084acc012 Accommodate testing with Bazel 2019-06-15 01:34:11 +02:00
Steve Harris
7a5297a884 Dump standard library into "astgen" package
Export all fields in struct types in the "ast" package to allow
generating program source to reconstruct their complete values in a
separate package.
2019-06-15 01:34:11 +02:00
Steve Harris
24fb8b9ee7 Print package prefix for dumped int value types 2019-06-15 01:34:11 +02:00
Steve Harris
ad72eb0fbb Allow building the Go program with Bazel 2019-06-15 01:34:11 +02:00
Dave Cunningham
1c89ed8927 Don't assume Go is in a specific directory 2019-06-08 18:59:32 +01:00
Dave Cunningham
e1e74dbf46 Change golden files back again; 2019-06-04 16:55:43 +01:00
Dave Cunningham
0d560aff58 Update for version v0.13.0 v0.13.0 2019-06-03 18:46:24 +01:00
Dave Cunningham
d89367d4c9 golden files were out of date 2019-06-03 17:39:17 +01:00
Stanisław Barzowski
ee8aee43a3 Fix unintentionally invalid filename escaping test 2019-05-29 21:44:17 +02:00
Dave Cunningham
df7753e2c7 Bring up-to-date with cpp version 2019-05-22 20:43:37 +01:00
Dave Cunningham
6fa1db7d85 Update cpp submodule 2019-05-16 10:12:09 +01:00
Stanisław Barzowski
591b119591 Perform lookups from obj locals with right sb
When object fields are evaluated the locals from the object
are added to the environment. These locals should have the same
environment as the field, in particular they should be
at the same inheritance level. Instead they were evaluated as if
they were on the level from which original field lookup was performed,
resulting in subtle and hard to debug issues.
2019-05-13 17:42:04 +02:00
Stanisław Barzowski
83ed0b939f Proper env for obj locals in comprehensions
We didn't set the environment (upvalues) for objects
created as comprehensions - we set them for each field
separately, but that meant missing the locals.
2019-05-13 17:42:04 +02:00
Stanisław Barzowski
33b6dcfa53
Keep object locals only once in AST (#263)
Keep object locals only once in AST

For example this reduces the size of stdlib ast file
roughly 3x. Note that this change doesn't regenerate the stdlib,
so that the diff here is sane.

It is likely to slightly improve performance of code using
a lot of locals (~10% on bench.05.gen.jsonnet).

The desugaring is more strightforward now, and we're back
to desugaring each node exactly once.
2019-05-07 22:43:55 +02:00
Stanisław Barzowski
181c86d815 Add builtin implementation of std.split 2019-04-24 12:42:40 +02:00
Stanisław Barzowski
c195e570ef Share std.jsonnet with cpp-jsonnet
So far `std.jsonnet` needed to be updated seprately from
the cpp-jsonnet submodule. Since we should update it anyway
at the same time (to make sure the tests are running fine),
we can just as well get it directly from there, eliminating
the extra step of copying the new `std.jsonnet` version.

This change updates the cpp-jsonnet used.
2019-04-16 20:35:19 +02:00
Michael Schuett
2188e2d62a Add go mod / cleanup (#266)
Add go mod

Also make the build docs nicer and cleanup the file directory to be in line
with most other go projects. This also make it so you can build jsonnet
without setting -o on go build.
2019-04-03 15:46:19 +02:00
Stanisław Barzowski
aa47869bc4 Add basic tests for Children and add missing cases 2019-03-20 10:23:24 -04:00
Stanisław Barzowski
686c77b2db Add missing error handling branch
Fixes #255
2019-03-20 10:23:24 -04:00
Stanisław Barzowski
eea884b12f Minimal C bindings (#257)
* Minimal C bindings
* Fix version reporting in C bindings
* Apply suggestions about C bindings implementation
* Rename compat/ -> c-bindings/
* Add comment about indexing VMs in C bindings
2019-03-16 17:47:12 -04:00
Alexandre Bourget
ce90e53336 Expose Evaluate functions, to be able to reuse the AST from SnippetToAST.
Right now, SnippetToAST provides a `Node` but nothing consumes it it seems.
2019-03-11 12:03:15 -04:00
Stanisław Barzowski
530e7960bd Fix improper stack trimming with operators and tailstrict
My understanding of origin of this bug was that once we
were creating thunks for binary operator arguments. So the environment
was no longer needed once they were created, so they could be tailcalls.

Now we're calling i.evaluate directly (for performance) and now
the environment cannot be destroyed during the evaluation of the first
argument.
2019-03-07 09:10:23 -05:00
Stanisław Barzowski
9348a5d2b1 Update cpp-jsonnet submodule and stdlib
Current go-jsonnet is not really 0.12.1 - it even
reports 0.12.0. This brings all the good stuff
from recent cpp-jsonnet commits and actually syncs
the version.
2019-03-04 09:45:11 -05:00
Stanisław Barzowski
c1743b9a2a Add std.encodeUTF8 and std.decodeUTF8 2019-03-04 09:41:01 -05:00
Stanisław Barzowski
7af3b8496c Add missing error handling branch
Fixes #255
2019-01-14 15:09:42 -05:00
Dave Cunningham
493c45a403 Update cpp-jsonnet and bump version to 0.12.0 v0.12.1 v0.12.0 2018-12-18 14:32:59 -05:00
Dave Cunningham
ff0c19aa29 Update cpp-jsonnet 2018-12-18 13:42:53 -05:00
Stanisław Barzowski
767f100fd6 std.parseJson - a builtin for parsing json 2018-12-13 13:45:39 -05:00