| Age | Commit message (Collapse) | Author |
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
This avoids creating a dictionary every time an arithmetic operator
is evaluated.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Global objects are treated as UnknownValue(), but unlike other variables
their object is created on every call to get_cur_value_if_defined()
instead of coming from a dictionary. This causes the dataflow DAG
to have multiple objects from the same object. Fix this by building
the UnknownValues at interpreter construction time.
Fixes: #15261
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
This reverts https://github.com/mesonbuild/meson/pull/15107
Explicit objections regarding the design were raised and not answered,
so it shouldn't have been merged. It needs to be discussed and
revisited.
|
|
This has the "processed" keyword arguments that the interpreter is
supposed to create for us, or that we expect internal users to build by
build.
This requires some hacking around in the rust module for the moment
because we suddenly have a type.
|
|
|
|
Avoid different but equivalent code between ast and regular
interpreter, and avoid using coredata.set_options since
all options are known to be backend options.
Move to environment since it uses environment.options.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Reduces 3 errors that show up in newer mypy versions than pinned in CI.
It is new since 1.16 and a likely future default for mypy 2.0. It allows
things like:
```
for i in ['one', 'two', 'three']:
frob_a(i)
for i in [1, 2, 3]:
frob_b(i)
```
since "i" is obviously used as a loop holder and its type can be freely
reinvented. Note: allow-redefinition-new isn't actually about this at
all, it has greater scope than loop holders and allows redefining
"unannotated variables" of all kinds. No granularity in what to accept
redefinition of. :P
To enable this, we must also opt in to local-partial-types, which has
some overlap with None-safety. Specifically:
> the most common cases for partial types are variables initialized
> using None, but without explicit X | None annotations. By default, mypy
> won’t check partial types spanning module top level or class top level.
> This flag changes the behavior to only allow partial types at local
> level, therefore it disallows inferring variable type for None from two
> assignments in different scopes.
So with this, we also fix a couple of actual type errors this revealed.
Where possible, stop None-initializing at all -- it's not strictly
needed for global variables, anyway, and it's a coding error if it is
possible to hit these variables without defining them first.
Bug: https://github.com/python/mypy/issues/19280
|
|
UnknownValue
It is not the build layer's job to handle ast types, so instead filter
out UnknownValues before passing them to the build layer, then fix up
any special values we need in the ast layer. This reveals that some of
what we were previously doing only works because the build layer is
pretty much untyped, if it was typed it would have screamed loudly.
|
|
Fixes #14840
|
|
subproject
This is already done most of the time for default_library but not in these cases.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
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
|
|
Change the semantics of IntrospectionBuildTarget.source_nodes
and IntrospectionBuildTarget.extra_files .
The rewriter and the static introspection tool used to be very broken,
now it is *less* broken, hence we add some tests in this commit.
Fixes #11763
|
|
|
|
|
|
`AstInterpreter.node_to_runtime_value` can now resolve function calls.
|
|
`resolve_node` is simply a half-broken, worse implementation of
`node_to_runtime_value` that we recently introduced.
In the example below, the static introspection tool/rewriter now
understands that the name of the executable is foo instead of bar:
```
var = 'foo'
name = var
var = 'bar'
executable(name, 'foo.c')
```
|
|
Without this commit, something like this crashes the static
introspection/rewrite tool:
```
default_options : ['warning_level='
+ run_command(['echo', '3']).stdout().strip()],
```
This commit does not reintroduce #14382.
|
|
Make the AstInterpreter create a directed acyclic graph (called
`dataflow_dag`) that stores the how the data flowes from one node in
the AST to another.
Add `AstInterpreter.node_to_runtime_value` which uses `dataflow_dag`
to find what value a variable at runtime will have.
We don't use dataflow_dag or node_to_runtime_value anywhere yet, but
it will prove useful in future commits.
|
|
Some of the evaluate_* functions in AstInterpreter seem very broken
and do not even evaluate all of the AST. I do not know what the
original author thought, so I just fixed it.
|
|
Replace `AstInterpreter.reverse_assignment` with
`AstInterpreter.all_assignment_nodes`.
This does not give us an immediate advantage but
will be useful in future commits.
|
|
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.
|
|
The AstInterpreter now stores how deep into if/elif/else we are.
This is currently dead code, but it will be read in future commits.
|
|
|
|
To improve type-safety and readability we replace a
dictionary with a new class `IntrospectionDependency`.
|
|
To improve type-safety and readability we replace a
dictionary with a new class `IntrospectionBuildTarget`.
|
|
|
|
|
|
|
|
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Let add_compiler_options and process_compiler_options handle subprojects,
and also run it for the main project to ensure that pending_options are
properly processed.
This exposes a bug because "comp" could have been None, so fix that.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Allow OptionStringLikeDict to use non-string data types, and use it
as much as possible instead of string-valued dictionaries.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Do not go through string first and OptionKey second. Just pass the OptionKeys
down.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
This was only being used by the introspection interpreter, which meant
the two interpreters had different behavior. They still do, which is
really bad because the IntrospectionInterpreter doesn't have the command
line options or project_default_options. I have a plan to fix that
later, and I don't want to spend time on it here, as it's not a
regression of this patch, it's just the status quo.
This also fixes an issue caused by dead code being left, and hit, due to
the option refactor branch.
Fixes: #14382
|
|
|
|
subproject_dir, environment, and coredata
|
|
|
|
It is not used elsewhere
|
|
This is an old method, that is now just a wrapper around the OptionStore
method, that doesn't add any value. It's also an option related method
attached to the CoreData instead of the OptionStore, so useless and a
layering violation.
|
|
|
|
Even though the "targets" introspection info already includes the
command line arguments used to invoke the compiler, this is not
enough to correlated with the "compilers" introspection info and
get extra information from there.
Together with the existing "language" key, adding a "machine" key
is enough to identify completely an entry in the compilers info.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
The AstInterpreter does this check as well, so don't do it twice.
|
|
|
|
|
|
|
|
|
|
|