aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
Commit message (Collapse)AuthorAge
* Clean up string representations for functionsGravatar vladmos2017-07-07
| | | | | | | | | If --incompatible_descriptive_string_representations is passed, functions and rule classes are converted to strings using `str`, `repr` and `print` functions differently (more descriptive, without leaking information that shouldn't be accessible). PiperOrigin-RevId: 161087777
* Refactor "isMutable" -> "isFrozen"Gravatar brandjon2017-05-04
| | | | | | | | | This helps readability, particularly since we also have "isImmutable" for SkylarkValues and in EvalUtils. I considered changing those to isFrozen as well, but we can leave it as-is since the terminology of freezing doesn't necessarily apply to non-Freezable things. Also rephrased some javadoc. RELNOTES: None PiperOrigin-RevId: 155090987
* 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
* Automated cleanupGravatar Laurent Le Brun2016-10-12
| | | | | -- MOS_MIGRATED_REVID=135816105
* Roll forward of commit 19db71413329da3f5d22b5fc7681471f3d971d88 (Skylark: ↵Gravatar Florian Weikert2016-09-06
| | | | | | | | | | | | | Replaced late bound attributes with computed default attributes) with two bug fixes: 1. Unlike SkylarkComputedDefault, SkylarkComputedDefaultTemplate did not sort the names of its attribute dependencies. Consequently, lookup operations failed when callback functions in bzl files specified the names of their required attributes in a non-alphabetical order since the order of the key tuples was different (e.g. [1, 2] vs [2, 1]). It would be less error prone to always sort the dependencies in createDependencyAssignmentTuple(), but this would impact performance. 2. SkylarkCallbackFunction ignores the legacy "cfg" parameter in callback functions. This special case should be deleted once all cfg parameters have been removed from the depot. -- MOS_MIGRATED_REVID=132235927
* Rollback of commit 19db71413329da3f5d22b5fc7681471f3d971d88.Gravatar Tobias Werth2016-09-06
| | | | | -- MOS_MIGRATED_REVID=132058819
* Skylark: Replaced late bound attributes with computed default attributesGravatar Mark Schaller2016-09-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: Compared to computed default attributes, late bound attributes are evaluated in a later phase (analysis instead of loading phase). While both mechanisms provide access to other attributes of a rule, only late bound attributes additionally provide access to the build configuration. However, late bound attributes could be used to return new labels that have not been loaded before. Since this happens in the analysis phase, it can break one of Blaze's underlying principles, thus introducing a serious correctness bug. We decided to replace late bound attributes in Skylark with computed default attributes since this moves the evaluation of values into the loading phase, thus fixing this bug. Moreover, none of the existing users of this mechanism required access to the build configuration, which means that the user impact of this change is minimal. Implementation details: Unlike attributes of non-Skylark rules, however, Skylark computed defaults need to be able to depend on more than two configurable attributes since all attributes of Skylark rules are configurable by default. This has two implications: 1. Unlike "normal" Skylark attributes, Skylark computed defaults need to know about the existence of other attributes in order to declare a dependency on them. This CL takes advantage of work previously done to require parameter names to be the names of attributes used by the computed default function. 2. Since Bazel computes the combinations of all possible attribute values, a Skylark rule with a computed default that depends on a lot of configurable attributes could crash Bazel. Consequently, this CL also introduces an upper bound (64) for the number of valid combinations. Caveats: 1. Getting the depended-on attributes' names from function paramters is mildly surprising. Alternatives: The best solution would be to keep SkylarkLateBound, but restrict it in a way that it can only return already loaded labels. This is not possible right now. -- MOS_MIGRATED_REVID=131967238
* Only include name for UserDefinedFunctionProfilingGravatar Michajlo Matijkiw2016-07-14
| | | | | | | | | | | These are called rather frequently I would imagine, but we don't profile often. Avoid useless object allocation. The SKYLARK_USER_FN qualifier and function name _should_ be enough to identify what's what, though I understand there could be duplicates. If this turns out to be an issue we can add more detail by memoizing location + name, but for now I'm inclined to treat it as YAGNI. -- MOS_MIGRATED_REVID=127328480
* Add profiler support for compiled Skylark.Gravatar Florian Weikert2015-11-10
| | | | | -- MOS_MIGRATED_REVID=107416625
* 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
* Add initial Skylark byte code generation code.Gravatar Klaas Boesche2015-11-06
| | | | | | | | Does not yet contain any implementation for expressions and statements but sets up various needed mechanisms and helper classes. -- MOS_MIGRATED_REVID=107222845
* Skylark interpreter optimizationGravatar Laurent Le Brun2015-10-28
| | | | | | | Special-case the return statement to avoid throwing an exception. -- MOS_MIGRATED_REVID=106488391
* 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
* Fixed Skylark stack trace:Gravatar Florian Weikert2015-09-11
| | | | | | | | | - Moved registration mechanism from BaseFunction into ASTNode / Statement / Expression - Added more details about statements/expressions to the output trace (including if's) - Fixed wrong locations -- MOS_MIGRATED_REVID=102841164
* 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
* Save subtasks for Skylark function profiler tasks and then report self time ↵Gravatar Klaas Boesche2015-09-09
| | | | | | | of function calls in HTML output -- MOS_MIGRATED_REVID=102663672
* 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
* Show a column with the location of a skylark function in HTML profiling ↵Gravatar Googler2015-09-02
| | | | | | | statistics. -- MOS_MIGRATED_REVID=102143715
* When a Skylark macro creates a native rule, it also sets the following rule ↵Gravatar Florian Weikert2015-09-02
| | | | | | | attributes: generator_{function, name, location} -- MOS_MIGRATED_REVID=102139196
* 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
* Roll back "When a Skylark macro creates a native rule, it also..."Gravatar Michajlo Matijkiw2015-08-31
| | | | | -- MOS_MIGRATED_REVID=101798931
* When a Skylark macro creates a native rule, it also sets the following rule ↵Gravatar Florian Weikert2015-08-28
| | | | | | | attributes: generator_{function, name, location} -- MOS_MIGRATED_REVID=101774632
* Add profiling for Skylark lexer, parser, user- and built-in functions.Gravatar Googler2015-08-28
| | | | | -- MOS_MIGRATED_REVID=101769963
* Skylark stack traces are now displayed in Python format.Gravatar Florian Weikert2015-08-27
| | | | | -- MOS_MIGRATED_REVID=101572295
* Skylark error messages now include a stack trace.Gravatar Florian Weikert2015-08-20
| | | | | | | This means that some tests had to be changed from using exact equality of error messages to working with contains() / startsWith(). -- MOS_MIGRATED_REVID=100923593
* Improved error messages for builtin Skylark functions that are invoked with ↵Gravatar Florian Weikert2015-08-12
| | | | | | | invalid arguments. -- MOS_MIGRATED_REVID=100386706
* Renamed Ident to Identifier, added some helper methods and refactored two ↵Gravatar Florian Weikert2015-07-23
| | | | | | | methods. -- MOS_MIGRATED_REVID=98922811
* New class hierarchy for Skylark functionsGravatar Francois-Rene Rideau2015-03-20
| | | | | | | | | | | | | | | | | | | | | | | | | | * New hierarchy BaseFunction > UserModeFunction, BuiltinFunction. The old hierarchy still exists for now, to be deleted after migration: Function > AbstractFunction > MixedModeFunction > (UserModeFunction, SkylarkFunction > SimpleSkylarkFunction) (UserModeFunction is already migrated, and BaseFunction implements Function, for now.) * Function supports *args and **kwargs when calling functions, and mandatory named-only parameters in the style of Python 3. Notable difference with Python: *args binds the variable to a tuple, because a Skylark list would have to be monomorphic. * A better, simpler, safer FFI using reflection with BuiltinFunction. Handles typechecking, passes parameters in a more Java style. (Not used for now, will be used later.) * A new annotation @SkylarkSignature, intended to replace @SkylarkBuiltin, supports the full function call protocol, including default arguments. * Support for annotating function Factory-s rather than functions. -- MOS_MIGRATED_REVID=88958581
* Introduce first class function signatures; make the parser use them.Gravatar Francois-Rene Rideau2015-02-19
| | | | | | | | | | | | | | | | | | | This is the first meaty cl in a series to refactor the Skylark function call protocol. 1- We introduce a first-class notion of FunctionSignature, that supports positional and named-only arguments, mandatory and optional, default values, type-checking, *stararg and **kwarg; 2- To keep things clean, we distinguish two different kinds of Argument's: Argument.Passed that appears in function calls, and Parameter, that appears in function definitions. 3- We refactor the Parser so it uses this infrastructure, and make minimal changes to MixedModeFunction so that it works with it (but don't actually implement *starparam and **kwparam yet). 4- As we modify FuncallExpression, we ensure that the args and kwargs arguments it passes to the underlying function are immutable, as a prerequisite to upcoming implementation of *starparam and **kwparam as being provided directly from a skylark list or dict. Further changes under review will take advantage of this FunctionSignature to redo all our function call protocol, to be used uniformly for both UserDefinedFunction's and builtin function. The result will be a simpler inheritance model, with better type-checking, builtin functions that are both simpler and better documented, and many redundant competing functionality-limited codepaths being merged and replaced by something better. NB: The changes to MixedModeFunction, SkylarkFunction and MethodLibrary are temporary hacks to be done away with in an upcoming CL. The rest is the actual changes. -- MOS_MIGRATED_REVID=86704072
* Update from Google.Gravatar Han-Wen Nienhuys2015-02-25
-- MOE_MIGRATED_REVID=85702957