aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/LValue.java
Commit message (Collapse)AuthorAge
* Replaces JavaSerializableCodec with DynamicCodec as the defaultGravatar shahan2018-04-04
| | | | | | | | | * Skylark serialization was previously dropping location in error, which this fixes. * Deletes a lot of codecs with fidelity issues (DynamicCodec has full fidelity). * Deletes EnumRuntimeCodec which can now be replaced with the superior EnumCodec. * This should eventually allow us to delete Serializable from all Blaze. The remaining blocker is NoSuchPackageExceptionCodec. PiperOrigin-RevId: 191603929
* Get rid of almost all Skylark codecs. We need to introduce a wrapper to turn ↵Gravatar janakr2018-03-03
| | | | | | | | ObjectCodec into a MEMOIZE_AFTER MemoizingCodec. I think that this is safe, because all the codecs that are being wrapped this way weren't memoizing anything internally that I could see. In order to @AutoCodec the WithValue type, which is generic and can have null elements in lists, add functionality to @AutoCodec to deal with generic type static instantiators, matching generic type arguments (although I'm not sure why that wasn't already working), and null elements in lists. PiperOrigin-RevId: 187740461
* Optimize LValue#boundIdentifiers for common caseGravatar michajlo2018-02-26
| | | | | | | | | | I'm assuming most of the time folks are only assigning one variable, which doesn't require an ImmutableSet.Builder and the garbage it comes with. Also took the liberty of removing some unused InterruptedException declarations. PiperOrigin-RevId: 187068400
* 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
* Change Identifier#boundNames to #boundIdentifiers.Gravatar fzaiser2017-08-28
| | | | | RELNOTES: None PiperOrigin-RevId: 166704851
* Remove validate() methods in the AST, use a visitor instead.Gravatar laurentlb2017-08-18
| | | | | | | This is a simple refactoring, no change in behavior. RELNOTES: None. PiperOrigin-RevId: 165572028
* 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
* Refactor augmented assignment and lvaluesGravatar brandjon2017-07-26
| | | | | | | Also fix minor bug where a[b] += c would evaluate b twice. RELNOTES: None PiperOrigin-RevId: 163103618
* Require LValues to have at least one variable.Gravatar laurentlb2017-07-06
| | | | | | | | | | | | In other words, we now forbid these: [] = [] () = () _, [] = f() RELNOTES[INC]: lvalues must have define at least one variable (i.e. we forbid `[] = f()`). PiperOrigin-RevId: 160981283
* Add a pretty printer for Skylark ASTsGravatar brandjon2017-06-28
| | | | | | | This can be used to canonically compare ASTs for equality, e.g. in tests. RELNOTES: None PiperOrigin-RevId: 160283160
* Introduce --incompatible_depset_is_not_iterableGravatar laurentlb2017-06-21
| | | | | | | RELNOTES: Iterating on a `depset` object is deprecated. If you need an iterable, call the `.to_list()` method first. PiperOrigin-RevId: 159672887
* Refactor comprehensions and other AST nodesGravatar brandjon2017-05-15
| | | | | | | | | | * Cleanup ForClause and IfClause to be static classes * Add missing/non-visible accessors and constructors * Make use of final modifiers more consistent * Make LValue an ASTNode. RELNOTES: None PiperOrigin-RevId: 156050683
* Implement a flag for extend-like behavior of the `+=` operator for listsGravatar vladmos2017-05-04
| | | | | Usage: --incompatible_list_plus_equals=true (the default value is false). PiperOrigin-RevId: 155084916
* Rollback of commit 34ffc4cab1b6cdde54e5945427b79c24fff39aa5.Gravatar Dmitry Lomov2017-03-02
| | | | | | | | | | | | | | *** Reason for rollback *** Roll-forward of commit 01120026dc313ee7ad9ea95069a29252eb19173b with fix. *** Original change description *** Automated [] rollback of commit 01120026dc313ee7ad9ea95069a29252eb19173b. -- PiperOrigin-RevId: 148897534 MOS_MIGRATED_REVID=148897534
* Rollback of commit 01120026dc313ee7ad9ea95069a29252eb19173b.Gravatar Jon Brandvein2017-03-01
| | | | | | -- PiperOrigin-RevId: 148888469 MOS_MIGRATED_REVID=148888469
* Export exportable values as we go instead of at the end of evaluation.Gravatar Dmitry Lomov2017-03-01
| | | | | | | | | This simplifies implementation of attr.* functions and helps make declared provider implementation simpler. -- PiperOrigin-RevId: 148867326 MOS_MIGRATED_REVID=148867326
* Augmented assignments don't evaluate lhs multiple timesGravatar Vladimir Moskva2017-02-21
| | | | | | -- PiperOrigin-RevId: 148092963 MOS_MIGRATED_REVID=148092963
* Delete the bytecode compiler experiment.Gravatar Laurent Le Brun2017-01-23
| | | | | | | | | The code has been untouched and unused for over a year (it's very likely broken) and we have other priorities for now. -- PiperOrigin-RevId: 145087310 MOS_MIGRATED_REVID=145087310
* Fix a bunch of typosGravatar Jon Brandvein2016-11-10
| | | | | -- MOS_MIGRATED_REVID=138757881
* Change error message to reflect broader syntax for assignmentsGravatar Jon Brandvein2016-11-10
| | | | | -- MOS_MIGRATED_REVID=138700111
* Index and slice calls are implemented as separate AST nodes rather than specialGravatar Vladimir Moskva2016-09-15
| | | | | | | function calls. -- MOS_MIGRATED_REVID=133262955
* Index and slice calls are implemented as separate AST nodes rather than specialGravatar Vladimir Moskva2016-09-15
| | | | | | | function calls. -- MOS_MIGRATED_REVID=133259901
* More flexible LValue syntaxGravatar Vladimir Moskva2016-08-23
| | | | | -- MOS_MIGRATED_REVID=131056178
* 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
* Remove syntactic sugar when assigning to a dict item.Gravatar Laurent Le Brun2016-01-07
| | | | | | | | | | | | | | e.g. a['key'] = value is handled through a proper lvalue, instead of using syntactic sugar. Benefits include: - better error messages (reference to the '+' operator was cryptic) - more robust, e.g. it is compatible with the += operator - can be used in a tuple, e.g. a[1], a[2] = 3, 4 - it is a step towards mutable dict -- MOS_MIGRATED_REVID=111597545
* Cleanup, code simplification, remove env.isSkylarkGravatar Laurent Le Brun2015-12-28
| | | | | -- MOS_MIGRATED_REVID=110836326
* Use Bazel Preconditions variant which avoids varargs array creationGravatar Mark Schaller2015-12-10
| | | | | | | Reduces garbage. -- MOS_MIGRATED_REVID=109914243
* Compile function call expressions.Gravatar Florian Weikert2015-11-10
| | | | | | | Mostly reuses the interpreters argument checking and helper functions. -- MOS_MIGRATED_REVID=107395974
* Compile assignments to byte code and throw errors.Gravatar Florian Weikert2015-11-10
| | | | | | | | Add EvalExceptions for cases in which the interpreter would throw them during evaluation of the function definition. -- MOS_MIGRATED_REVID=107376021
* 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 Skylark Environment-sGravatar Francois-Rene Rideau2015-09-11
| | | | | | | | | | | | | | | | | | | | Make Environment-s freezable: Introduce a class Mutability as a revokable capability to mutate objects in an Environment. For now, only Environment-s carry this capability. Make sure that every Mutability is revoked in the same function that create... This reinstates a change that previously rolled-back because it broke the serializability of SkylarkLookupValue. Bad news: serializing it succeeds for the wrong reason, because a SkylarkEnvironment was stored as a result (now an Environment.Extension) that was Serializable but inherited its bindings from an Environment (now an Environment.BaseExtension) which wasn't Serializable. Apparently, Java doesn't try to serialize the bindings then (or at least doesn't error out when it fails), because these bindings map variable names to pretty arbitrary objects, and a lot of those we find in practice aren't Serializable. Thus the current code passes the same tests as the previous code, but obviously the serialization is just as ineffective as it used to be. -- MOS_MIGRATED_REVID=102776694
* Rollback of commit 5a94e59f02833f9142bad9203acd72626b089535.Gravatar Janak Ramakrishnan2015-09-08
| | | | | | | | | *** Reason for rollback *** Breaks serialization of SkyValues. -- MOS_MIGRATED_REVID=102457225
* Refactor Skylark Environment-sGravatar Francois-Rene Rideau2015-09-08
| | | | | | | | | | | | | | | | | Make Environment-s freezable: Introduce a class Mutability as a revokable capability to mutate objects in an Environment. For now, only Environment-s carry this capability. Make sure that every Mutability is revoked in the same function that creates it, so no Environment is left open for modification after being created and exported; exceptions for tests, the shell and initialization contexts. Unify Environment, SkylarkEnvironment and EvaluationContext into Environment. Have a notion of Frame for the bindings + parent + mutability. Replace the updateAndPropagate mechanism by a dynamicFrame. Simplify ValidationEnvironment, that is now always deduced from the Environment. -- MOS_MIGRATED_REVID=102363438
* Rename isSkylarkEnabled to isSkylarkGravatar Francois-Rene Rideau2015-08-26
| | | | | -- MOS_MIGRATED_REVID=101518833
* Renamed Ident to Identifier, added some helper methods and refactored two ↵Gravatar Florian Weikert2015-07-23
| | | | | | | methods. -- MOS_MIGRATED_REVID=98922811
* Skylark: Allow variable reassignment to change the type of a variable.Gravatar Laurent Le Brun2015-06-18
| | | | | -- MOS_MIGRATED_REVID=96211360
* Skylark: support %r format specifierGravatar Francois-Rene Rideau2015-06-17
| | | | | | | | Refactor the implementation of format. Add %r. Improve some error messages. -- MOS_MIGRATED_REVID=96154542
* 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
* Allow if filtering in list comprehensionsGravatar Laurent Le Brun2015-05-18
| | | | | -- MOS_MIGRATED_REVID=93881507
* Skylark: Remove static type checking of variables/functions.Gravatar Laurent Le Brun2015-04-13
| | | | | | | | There are still some static checks (check existence of variable/function, readonly variables, etc.). More cleanup will come later. -- MOS_MIGRATED_REVID=90979748
* Simplify Skylark testsGravatar Francois-Rene Rideau2015-04-13
| | | | | | | | | | | | | | | | | | Use the new EvaluationContext infrastructure to simplify Skylark tests (said infrastructure is originally based on code from these tests). Merge AbstractEvaluationTestCase and AbstractParserTestCase into a non-abstract class EvaluationTestCase that uses EvaluationContext. Cleanup the EventCollectionApparatus it uses. Refactor all Skylark tests to use this new infrastructure. Fix EvaluationTest and MethodLibraryTest to actually and correctly run tests in both modes. Fix small bugs in the main code base discovered by actually running the code in both modes, and make error messages identical when possible. -- MOS_MIGRATED_REVID=90828053
* Enable support for multiple variable assignments.Gravatar Laurent Le Brun2015-03-23
| | | | | | | | | | This happens in for loops, list comprehensions and simple assigment. e.g. a, b = expr [a for a, b in expr] -- MOS_MIGRATED_REVID=89123977
* Skylark: Use LValue class in loops and comprehensions.Gravatar Laurent Le Brun2015-03-20
| | | | | -- MOS_MIGRATED_REVID=89020190
* Refactoring: Introduce a new class LValue.Gravatar Laurent Le Brun2015-03-20
This CL is just moving code from AssignmentStatement to a new class. The goal is to share code dealing with LValues. LValues can be found here: - lvalue = 2 - [for lvalue in exp] - {a: b for lvalue in exp] - for lvalue in exp: pass The LValue itself can have different forms: - a - a, b - a[0] - a, (b, c) - [a[0], (b, c)] - a[1:5] Although we may not handle everything, we need to make sure that the same things can be used in variable assignment and in for loops. -- MOS_MIGRATED_REVID=89015483