| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
|
| |
expressions.
This is probably only a theoretical problem, since a blocking struct field is probably a very bad idea.
Closes #5132.
Change-Id: Ie84a78ab4d9ce215f2806ac49bf8911de6959930
PiperOrigin-RevId: 207902766
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
range used to use MutableList which would eagerly allocate an array list with
all range elements, which is not efficient for very large ranges or when only
a small number of its elements are used.
This implementation uses a constant amount of RAM and computes a value for
each requested index.
For the following Skylark snippet:
```
def check_content(t):
if t == []:
return t
return False
def modulo(n):
return n % 797
N = 10000000
[check_content(i) for i in range(N)]
[check_content(i) for i in range(N)]
[modulo(i) for i in range(N)]
[modulo(i) for i in range(N)]
```
the total runtime goes from
```
$ time bazel-bin/src/main/java/com/google/devtools/skylark/Skylark test.bzl
bazel-bin/src/main/java/com/google/devtools/skylark/Skylark test.bzl 93.09s user 1.67s system 316% cpu 29.930 total
```
to
```
$ time bazel-bin/src/main/java/com/google/devtools/skylark/Skylark test.bzl
bazel-bin/src/main/java/com/google/devtools/skylark/Skylark test.bzl 31.45s user 0.86s system 179% cpu 17.974 total
```
which reflects the reduced system time (fewer allocations) and performance.
Closes #5240.
PiperOrigin-RevId: 204918577
|
|
|
|
|
| |
RELNOTES: None.
PiperOrigin-RevId: 204505003
|
|
|
|
|
|
|
|
| |
Closes #5307
Closes #5455.
PiperOrigin-RevId: 202567483
|
|
|
|
|
|
|
|
|
|
| |
This will be enforced by annotation processor.
This will be followed up, along with turndown of mandatoryPositionals, by
removing the intepreter code which infers the correct number and type of parameters.
RELNOTES: None.
PiperOrigin-RevId: 202499089
|
|
|
|
|
| |
RELNOTES: None
PiperOrigin-RevId: 202360925
|
|
|
|
|
| |
RELNOTES: None.
PiperOrigin-RevId: 201748802
|
|
|
|
|
|
|
|
|
|
| |
useEnvironment
Unfortunately this doesn't work for all callers, namely NativeInfo objects, as they may have structField callables invoked from contexts that have no environment available.
RELNOTES[INC]: Skylark structs (using struct()) may no longer have to_json and to_proto overridden.
PiperOrigin-RevId: 201376969
|
|
|
|
|
|
|
|
|
| |
Ultimately, we'll need to make the call on whether these functions belong as part of the build API or as part of skylark builtins. For now, we keep them as skylark builtins.
(In either case, we'll want to migrate to @SkylarkCallable, but that's for a later change)
RELNOTES: None.
PiperOrigin-RevId: 200723605
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When pretty printing a Skylark value, lists are presented as the
opening bracket on a line by itself, each entry on its own line,
and the closing bracket again on its own line. While this generally
improves readability, for the empty list this is not the case, as
the expression [] can easily be understood at a glance. In fact, the
additional line even makes the outer structure harder to see, as it
is spread over even more lines. Therefore, shorten the printing of
the empty list to be on a single line.
Change-Id: I032d1550b1f99bce47dbec7e77a4d5c6656d78a1
PiperOrigin-RevId: 200558784
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
repository name is remapped.
For example if main/WORKSPACE contains:
local_repository(
name = "a",
path = "../a",
repo_mapping = {"@x" : "@y"},
)
a/BUILD
load("@x//:sample.bzl", "sample")
Then the load in a/BUILD will be resolved as "@y//:sample.bzl"
RELNOTES: None
PiperOrigin-RevId: 200227431
|
|
|
|
|
|
|
|
|
|
|
|
| |
The high level summary of the changes:
- use `Identifier` instead of `name` in `Keyword` and `Parameter`.
- construct `Identifier` through a factory method in case future interning is desired.
These changes are in preparation for using `Identifier` instead of `name` for environment lookups.
Closes #5304.
PiperOrigin-RevId: 199869171
|
|
|
|
|
|
|
|
|
|
| |
There's only one Token and it gets reused.
This reduces the memory usage of the lexer. Parsing time seems to be 5%-10%
faster with this change on a large file. This makes little difference on the
overall performance of Bazel though.
RELNOTES: None.
PiperOrigin-RevId: 199310860
|
|
|
|
|
|
|
| |
Next step will be to skip token allocation.
RELNOTES: None.
PiperOrigin-RevId: 199121625
|
|
|
|
|
|
|
|
|
|
|
| |
With the recording of the results of repository rules (that
eventually will lead to an implementation of the WORKSPACE.resolved
proposal) bazel started writing out lengthy Skylark values. To make
this file more readable for humans, add a Skylkark printer that
does at least some basic line breaking and indenting.
Change-Id: I469d029421df9212b43747509dd17bd6c64da4a8
PiperOrigin-RevId: 198389112
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This expands on https://github.com/bazelbuild/bazel/commit/33f08e75fa4e7480f8d46b8305ce03a171adefa0 to ensure list-like behavior of range for the following operations
- str/repr/type
- equality and ordering
- append / augmented assignment
- concatenation
- all of the above with slices
This is a prerequisite to both optimizing range() while preserving its current API, as well as changing its API via an incompatible change flag.
RELNOTES: None
PiperOrigin-RevId: 198046941
|
|
|
|
|
|
|
|
|
| |
well-defined.
Moving forward, if a class not already annotated with @SkylarkModule has SkylarkModule supertypes A and B, then it must be the case that A is a type of B, or B is a type of A. The skylark type of a given class is dictated by the *most specific* superclass annotated with @SkylarkModule.
RELNOTES: None.
PiperOrigin-RevId: 197946898
|
|
|
|
|
|
|
| |
This is useful before we optimize range() to return a lazy object that appears like a list to the user.
RELNOTES: None
PiperOrigin-RevId: 197944773
|
|
|
|
|
|
|
| |
with generic parameters
RELNOTES: None.
PiperOrigin-RevId: 197932265
|
|
|
|
|
| |
RELNOTES: None.
PiperOrigin-RevId: 197915097
|
|
|
|
|
|
|
|
|
|
|
|
| |
A bug in the lexer ignored indentation on the first line of a file. This now
causes an error.
Also, remove the COMMENT token from the lexer. Comments are now accessed separately. This will allow further optimizations in the lexer. It also aligns the code a bit more with the Go implementation.
RELNOTES[INC]:
Indentation on the first line of a file was previously ignored. This is now fixed.
PiperOrigin-RevId: 197889775
|
|
|
|
|
| |
RELNOTES: None.
PiperOrigin-RevId: 197881012
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I've pulled out the API for separate review. It includes all
hooks from blaze/skylark used by the debugger.
Debuggable thread contexts are currently declared in 3 places:
- BuildFileAST (top-level evaluation of BUILD files)
- SkylarkRuleConfiguredTargetUtil (rules)
- SkylarkAspectFactory (aspects)
The purpose of declaring these contexts is so that the debugger
can track currently-active threads (and stop tracking them when
the task is completed).
Details of the actual debugging server are in unknown commit.
PiperOrigin-RevId: 197770547
|
|
|
|
|
|
| |
Also consolidate code with getattr so getattr now also gets typo detection.
PiperOrigin-RevId: 197612666
|
|
|
|
|
|
|
|
|
| |
Remove all references to `Token` (except one) in the parser. In particular,
remove the mechanism to push tokens back. This change will make possible for
the lexer to reuse tokens instead of allocating new objects each time.
RELNOTES: None.
PiperOrigin-RevId: 197585185
|
|
|
|
|
|
|
|
| |
With this change, the parser explicitly asks the lexer to give the next token.
To avoid changing the lexer too much, the tokenize() method populates a queue (it may add multiple tokens at the same time). While this reduces the peak memory usage, further work is needed to actually improve the performance.
RELNOTES: None.
PiperOrigin-RevId: 197576326
|
|
|
|
| |
PiperOrigin-RevId: 195040539
|
|
|
|
|
|
|
|
|
| |
This helps the Skylark interpreter to not depend on Bazel concepts, though it adds a temporary dependency of Skylint on packages/. The fix for that will be to create a Build API interface for BazelLibrary (e.g., "BazelLibraryAPI").
Refactored some GlobalFrame construction logic to be more uniform. Instead of constructing a whole Environment just to get a frame, we build the frame directly, using ImmutableMap.Builder to accumulate bindings. This convention may further change once we convert MethodLibrary and the like to @SkylarkGlobalLibrary, but for now it's more readable.
RELNOTES: None
PiperOrigin-RevId: 194960824
|
|
|
|
|
|
|
|
| |
This deprecates the old NativeProvider pattern.
The new pattern is demonstrated using AppleStaticLibraryInfo.
RELNOTES: None.
PiperOrigin-RevId: 194956883
|
|
|
|
|
|
|
|
|
|
|
|
| |
be treated as a callable skylark object.
This will allow Skylark Provider objects to be better specified.
For example, "JavaInfo" can have a fully-documented, fully-specified @SkylarkCallable method with selfCall=true to represent the method JavaInfo(), instead of being a subclass of BaseFunction and requiring a @SkylarkSignature annotation.
There are no usages of this pattern introduced in this CL, and also no updates to docgen to support the new pattern. These will be introduced in another CL.
RELNOTES: None.
PiperOrigin-RevId: 194088227
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the process, clean up SkylarkType-related tests.
- Factor test of EvalUtils.getSkylarkType logic from SkylarkEvaluationTest and ValidationTest to EvalUtilsTest.
- Move test of EvalUtils.getSkylarkType's behavior on lists to SkylarkListTest.
- Move other SkylarkType tests from ValidationTest to new SkylarkTypeTest and split them up a little.
- Throughout, don't use Bazel types like Artifact as test subjects.
RELNOTES: None
PiperOrigin-RevId: 193303463
|
|
|
|
|
|
| |
RELNOTES:
Removed flag `--incompatible_disallow_toplevel_if_statement`.
PiperOrigin-RevId: 192621765
|
|
|
|
|
|
|
| |
StringModule is a special case in a number of places because it represents effectively methods which should be annotated on String.class. However, String may not be subclassed in Java. StringModule thus serves as a proxy module for String.
RELNOTES: None.
PiperOrigin-RevId: 192508607
|
|
|
|
|
|
|
|
|
|
| |
@SkylarkCallable.
@SkylarkSignature.parameters() treat named()=true for parameters regardless of whether named() was actually set to true, and thus for ease of migration we mark migrated parameters as legacyNamed() = true, which is currently semantically equivalent to named() = true.
We make a distinction so that it's easier to bulk fix these later.
RELNOTES: None.
PiperOrigin-RevId: 192477405
|
|
|
|
|
|
|
|
| |
RELNOTES:
The `/` operator is deprecated in favor of `//` (floor integer division).
Try the `--incompatible_disallow_slash_operator` flag to ensure your code
is forward-compatible.
PiperOrigin-RevId: 192430310
|
|
|
|
|
| |
RELNOTES: None
PiperOrigin-RevId: 192337555
|
|
|
|
|
|
|
|
|
| |
parity with @SkylarkSignature.
This is necessary for several builtin functions that still use @SkylarkSignature, such as string format. These will be migrated in a future CL.
RELNOTES: None.
PiperOrigin-RevId: 192200282
|
|
|
|
|
|
|
| |
This involves enforcing additional compiletime restrictions on Param ordering and semantics.
RELNOTES: None.
PiperOrigin-RevId: 191927206
|
|
|
|
| |
PiperOrigin-RevId: 191717115
|
|
|
|
|
|
|
|
|
| |
@SkylarkSignature
Most notably, this involves introduction of a new function abstraction, BuiltinMethod, which can wrap a {objc, SkylarkCallable} pair into a BaseFunction for later calling. (This is required due to the current layer of indirection on the end "native" module)
RELNOTES: None.
PiperOrigin-RevId: 191642467
|
|
|
|
|
| |
RELNOTES: None.
PiperOrigin-RevId: 191641410
|
|
|
|
|
|
|
| |
This is useful for contexts like ctx.actions.args()'s methods, where %d and %r aren't appropriate placeholders.
RELNOTES: None
PiperOrigin-RevId: 191629195
|
|
|
|
|
|
|
| |
of @SkylarkSignature.
RELNOTES: None.
PiperOrigin-RevId: 191112273
|
|
|
|
|
|
|
| |
documented=false.
RELNOTES: None.
PiperOrigin-RevId: 191112140
|
|
|
|
|
| |
RELNOTES: None.
PiperOrigin-RevId: 190823566
|
|
|
|
|
| |
RELNOTES: None.
PiperOrigin-RevId: 190785580
|
|
|
|
|
|
|
| |
Also add tests for leading "+" in int(<string>) form.
RELNOTES: None
PiperOrigin-RevId: 190507678
|
|
|
|
|
|
|
|
| |
*** Reason for rollback ***
Roll-forward with fix (equality and hashcode for relevant classes). Also add a bit more debugging info in case of failure.
PiperOrigin-RevId: 190492934
|
|
|
|
|
|
|
|
|
|
| |
- fix negatives + prefixes
- fix boundary cases (min int value)
The only remaining relevant differences from Python are that we disallow int() with zero args, we don't allow whitespace in strings, and we take Python 3's view on prohibiting leading 0s when base is 0.
RELNOTES: None
PiperOrigin-RevId: 190216646
|
|
|
|
|
|
|
| |
vardef().
RELNOTES: None.
PiperOrigin-RevId: 190196933
|