aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java
Commit message (Collapse)AuthorAge
* Deprecate and remove several uses of the 'values' map in NativeInfo subclasses.Gravatar cparsons2018-02-28
| | | | | | | | | | These subclasses should be using @SkylarkCallable(structField = true) instead This is a bit of a memory win, as there is now no need to store field information twice. There are still a couple of stragglers that are more difficult, namely ToolchainInfo and DefaultInfo. Their APIs will likely need some more extensive revamping before proceeding. RELNOTES: None. PiperOrigin-RevId: 187364392
* Replace all usages of Blaze's Preconditions class with guava.Gravatar tomlu2017-11-09
| | | | | | | | Blaze had its own class to avoid GC from varargs array creation for the precondition happy path. Guava now (mostly) implements these, making it unnecessary to maintain our own. This change was almost entirely automated by search-and-replace. A few BUILD files needed fixing up since I removed an export of preconditions from lib:util, which was all done by add_deps. There was one incorrect usage of Preconditions that was caught by error prone (which checks Guava's version of Preconditions) that I had to change manually. PiperOrigin-RevId: 175033526
* Micro-optimize mutablelist concatenationGravatar michajlo2017-10-23
| | | | | | | | Avoid ArrayList.addAll(Collection) winds up converting the collection to an array, which is wasteful on such a potentially hot code path. RELNOTES: None PiperOrigin-RevId: 172941634
* Optimize trusted MutableList constructionGravatar michajlo2017-10-18
| | | | | | | | | | | | Cuts back a lot of unnecessary copying. All construction is funneled through copyOf and wrapUnsafe. copyOf is the traditional construction mechanism, taking defensive copies of the input and determining if GlobList information needs to be retained. wrapUnsafe takes full ownership of the supplied ArrayList, allowing us to skip a lot of copies in trusted situations. This is particularly useful for common built in functions which return a list, range() being one common example. RELNOTES: None PiperOrigin-RevId: 172361367
* Migrate from deprecated MutableList constructor to copyOf, fixing bug in latterGravatar michajlo2017-10-06
| | | | PiperOrigin-RevId: 171176871
* Removed unsafe public API methods for mutable types (list/dict)Gravatar brandjon2017-09-28
| | | | | | | Instead of this escape hatch, we'll encourage outside code to construct and use a legitimate Mutability object. RELNOTES: None PiperOrigin-RevId: 170210739
* Cleanup cast methods for SkylarkListGravatar brandjon2017-08-10
| | | | | | | Ensure that the casted list is unmodifiable (both for mutability correctness and also type correctness), and clearly document this. RELNOTES: None PiperOrigin-RevId: 164739837
* In the MutableList API, make an internal unsafe method publicGravatar brandjon2017-08-10
| | | | | | | This method acts as an "escape hatch" for mutating a list regardless of Mutability. It should be avoided if at all possible. RELNOTES: None PiperOrigin-RevId: 164716286
* Add tuple * int multiplication operatorGravatar brandjon2017-08-07
| | | | | | | I.e., ('a', 'b') * 3 == ('a', 'b', 'a', 'b', 'a', 'b'), like lists. RELNOTES: None PiperOrigin-RevId: 164403099
* Fix mutability bug in SkylarkList/SkylarkMap Java APIsGravatar brandjon2017-08-07
| | | | | | | | | Previously, you could modify a frozen MutableList indirectly via its iterator(). This CL wraps the underlying list with a Collections.unmodifiableList when obtaining the iterator, and likewise for other methods that return views over Skylark data structures. This also eliminates the SkylarkList#getContents method in favor of just using the SkylarkList object itself. RELNOTES: None PiperOrigin-RevId: 164402129
* Cleanup SkylarkListGravatar brandjon2017-08-04
| | | | | | | | | | | | | | | - Made abstract collection classes in SkylarkMutable more systematic. Added javadoc. Added a BaseMutableList class to factor out List stubs from SkylarkList. Alphabetized the methods to make it easier to verify that all overrides are covered. - Simplified MutableList constructors. Added MutableList#copyOf factory, and deprecated public access to the existing constructor to be more in line with Guava collections. Made Tuple#create private. - Made mutation methods for MutableList take in mutabilities rather than environments. For symmetry with the other mutators, pushed SkylarkList#set down to MutableList and moved the evaluation of its index to the caller. - Made SkylarkList#getSlice an abstract method that's implemented symmetrically in Tuple and MutableList -- instead of the bizarre thing it was doing before, where its return type was a List that sometimes got passed through SkylarkType.convertToSkylark in the caller. - Removed final modifier on methods where it wasn't obviously appropriate. Removed redundant super() calls. Renamed type variables to always be one letter, and to not reuse the instance's own type variable name from within static methods. RELNOTES: None PiperOrigin-RevId: 164257778
* Make MutableList#EMPTY privateGravatar brandjon2017-08-04
| | | | | RELNOTES: None PiperOrigin-RevId: 164131012
* Cleanup javadoc around Mutability / SkylarkMutableGravatar brandjon2017-08-03
| | | | | | | | | Also throw IllegalArgumentException instead of AssertionError. A follow-up CL will look to eliminate the SkylarkMutable#checkMutable(Location, Environment) override in favor of checkMutable(Location, Mutability). This will make it easier to manipulate Skylark values in specialized contexts aside from normal evaluation. RELNOTES: None PiperOrigin-RevId: 163978262
* Make list EMPTY instance work like tuplesGravatar brandjon2017-08-02
| | | | | | | I.e., use an accessor for type inference. The EMPTY field will be made private in a future CL. RELNOTES: None PiperOrigin-RevId: 163843569
* Misc cleanups of syntax dirGravatar brandjon2017-07-12
| | | | | RELNOTES: None PiperOrigin-RevId: 161560683
* Refactor PrinterGravatar vladmos2017-07-03
| | | | | | | It's now easier to customize Printer if in different situations objects should be printed differently. Also its API is cleaner now. Names of methods of SkylarkValue objects now reflect names of Skylark functions: SkylarkValue#repr and SkylarkPrintableValue#str. PiperOrigin-RevId: 160635154
* Fix int*list binary operator.Gravatar Laurent Le Brun2017-02-09
| | | | | | | | [2] * 3 should return [2, 2, 2] and not [2, 2, 2, 2]. -- PiperOrigin-RevId: 147017581 MOS_MIGRATED_REVID=147017581
* Manually add periods to documentation strings where needed.Gravatar John Cater2017-01-03
| | | | | | | | -- Change-Id: I9ec3209a69ba5a51943b334f278ba93d67d4f9f4 Reviewed-on: https://cr.bazel.build/8090 PiperOrigin-RevId: 143470915 MOS_MIGRATED_REVID=143470915
* New operators for Skylark:Gravatar Andreas Bergmeier2016-12-15
| | | | | | | | | | | | | - list * int - int * list RELNOTES[NEW]: Skylark: you can now multiply a list by an integer to get the concatenation of N copies of this list, e.g. [a,b] * 3 = [a,b,a,b,a,b] -- Change-Id: I2068ad30e11df26dc7b4b8c41e51f85db56f0390 Reviewed-on: https://github.com/bazelbuild/bazel/pull/1524 PiperOrigin-RevId: 142140726 MOS_MIGRATED_REVID=142140726
* Fix bugs in slicing with a negative strideGravatar Jon Brandvein2016-11-14
| | | | | | | | | | | | | | There was a crash when the starting point of a negative slice is larger than the list length. In addition, there was an incorrect result when the ending point of a negative slice is less than the list's length times -1. It would wrongly exclude the first element. RELNOTES: Fix slicing bug where "abc"[:-4:-1] would give wrong answer -- MOS_MIGRATED_REVID=138878716
* Supported "in" operator for all SkylarkIndexable objects.Gravatar Vladimir Moskva2016-10-07
| | | | | -- MOS_MIGRATED_REVID=135483694
* Index and slice calls are implemented as separate AST nodes rather than specialGravatar Vladimir Moskva2016-09-15
| | | | | | | function calls. -- MOS_MIGRATED_REVID=133259901
* Better API for creating immutable Skylark lists.Gravatar Dmitry Lomov2016-09-06
| | | | | -- MOS_MIGRATED_REVID=132226460
* More flexible LValue syntaxGravatar Vladimir Moskva2016-08-23
| | | | | -- MOS_MIGRATED_REVID=131056178
* Minimize ArrayList resizing in MutableList constructionGravatar Michajlo Matijkiw2016-08-11
| | | | | | | | | Specialize the creation of internal contents if we have a collection and can properly presize the ArrayList (this is almost always the case), and provide a special case constructor for concat. -- MOS_MIGRATED_REVID=129919134
* Check that deeply nested values in sets are immutableGravatar Jon Brandvein2016-08-04
| | | | | -- MOS_MIGRATED_REVID=129331086
* Simplify immutability testGravatar Jon Brandvein2016-07-29
| | | | | -- MOS_MIGRATED_REVID=128800280
* Reorganize Skylark Reference documentation.Gravatar Dmitry Lomov2016-06-29
| | | | | -- MOS_MIGRATED_REVID=126081020
* Use Iterables.addAll() in SkylarkList.Gravatar Googler2016-04-15
| | | | | | | | | It is probably more efficient in the common case where the Iterable is a collection. String and list handling in Skylark results in a *lot* of calls to this method, and the use of addAll should reduce the amount of copying and GCing that needs to occur. An alternative would be to change the underlying type of SkylarkList from ArrayList to LinkedList, which would reduce the copying and GCing due to list concatenation even more. There is probably a downside to that but it is not clear if it is significant. -- MOS_MIGRATED_REVID=119891128
* implement list.insert for skylark ruleGravatar Yue Gan2016-04-07
| | | | | | | RELNOTES: implement list.insert for skylark rule -- MOS_MIGRATED_REVID=119243427
* Reinstate mutable maps, again.Gravatar Francois-Rene Rideau2016-02-17
| | | | | -- MOS_MIGRATED_REVID=114860576
* Rollback of commit f941d56acfad5f8c819c81b494f806ea74ea7fd8.Gravatar Carmi Grushko2016-02-02
| | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks many targets, see [] *** Original change description *** Reinstate mutable SkylarkDict Add <String, Object> annotation to optionMap invocation in SkylarkAttr, to make JDK 1.7 happy. Give the visible name "aspect" to class SkylarkAspect. -- MOS_MIGRATED_REVID=113543873
* Reinstate mutable SkylarkDictGravatar Francois-Rene Rideau2016-02-01
| | | | | | | | | | Add <String, Object> annotation to optionMap invocation in SkylarkAttr, to make JDK 1.7 happy. Give the visible name "aspect" to class SkylarkAspect. -- MOS_MIGRATED_REVID=113394826
* Rollback of commit c0a8c58b9230a1f5d76269eb7dc6b11e18f19686.Gravatar Damien Martin-Guillerez2016-01-29
| | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Break Java 1.7 builds of Bazel. See http://ci.bazel.io/job/Bazel/JAVA_VERSION=1.7,PLATFORM_NAME=linux-x86_64/327/console Test: git clone ... && git revert c0a8c58 && export JAVA_VERSION=1.7 && export BAZEL_COMPILE_TARGET=compile && bash -c "source scripts/ci/build.sh; bazel_build" *** Original change description *** Make Skylark dicts mutable Represent Skylark dict using a new subclass SkylarkDict<K, V> of Map<K, V>. Back it with a TreeMap to provide a deterministic iteration order. Also make SkylarkList generic in its element type <E>. Have Artifact implement Comparable<Object> so it can be used as TreeMap key. -- MOS_MIGRATED_REVID=113359718
* Make Skylark dicts mutableGravatar Francois-Rene Rideau2016-01-29
| | | | | | | | | | Represent Skylark dict using a new subclass SkylarkDict<K, V> of Map<K, V>. Back it with a TreeMap to provide a deterministic iteration order. Also make SkylarkList generic in its element type <E>. Have Artifact implement Comparable<Object> so it can be used as TreeMap key. -- MOS_MIGRATED_REVID=113277489
* Make SkylarkList a List.Gravatar Francois-Rene Rideau2016-01-22
| | | | | | | | | | | | | | | SkylarkList now implements the List interfaces, except that its mutating methods throw an UnsupportedOperationException, just like ImmutableList does. To actually mutate a SkylarkList, you need to pass a Location and a suitable Environment object with a matching Mutability while it is still active. Introduce SkylarkMutable and SkylarkMutable.MutableCollection to better handle mutable data structures. Remove some functions in EvalUtils made obsolete by this and previous changes regarding Skylark lists. -- MOS_MIGRATED_REVID=112768457
* Make unsafe list methods non-publicGravatar Laurent Le Brun2015-12-28
| | | | | -- MOS_MIGRATED_REVID=110838816
* Skylark: Slice operations now accept a step argument.Gravatar Florian Weikert2015-12-17
| | | | | -- MOS_MIGRATED_REVID=110446625
* Move annotation classes used for referencing framework Java classes from ↵Gravatar John Field2015-12-16
| | | | | | | | | | | | | | Skylark into their own package. This allows, e.g., classes in the syntax package to access classes in the cmdline package without creating circular dependencies. While we're here: - Removed a couple of unused BUILD deps flagged in []. - Updated SkylarkRuleImplementationFunctionsTest to remove non-ASCII characters and clarify the intent of the test. -- MOS_MIGRATED_REVID=110360763
* Implement list.remove functionGravatar Laurent Le Brun2015-12-16
| | | | | -- MOS_MIGRATED_REVID=110356439
* Workaround javac 1.7 bugGravatar Dmitry Lomov2015-11-19
| | | | | -- MOS_MIGRATED_REVID=108243881
* Compile list literals to byte code.Gravatar Klaas Boesche2015-11-06
| | | | | -- MOS_MIGRATED_REVID=107231604
* Add Skylark support for string_list_dictGravatar Francois-Rene Rideau2015-10-30
| | | | | | | Convert to Skylark values when destructuring a sequence or map. -- MOS_MIGRATED_REVID=106591523
* Unify Skylark and BUILD listsGravatar Francois-Rene Rideau2015-10-20
| | | | | | | | Use SkylarkList everywhere rather than either List or GlobList. Keep a GlobList underneath a MutableList, where applicable. -- MOS_MIGRATED_REVID=105864035
* Rationalize copyright headersGravatar Damien Martin-Guillerez2015-09-25
| | | | | | | | | | | The headers were modified with `find . -type f -exec 'sed' '-Ei' 's|Copyright 201([45]) Google|Copyright 201\1 The Bazel Authors|' '{}' ';'` And manual edit for not Google owned copyright. Because of the nature of ijar, I did not modified the header of file owned by Alan Donovan. The list of authors were extracted from the git log. It is missing older Google contributors that can be added on-demand. -- MOS_MIGRATED_REVID=103938715
* Refactor SkylarkList to allow MutableListGravatar Francois-Rene Rideau2015-09-21
| | | | | | | | Make SkylarkList no longer read-only to match Python and the BUILD language. Instead, subject it to a Mutability object inherited from the Environment. -- MOS_MIGRATED_REVID=103332973
* Cleanup Skylark types some moreGravatar Francois-Rene Rideau2015-09-17
| | | | | | | | | | | Clarify the criterion for being a valid Skylark value; stop claiming immutability is "the" criterion when Skylark now has mutable values; stop relying on a reflection with a magic list (this also fixes the SkylarkShell build). Clarify the criterion for determining immutable types when making a SkylarkNestedSet. Clarify and use the criterion for being a valid Skylark dict key. -- MOS_MIGRATED_REVID=103313934
* Allow heterogeneous lists in Skylark.Gravatar Laurent Le Brun2015-08-11
| | | | | | | | | This brings consistency between BUILD and Skylark interpreters. It also brings consistency with dicts (e.g. **kwargs can contain anything and kwargs.values is allowed). -- MOS_MIGRATED_REVID=100278980
* Implement Skylark function reprGravatar Francois-Rene Rideau2015-06-15
| | | | | | | | | | | | | | | | | Move printing code from EvalUtils to Printer. Rename functions in Printer: printValue becomes str or print, prettyPrintValue becomes repr or write, formatString becomes format, makeFormattable becomes strFormattable, prettyPrintValues becomes listString. write being self-sufficient is made the reference, and print is the one that is a wrapper around write, rather than the other way around, avoiding mutual recursion. -- MOS_MIGRATED_REVID=95897834
* Fix SkylarkList#equalsGravatar Francois-Rene Rideau2015-04-27
| | | | | -- MOS_MIGRATED_REVID=92063536