aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
Commit message (Collapse)AuthorAge
* 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
* Prohibited comparison of Skylark setsGravatar Vladimir Moskva2016-11-08
| | | | | | | RELNOTES: Comparing sets (`if set1 < set2:`) is not allowed anymore in Skylark because it didn't work correctly anyway. -- MOS_MIGRATED_REVID=138408411
* Refactor getParentWithSkylarkModule() into SkylarkInterfaceUtilsGravatar Jon Brandvein2016-10-13
| | | | | -- MOS_MIGRATED_REVID=135956016
* Make EvalUtils.getDataTypeNameFromClass() look for @SkylarkModules in parent ↵Gravatar Jon Brandvein2016-10-12
| | | | | | | | | classes This is needed to let subclasses of @SkylarkModules have the same type() string as their superclass, without requiring a second annotation for the subclass. -- MOS_MIGRATED_REVID=135814343
* Rollback of commit 9c25afe750a937b2152c21a93effc8b9ba82c27b.Gravatar Ulf Adams2016-10-11
| | | | | | | | | | | | | | | *** Reason for rollback *** Seems to break some parts of aspects. *** Original change description *** Make EvalUtils.getDataTypeNameFromClass() look for @SkylarkModules in parent classes This is needed to let subclasses of @SkylarkModules have the same type() string as their superclass, without requiring a second annotation for the subclass (which would lead to redundant documentation being generated). -- MOS_MIGRATED_REVID=135786137
* Make EvalUtils.getDataTypeNameFromClass() look for @SkylarkModules in parent ↵Gravatar Jon Brandvein2016-10-05
| | | | | | | | | classes This is needed to let subclasses of @SkylarkModules have the same type() string as their superclass, without requiring a second annotation for the subclass (which would lead to redundant documentation being generated). -- MOS_MIGRATED_REVID=135161653
* Disallow mutation of values being iterated by a for loop or comprehensionGravatar Jon Brandvein2016-09-28
| | | | | | | | | This entails adding a read-locking mechanism to Mutability contexts. RELNOTES[INC]: Updating list/dicts while they are being looped over is not allowed. Use an explicit copy if needed ("for x in list(mylist):"). -- MOS_MIGRATED_REVID=134442701
* Make SkylarkClassObject "Bazel-specific".Gravatar Dmitry Lomov2016-08-05
| | | | | | | This in preparation to DeclaredProviders implementation. -- MOS_MIGRATED_REVID=129420617
* Simplify immutability testGravatar Jon Brandvein2016-07-29
| | | | | -- MOS_MIGRATED_REVID=128800280
* 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
* Fix small mistakes in some comments.Gravatar Francois-Rene Rideau2016-01-07
| | | | | -- MOS_MIGRATED_REVID=111530554
* Make unsafe list methods non-publicGravatar Laurent Le Brun2015-12-28
| | | | | -- MOS_MIGRATED_REVID=110838816
* 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
* Skylark: implemented all() and any()Gravatar Florian Weikert2015-12-16
| | | | | -- MOS_MIGRATED_REVID=110348607
* Skylark: implemented min() and max().Gravatar Florian Weikert2015-12-13
| | | | | -- MOS_MIGRATED_REVID=110025690
* Use Bazel Preconditions variant which avoids varargs array creationGravatar Mark Schaller2015-12-10
| | | | | | | Reduces garbage. -- MOS_MIGRATED_REVID=109914243
* Compile list literals to byte code.Gravatar Klaas Boesche2015-11-06
| | | | | -- MOS_MIGRATED_REVID=107231604
* Improve error message for select objects ('+' operator for incompatible types)Gravatar Laurent Le Brun2015-11-05
| | | | | -- MOS_MIGRATED_REVID=107131704
* 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
* Separate build-specific types and types inherent to Skylark.Gravatar Lukacs Berki2015-09-21
| | | | | -- MOS_MIGRATED_REVID=103374106
* 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
* Create an abstraction for user defined data types in Skylark.Gravatar Lukacs Berki2015-09-17
| | | | | | | This will be used to remove Blaze-specific data types, FilesetEntry, Label and GlobList from the .syntax package. -- MOS_MIGRATED_REVID=103281375
* Move global objects to RuntimeGravatar Francois-Rene Rideau2015-08-31
| | | | | | | | Move away global constants and global namespaces out of Environment and into a new file Runtime. -- MOS_MIGRATED_REVID=101940218
* Improved error messages for builtin Skylark functions that are invoked with ↵Gravatar Florian Weikert2015-08-12
| | | | | | | invalid arguments. -- MOS_MIGRATED_REVID=100386706
* Changes related to the order of Skylark dictionaries:Gravatar Florian Weikert2015-08-04
| | | | | | | | | - Objects of different types can now be compared. - Printer now prints dictionaries in a deterministic order, even when the keys have different types. - testEval() in EvaluationTestCases evaluates both expressions instead of comparing expression strings. Consequently, if a statement describes a collection, its order does no longer matter when doing the comparison. -- MOS_MIGRATED_REVID=99829458
* 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
* The Order enum now supports the conversion of its values to and from strings.Gravatar Florian Weikert2015-06-10
| | | | | | | This functionality used to be part of SkylarkNestedSet. -- MOS_MIGRATED_REVID=95526136
* Skylark: fix escaping of backslashGravatar Francois-Rene Rideau2015-06-08
| | | | | | | | | | | Create a Printer class into which to eventually move all printing infrastructure currently in EvalUtils. For now, only move string escaping there. Fix the forgotten case of backslash. Allow any style of Python quotes, while we're at it, but keep using simple double-quote as the default. -- MOS_MIGRATED_REVID=95328052
* Simplification in EvalUtils.optionMapGravatar Laurent Le Brun2015-06-05
| | | | | -- MOS_MIGRATED_REVID=95106558
* Improve the way a FuncallExpression is printed while debugging.Gravatar Francois-Rene Rideau2015-05-18
| | | | | -- MOS_MIGRATED_REVID=93908545
* Skylark: type of None is NoneType (instead of None), for consistency with ↵Gravatar Laurent Le Brun2015-05-08
| | | | | | | Python. -- MOS_MIGRATED_REVID=93120393
* Remove old Skylark Function hierarchyGravatar Francois-Rene Rideau2015-04-23
| | | | | | | Last step in refactoring of Skylark builtin functions. -- MOS_MIGRATED_REVID=91796746
* Define a reusable comparator for Skylark objects.Gravatar Laurent Le Brun2015-04-16
| | | | | -- MOS_MIGRATED_REVID=91304912
* 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
* Provide cleaner syntax error messages using select.Gravatar Greg Estren2015-04-10
| | | | | | | | | | | | | | Given: genrule(srcs = ['somefile'] + select({...})) Before this change: ERROR: unsupported operand type(s) for +: 'List' and 'SelectorValue' After this change: ERROR: unsupported operand type(s) for +: 'List' and 'select' -- MOS_MIGRATED_REVID=90750232
* 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: Define dict iteration order (sorted by key).Gravatar Laurent Le Brun2015-03-18
| | | | | -- MOS_MIGRATED_REVID=88924033
* Print singleton tuples with a commaGravatar Francois-Rene Rideau2015-03-18
| | | | | | | | | | Like python, print singleton tuples with a terminating comma before the closing parenthesis, so you can read them back as tuples. Also, have toString() call the pretty-printer for Skylark lists and tuples. -- MOS_MIGRATED_REVID=88831764
* Misc Skylark cleanups and small featuresGravatar Francois-Rene Rideau2015-03-10
| | | | | -- MOS_MIGRATED_REVID=88224368
* Skylark: Show ordering when pretty-printing sets.Gravatar Laurent Le Brun2015-03-10
| | | | | -- MOS_MIGRATED_REVID=88149329
* Restore Skylark "support" for inheritanceGravatar Francois-Rene Rideau2015-03-06
| | | | | | | | | | Classes of the same EvalUtils.getSkylarkType are once again the same for the type inferencer. Also, for debugging purposes, only print SkylarkClassObject as struct, not all classes that implement ClassObject yet are considered disjoint by the type engine. -- MOS_MIGRATED_REVID=87933890
* Some cleanup changes.Gravatar Ulf Adams2015-03-05
| | | | | -- MOS_MIGRATED_REVID=87821306
* Fix race condition in SkylarkType.ofGravatar Francois-Rene Rideau2015-03-05
| | | | | | | | | | | Fix race condition in SkylarkType.of(), whereby .equals() but not same (==) types were created, by making Simple.of() synchronized. Also make SkylarkType#includes() more robust by using .equals() instead of == (it's a little bit slower in the case of Simple types once fixed, but also works on complex types that don't hash-cons their values). Also, distinguish SkylarkList (printed as list) and java.util.List (printed as List) and similarly for tuple vs Tuple, when printing types in debugging messages. -- MOS_MIGRATED_REVID=87490176
* Add Union, contains() to SkylarkTypeGravatar Francois-Rene Rideau2015-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor SkylarkType, notably adding Union types and runtime typechecks. These are pre-requisites to unifying all Skylark function calls to use the same code path, that will check types (like SkylarkFunction currently does) as well handle a more complete Python calling convention (like MixedModeFunction is almost but not quite able to do). A SkylarkType can be either * a Simple type corresponding to a Java class, with special types TOP and BOTTOM corresponding respectively to Object and EmptyType (similar to Void). * a Combination of a generic class (LIST, MAP or SET) and an argument type * a Union of a finite number of types * a FunctionType associated with a name and a returnType (with ugly validation-time side-effects that we should probably move out of the type) Unions are necessary because: 1- the type of some builtin function arguments are actually the Union of some type and a function type for a callback that computes the actual value. 2- the type of some builtin function arguments declared as "List" is actually the Union of java List and SkylarkList. 3- instead of adding lots of special cases at the point of argument validation, it's cleaner and more generally useful to have explicit Union types, that can then be displayed to users for documentation or debugging purposes. Validation-time "type inference" is re-expressed simply as type intersection. None is treated specially as inferred into TOP instead of NoneType. Combination types are printed as genericType of argTypes, e.g. "dict of ints". "type" and "generic1" become "genericType" and "argType". In SkylarkList and SkylarkNestedSet, genericType becomes contentType. -- MOS_MIGRATED_REVID=87340881