-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Std lib improvements: add std.slice and std.manifestJsonMinified, fix handling of numbers in manifestXmlJsonml, handling of code in extCode #171
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lihaoyi-databricks
changed the title
Add std.slice and std.manifestJsonMinified
Add std.slice and std.manifestJsonMinified, Fix handling of numbers in manifestXmlJsonml
May 30, 2023
lihaoyi-databricks
changed the title
Add std.slice and std.manifestJsonMinified, Fix handling of numbers in manifestXmlJsonml
Add std.slice and std.manifestJsonMinified, Fix handling of numbers in manifestXmlJsonml, code in extCode
May 30, 2023
lihaoyi-databricks
changed the title
Add std.slice and std.manifestJsonMinified, Fix handling of numbers in manifestXmlJsonml, code in extCode
Std lib improvements: add std.slice and std.manifestJsonMinified, fix handling of numbers in manifestXmlJsonml, handling of code in extCode
May 31, 2023
szeiger
reviewed
Jun 1, 2023
sjsonnet/src/sjsonnet/Std.scala
Outdated
Comment on lines
748
to
751
val range = collection.immutable.Range(index, end, step) | ||
val res = indexable match{ | ||
case Val.Str(pos0, s) => Val.Str(pos, new String(range.map(s.charAt).toArray)) | ||
case arr: Val.Arr => new Val.Arr(pos, range.map(arr.asArr.asLazy(_)).toArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks extremely inefficient for the 99% of cases with step = 1
.
sjsonnet/src/sjsonnet/Val.scala
Outdated
def evalRhs(arg1: Val, arg2: Val, arg3: Val, arg4: Val, ev: EvalScope, pos: Position): Val | ||
|
||
override def apply(argVals: Array[_ <: Lazy], namedNames: Array[String], outerPos: Position)(implicit ev: EvalScope): Val = | ||
if(namedNames == null && argVals.length == 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be argVals.length == 4
szeiger
approved these changes
Jun 2, 2023
lihaoyi-databricks
added a commit
that referenced
this pull request
Jun 6, 2023
Similar to the `--ext-code` changes in #171, `--tla-code` is meant to be able to take arbitrary Jsonnet code just like `--ext-code` can, and before this PR we limited it to only JSON I refactored out the common `Interpreter#parseVar` logic so it can be shared between both, and added new tests to exercise the new behavior. The `override def evalDefault` for the `Val.Func` used for top-level functions needed to be fixed; there was always a logical issue evaluating the `--tla-code` expression using the main file's `ValScope`, but it didn't matter since previously we only allowed JSON so there weren't any identifiers to look up using it. Now that there are, the correct thing to do is to evaluate the `--tla-code` expression using `ValScope.empty`, since it is meant to be a standalone expression without any existing local bindings in its lexical scope Notably, `--tla-code` expressions cannot reference each other the way `--ext-code` expressions can, so there is no equivalent to the `stdExtVarRecursive` test case. They can still call `std` functions, so the `std` test case remains
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #110 and #149 and #74 and #56 and #47 and #114 and #76
Mostly straightforward changes, though the constructor signature of
Interpeter
andEvaluator
had to change a bit to satisfy the fixedextCode
semantics. Added unit tests to assert the correct behaviors