aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
Commit message (Collapse)AuthorAge
* Add debugging helper to Environment.Extension to say why something's unequalGravatar brandjon2018-02-06
| | | | | RELNOTES: None PiperOrigin-RevId: 184649483
* 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
* Optimize recursive call detectionGravatar michajlo2017-10-24
| | | | | | | No need to contruct a list for each function call RELNOTES: None PiperOrigin-RevId: 173144689
* Require semantics field for Environment.BuilderGravatar brandjon2017-10-23
| | | | | | | Follow-up of unknown commit. RELNOTES: None PiperOrigin-RevId: 172922507
* Be explicit about semantics of Skylark environmentsGravatar brandjon2017-10-23
| | | | | | | | | All callers that do not use Environment.Builder#setSemantics should call #useDefaultSemantics. A follow-up CL will enforce this requirement. Motivation: It's more important that we are strict about semantics than about the other builder args. It's too easy for a mistake in semantics to go unnoticed. RELNOTES: None PiperOrigin-RevId: 172912829
* Add useDefaultSemantics() to Enviornment.BuilderGravatar brandjon2017-10-20
| | | | | RELNOTES: None PiperOrigin-RevId: 172801656
* Pass SkylarkSemantics through Skyframe instead of the options classGravatar brandjon2017-10-06
| | | | | | | Also remove the use of the @UsesOnlyCoreTypes annotation on SkylarkSemanticsOptions. It was only there to help mark that the options class was safe to put in Skyframe. RELNOTES: None PiperOrigin-RevId: 171248504
* Use SkylarkSemantics in place of options class in the interpreterGravatar brandjon2017-10-06
| | | | | | | Mainly this just means using getters instead of fields to access option values. RELNOTES: None PiperOrigin-RevId: 171101597
* Clarify Mutability invariants, refactor some testsGravatar brandjon2017-09-29
| | | | | RELNOTES: None PiperOrigin-RevId: 170343759
* Add a way to construct Frames in a two-step processGravatar brandjon2017-08-29
| | | | | RELNOTES: None PiperOrigin-RevId: 166857589
* 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
* Clean up a few Skylark-Skyframe structuresGravatar brandjon2017-07-19
| | | | | | | Add value-class methods to SkylarkFileDependency and SkylarkImportLookupValue. Remove Java serialization hack from Extension. RELNOTES: None PiperOrigin-RevId: 162383283
* Fix crash when unioning depsets with different ordersGravatar brandjon2017-07-14
| | | | | | | Also refactor FAIL_FAST_HANDLER to throw something more specific than IllegalArgumentException. This bug was masked because the test assertion that would've caught it considered IllegalArgumentException to be an expected error, the same as EvalException. RELNOTES: None PiperOrigin-RevId: 161809957
* 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
* 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_comprehension_variables_do_not_leakGravatar laurentlb2017-06-14
| | | | | | | | | | | | | When the flag is activated, variables in list comprehensions do not leak anymore. Even if a variable was defined before the loop, it's not accessible after the loop. This change allows us to detect any breakage and ensures that no user is accessing loop variables after the loop. This will make possible for us to change the behavior and follow Python 3 semantics in the future. RELNOTES: None. PiperOrigin-RevId: 158895514
* Clean up API for the Extension classGravatar brandjon2017-05-09
| | | | | RELNOTES: None PiperOrigin-RevId: 155507750
* Clean up Environment.FrameGravatar brandjon2017-05-09
| | | | | | | | | Make fields visibility/accessors more idiomatic. Prefer accessors that give a full map of the bindings and inherited bindings, rather than just the keys. Also increase visibility of some accessors on Mutability. RELNOTES: None PiperOrigin-RevId: 155393780
* 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
* Make Skylark interpreter read Skylark command-line flagsGravatar brandjon2017-04-30
| | | | | | | | | | | This is the second of two CLs for making command line options able to affect the Skylark interpreter. For the main kinds of evaluation contexts -- package loading, .bzl loading, rule analysis, aspect analysis, and computed defaults -- the SkylarkSemanticsOptions object is retrieved from Skyframe and passed along to the Environment builder. For other contexts such as tests, default values of builtin functions, and standalone Skylark, flags are currently not processed. In the future, we may want to split into separate files the options that affect "pure" Skylark vs the options that affect Bazel-flavored Skylark. One possibility is to subclass SkylarkSemanticsOptions into SkylarkBazelSemanticsOptions, and go through an indirection in SkylarkUtils. We could also pass SkylarkSemanticsOptions to the parser, to support --incompatible_* changes that alter Skylark's syntax. I don't think that's needed at the moment. RELNOTES: None PiperOrigin-RevId: 154628391
* Make frame bindings use LinkedHashMap for determinismGravatar Jon Brandvein2017-01-19
| | | | | | | | | This matters when the same rule (or other exportable) is bound to multiple variables, since the identifier of the first variable will become its name. -- PiperOrigin-RevId: 144881310 MOS_MIGRATED_REVID=144881310
* Add 'did you mean' suggestion for load() statements.Gravatar Laurent Le Brun2017-01-03
| | | | | | -- PiperOrigin-RevId: 143381556 MOS_MIGRATED_REVID=143381556
* Add 'did you mean' suggestion when accessing an undefined variable.Gravatar Laurent Le Brun2017-01-03
| | | | | | -- PiperOrigin-RevId: 143373605 MOS_MIGRATED_REVID=143373605
* Rollback of commit 7c4a8093da6272969c86f22a08c72ddbbf6e8274.Gravatar Kristina Chodorow2016-12-02
| | | | | | | | | | | | | | | | | *** Reason for rollback *** Broke //src/test/shell/bazel:external_skylark_load_test See http://ci.bazel.io/job/bazel-tests/BAZEL_VERSION=HEAD,PLATFORM_NAME=linux-x86_64/370/console, for example. *** Original change description *** Remove callerLabel from Environment. It is a Bazel-specific information. -- MOS_MIGRATED_REVID=140742037
* Remove callerLabel from Environment.Gravatar Laurent Le Brun2016-12-01
| | | | | | | It is a Bazel-specific information. -- MOS_MIGRATED_REVID=140719791
* Remove isSkylark and eval from Environment.Gravatar Laurent Le Brun2016-11-29
| | | | | -- MOS_MIGRATED_REVID=140371603
* Remove Environment.parseFileGravatar Laurent Le Brun2016-11-23
| | | | | -- MOS_MIGRATED_REVID=140037282
* Minor refactoring in SkylarkUtilsGravatar Laurent Le Brun2016-11-22
| | | | | | | Next step will be to move Environment.Phase to SkylarkUtils.BazelInfo -- MOS_MIGRATED_REVID=139902745
* Fix a bunch of typosGravatar Jon Brandvein2016-11-10
| | | | | -- MOS_MIGRATED_REVID=138757881
* Move ToolsRepository out of EnvironmentGravatar Laurent Le Brun2016-10-27
| | | | | | | | | Other fields will follow (is_skylark, phase, callerLabel). The goal is to make Environment (and more generally Skylark) less dependent on Bazel. -- MOS_MIGRATED_REVID=137386248
* Cleanup: remove isSkylark in Environment ContinuationGravatar Laurent Le Brun2016-10-27
| | | | | -- MOS_MIGRATED_REVID=137272887
* Cleanup in Environment, remove unused lookup functionGravatar Laurent Le Brun2016-10-27
| | | | | -- MOS_MIGRATED_REVID=137266170
* Cleanup, remove differences between Build and Skylark environments.Gravatar Laurent Le Brun2016-10-14
| | | | | | | | | | | | | The only visible difference for users is that a few more functions are available in BUILD files. That's fine, this difference was not even documented. RELNOTES: A few functions are added to BUILD files for consistency (hash, dir, hasattr, getattr) with .bzl files, although they are not very useful. -- MOS_MIGRATED_REVID=136151633
* Automated cleanupGravatar Laurent Le Brun2016-10-12
| | | | | -- MOS_MIGRATED_REVID=135816105
* Remove support for "Python" parsing mode.Gravatar Laurent Le Brun2016-10-07
| | | | | | | It was unused in Bazel. -- MOS_MIGRATED_REVID=135483937
* Deprecation warnings for deprecated syntaxGravatar Vladimir Moskva2016-09-16
| | | | | | | | | RELNOTES: Global varaiables HOST_CFG and DATA_CFG are deprecated in favor of strings "host" and "data. Argument `cfg = "host"` or `cfg = "data"` is mandatory if `executable = True` is provided for a label. -- MOS_MIGRATED_REVID=133285197
* Move SkylarkImport from LoadStatement to BuildFileASTGravatar Miguel Alcon Pinto2016-08-22
| | | | | | | This allow us to skip the import validation in non-build usages. -- MOS_MIGRATED_REVID=130936612
* Roll forward fix of global var shadow detectionGravatar Jon Brandvein2016-08-12
| | | | | | | RELNOTES[INC]: Skylark: It is an error to shadow a global variable with a local variable after the global has already been accessed in the function. -- MOS_MIGRATED_REVID=130014492
* Rollback of commit 6aa2f64045d390f4da77d396cd3fcbe1c44a98c1.Gravatar Chris Parsons2016-08-11
| | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks release. *** *** Original change description *** Fix Environment.Continuation's tracking of global variables RELNOTES[INC]: Skylark: It is an error to shadow a global variable with a local variable after the global has already been accessed in the function. -- MOS_MIGRATED_REVID=129910501
* Substituted NoSuchVariableException with manual checks for performance purposesGravatar Vladimir Moskva2016-08-11
| | | | | -- MOS_MIGRATED_REVID=129869968
* Fix Environment.Continuation's tracking of global variablesGravatar Jon Brandvein2016-08-05
| | | | | | | RELNOTES[INC]: Skylark: It is an error to shadow a global variable with a local variable after the global has already been accessed in the function. -- MOS_MIGRATED_REVID=129365195
* Remove static checks from the parser.Gravatar Laurent Le Brun2016-08-04
| | | | | -- MOS_MIGRATED_REVID=129313959
* Preliminary cleanup for removing Blaze-specific code from the environmentGravatar Laurent Le Brun2016-08-03
| | | | | | | | The goal is to remove parse and eval functions from Environment, as well as isSkylark boolean. -- MOS_MIGRATED_REVID=129202204
* Lazily construct NoSuchVariableException messageGravatar Michajlo Matijkiw2016-08-01
| | | | | | | Code typically doesn't use the message, so avoid creating it if we don't need to. -- MOS_MIGRATED_REVID=128837352
* Optimize Environment.lookup() to avoid Throwable.fillInStackTrace();Gravatar Googler2016-06-21
| | | | | | | | | | this is a noticeable hotspot in profiles of the loading phase. (Every caller of lookup() or importSymbol() catches this and either converts it to a non-exceptional condition or throws a new exception which will have its own stack trace.) -- MOS_MIGRATED_REVID=125320351
* Use setLoadingOrWorkspacePhase instead of setLoadingPhase where relevant,Gravatar Damien Martin-Guillerez2016-05-23
| | | | | | | | | | | commit 3fedf9e618cbce3dbdd00559b2de0bb8e2d43171 introduced the distinction between the loading phase and the workspace phase. This check broke the use of native.existing_rule(s) in skylark remote repository, added a regression test for it. Fixes #1277 -- MOS_MIGRATED_REVID=122988569
* Store the hash code of the Environment in the RuleClass object. When a ↵Gravatar Janak Ramakrishnan2016-05-23
| | | | | | | | | RuleClass is deserialized as part of a Skylark rule, the Environment is currently not present, but it is needed to detect changes to the rule. Also precompute and store the Environment's hash code, and do a drive-by clean-up of a bunch of warnings in the Environment code. -- MOS_MIGRATED_REVID=122838588
* Inject the Constants.TOOLS_REPOSITORY in SkylarkRuleClassFunctions.testBaseRule Gravatar Luis Fernando Pino Duque2016-04-29
| | | | | | | | | | | | | via the Skylark and delete the constant. Also, change the isLoadingPhase in the Skylark environment an enum Phase in order to: - Decide whether testRules are enabled or not and, - Check that the toolsRepository is set when in the LOADING phase. Finally, a few tests that were using ConfiguredRuleClassProvider directly had to be updated to set a tools repository, otherwise createGlobals() fails. -- MOS_MIGRATED_REVID=121022804
* Don't make racy changes to the global Environment.FrameGravatar Brian Silverman2016-04-12
| | | | | | | | | | | | | | | 6f15335 Make labels in .bzl files in remote repos resolve relative [...] introduced a Frame#setLabel which is documented to create a new Frame but instead modifies the existing one. This results in the global environment being modified in-place. I've been seeing some strange errors about not finding various packages in the wrong repositories which seems to be fixed by this change. -- Change-Id: I9b8521e50f45cfd385b20491315904ff0e24dcf6 Reviewed-on: https://bazel-review.googlesource.com/#/c/3300 MOS_MIGRATED_REVID=119529142