aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase/baseobjects.py
AgeCommit message (Collapse)AuthorFilesLines
2025-06-17interpreterbase: remove per-object method dispatchingPaolo Bonzini1-11/+0
Only support class-based dispatch, all objects have been converted.
2025-06-17interpreter: make methods per-class for primitivesPaolo Bonzini1-6/+33
Do not call update() and Enum.__hash__ a gazillion times; operators are the same for every instance of the class. In order to access the class, just mark the methods using a decorator and build METHODS later using __init_subclass__. Non-primitive objects are not converted yet to keep the patch small. They are created a lot less than other objects, especially strings and booleans. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-17interpreter: make operators per-classPaolo Bonzini1-10/+30
Do not call update() and Enum.__hash__ a gazillion times; operators are the same for every instance of the class. In order to access the class for non-trivial operators, the operators are first marked using a decorator, and then OPERATORS is built via __init_subclass__. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-17interpreter: make trivial_operators per-classPaolo Bonzini1-9/+24
Do not call update() and Enum.__hash__ a gazillion times; trivial operators are the same for every instance of the class. Introduce the infrastructure to build the MRO-resolved operators (so the outcome same as if one called super().__init__) for each subclass of InterpreterObject. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-17interpreter: make operator functions binaryPaolo Bonzini1-12/+10
In preparation for moving them to the class, make the operator functions binary. Adjust the lambdas for trivial operators, and store unbound methods for non-trivial ones. Note that this requires adding operators manually for every override, even subclasses. It's decidedly ugly at this temporary stage; later it will result in just an extra @InterpreterObject.operator decorator on the subclasses. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-09AstInterpreter: Fix dead-code-crashVolker Weißmann1-0/+4
Without this commit, the rewriter and the static introspection tool crash if `meson.build` contains something like ```meson if false foo = not_defined endif ``` or ```meson if false message(not_defined) endif ``` While it could be argued, that you should not write stuff like this, this used to raise a `MesonBugException`, which we have to fix. Fixes #14667
2025-05-29rewriter: Replace assignments with cur_assignmentsVolker Weißmann1-0/+6
Replace the variable tracking of `AstInterpreter.assignments` with a slightly better variable tracking called `AstInterpreter.cur_assignments`. We now have a class `UnknownValue` for more explicit handling of situations that are too complex/impossible.
2024-09-08interpreterbase: Use explicit `TypeAlias` annotation to allow recursive typesDylan Baker1-4/+4
And fix all of the issues that pop up once we remove the use of `Any`, which hides so many problems.
2024-07-05Revert "Clarify mutable objects usage"Eli Schwartz1-21/+0
This reverts commit 9f02d0a3e5a5ffc82256391c244b1af38e41ef78. It turns out that this does introduce a behavioral change in existing users of ConfigurationData, which it wasn't supposed to (it was supposed to preserve behavior there, and add a new *warning* for EnvironmentVariables). This breaks projects such as pulseaudio, libvirt, and probably more. Roll back the change and try again after 1.5.0 is released. Fixes: #13372
2024-04-14Clarify mutable objects usageXavier Claessens1-0/+21
Only Environment and ConfigurationData are mutable. However, only ConfigurationData becomes immutable after first use which is inconsistent. This deprecates modification after first use of Environment object and clarify documentation.
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker1-11/+1
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-10-04Remove unused code in interpreterbaseTristan Partin1-3/+0
2023-07-31fix lint errors revealed by pycodestyle 2.11Eli Schwartz1-4/+4
When performing isinstance checks, an identity comparison is automatically done, but we don't use isinstance here because we need strict identity equality *without allowing subtypes*. Comparing type() == type() is a value comparison, but could produce effectively the same results as an identity comparison, usually, despite being semantically off. pycodestyle learned to detect this and warn you to do strict identity comparison.
2023-03-01interpreter: Add testcase..endtestcase clause supportXavier Claessens1-0/+5
This is currently only enabled when running unit tests to facilitate writing failing unit tests. Fixes: #11394
2023-02-01treewide: add future annotations importEli Schwartz1-0/+1
2022-05-23typing: use forward reference for types defined later in fileEli Schwartz1-2/+2
2022-03-07merge various TYPE_CHECKING blocks into oneEli Schwartz1-7/+7
A bunch of files have several T.TYPE_CHECKING blocks that each do some things which could just as well be done once, with a single `if` statement. Make them do so.
2022-02-14FeatureNew: add mypy type annotations for subproject argEli Schwartz1-2/+4
Use a derived type when passing `subproject` around, so that mypy knows it's actually a SubProject, not a str. This means that passing anything other than a handle to the interpreter state's subproject attribute becomes a type violation, specifically when the order of the *four* different str arguments is typoed.
2021-10-27fix various flake8 whitespace errorsEli Schwartz1-0/+1
2021-10-10Fix typos discovered by codespellChristian Clauss1-1/+1
2021-10-06interpreter: Move RangeHolder out of interpreterbase to interpreterDaniel Mensinger1-23/+0
2021-10-06interpreter: Holderify arrays and dictsDaniel Mensinger1-7/+24
This is the final refactoring for extracting the bultin object logic out of Interpreterbase. I decided to do both arrays and dicts in one go since splitting it would have been a lot more confusing.
2021-10-04fix extra whitespaceEli Schwartz1-1/+0
discovered via flake8 --select E303
2021-09-25Remove helpers.check_stringlist()Daniel Mensinger1-3/+9
2021-09-25interpreter: Introduce StringHolderDaniel Mensinger1-2/+2
Another commit in my quest to rid InterpreterBase from all higher level object processing logic. Additionally, there is a a logic change here, since `str.join` now uses varargs and can now accept more than one argument (and supports list flattening).
2021-09-01interpreter: Introduce BooleanHolder for the bool primitiveDaniel Mensinger1-2/+2
2021-08-31interpreter: Add IntegerHolderDaniel Mensinger1-0/+4
2021-08-31interpreter: Introduce operators support for InterpreterObjectsDaniel Mensinger1-4/+79
2021-08-16interperterbase: help type checkers do better type deductionDylan Baker1-1/+5
This assert causes several type checkers (both mypy and pyright) to force `obj` to be a base `HoldableObject` instead of the specialized object. Since the check itself may still be valuable as we don't have fully type annotation coverage it's simply been removed when type checking to aid in type specialization.
2021-07-21Fix meson.version().version_compare() regression in subprojectXavier Claessens1-1/+1
2021-06-26refactor: Refactor BothLibraries logicDaniel Mensinger1-1/+3
This commit introduces a new type of `HoldableObject`: The `SecondLevelHolder`. The primary purpose of this class is to handle cases where two (or more) `HoldableObject`s are stored at the same time (with one default object). The best (and currently only) example here is the `BothLibraries` class.
2021-06-21fix: Ensure that build targets have all methods from ExternalProgramDaniel Mensinger1-1/+1
As a side-effect from #8885 `find_program()` returns now `Executable` objects when `meson.override_find_program` is called with an executable target. To resolve this conflict the missing methods from `ExternalProgram` are added to `BuildTarget`.
2021-06-18holders: Introduce HoldableObjectDaniel Mensinger1-11/+23
2021-06-18interpreter: Meson does not have floats --> remove themDaniel Mensinger1-2/+2
2021-06-18interpreter: Add a new MesonInterpreterObject for non-elementary objectsDaniel Mensinger1-2/+5
2021-06-18interpreter: Refactor interpreter.compiler to use ObjectHolderDaniel Mensinger1-2/+2
2021-06-18interpreter: Refactor ObjectHolder to extend InterpreterObjectDaniel Mensinger1-10/+10
2021-06-11interpreter: Split base objects and helpers from interpreterbase.pyDaniel Mensinger1-0/+79