Commit Graph

10 Commits

Author SHA1 Message Date
Angus Lees
856bd58872 Add 'importbin' statement
Add `importbin` statement.  Similar to `importstr` but the result is
an array of numbers (all integers 0-255).
2022-03-03 22:49:02 +00:00
Hanyu Cui
f742f2463e
Allow setting a different output stream than os.Stderr for std.trace (#514)
Allow std.trace output to other streams
2021-02-09 14:44:23 +01:00
gotwarlost
6d6c293079 allow initialization of external and TLA code variables from an AST node.
This allows configuration of a VM with an external code variable that has been pre-parsed into an AST node.
This allows a caller to pre-parse a large object into a node and re-use that for multiple VMs. The cost
of converting the object to an ast.Node is incurred only once by the caller as opposed to having this
eagerly incurred (whether or not the object is used) before the eval.
2021-02-04 12:05:09 +01:00
Krishnan Anantheswaran
8a3fcc0302
Allow reset of ext and TLA vars for VM reuse (#509)
Allow reset of ext and TLA vars for VM reuse

Currently ext and TLA vars can be set but not reset. This makes
re-using VMs that have different variables impossible.

Add VM methods to be able to reset ext and TLA vars
2021-02-03 22:55:13 +01:00
Stanisław Barzowski
b70cbd441a Anonymous Import Locations
We used to treat dummy paths like <stdin>, <std>, <extvar> as
real import locations, which causes obvious problem for importers.

After this change we consistently pass "" (an empty string) as location
for non-imported paths.

We exposed new functions to properly handle all paths.

The first function family, EvaluateFile* which allow evaluating
a Jsonnet program at a specified importable path. It should
be used in most cases.

The second function family, EvaluateAnonymousSnippet* allows evaluating
a snippet without an importable path. It should be used for situations
like the code passed as a commandline argument, stdin, etc.

The old function family, EvaluateSnippet* is now deprecated, but
works the same as before, i.e. the passed filenames are treated
as imported paths.

Changes are required to custom importers to make sure they satisfy
the refined contract.

Fixes #329.
2020-09-08 17:27:47 +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
Steve Harris
2e6c559964 Don't automatically install the std AST into "ast" 2019-06-15 01:34:11 +02:00
Steve Harris
7084acc012 Accommodate testing with Bazel 2019-06-15 01:34:11 +02:00
Stanisław Barzowski
f4428e6d47 Better Importer interface
As discussed in https://github.com/google/go-jsonnet/issues/190
2018-04-28 01:34:42 -04:00
Stanisław Barzowski
c3551f4f61 Basic refactoring - towards shared e2e tests 2017-12-14 17:48:34 -05:00