diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-03-03 18:33:05 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-03-03 20:25:07 +0200 |
commit | 7f9fb6a08481c26698fb9c8ce4920c456e46bbbd (patch) | |
tree | 782965a808437bf4816b0cbf17ab77d565ec7c13 /mesonbuild/ast | |
parent | bd5d54513c14898535330aa807ed41a5c7c9a80a (diff) | |
download | meson-7f9fb6a08481c26698fb9c8ce4920c456e46bbbd.zip meson-7f9fb6a08481c26698fb9c8ce4920c456e46bbbd.tar.gz meson-7f9fb6a08481c26698fb9c8ce4920c456e46bbbd.tar.bz2 |
rewriter: Minor code cleanup
Diffstat (limited to 'mesonbuild/ast')
-rw-r--r-- | mesonbuild/ast/introspection.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 7544b60..6ac5929 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -16,10 +16,11 @@ # or an interpreter-based tool from . import AstInterpreter -from .. import compilers, environment, mesonlib, mparser, optinterpreter +from .. import compilers, environment, mesonlib, optinterpreter from .. import coredata as cdata from ..interpreterbase import InvalidArguments from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary +from ..mparser import ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode import os build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries'] @@ -77,7 +78,7 @@ class IntrospectionInterpreter(AstInterpreter): proj_name = args[0] proj_vers = kwargs.get('version', 'undefined') proj_langs = self.flatten_args(args[1:]) - if isinstance(proj_vers, mparser.ElementaryNode): + if isinstance(proj_vers, ElementaryNode): proj_vers = proj_vers.value if not isinstance(proj_vers, str): proj_vers = 'undefined' @@ -96,7 +97,7 @@ class IntrospectionInterpreter(AstInterpreter): if not self.is_subproject() and 'subproject_dir' in kwargs: spdirname = kwargs['subproject_dir'] - if isinstance(spdirname, mparser.ElementaryNode): + if isinstance(spdirname, ElementaryNode): self.subproject_dir = spdirname.value if not self.is_subproject(): self.project_data['subprojects'] = [] @@ -155,25 +156,25 @@ class IntrospectionInterpreter(AstInterpreter): while srcqueue: curr = srcqueue.pop(0) arg_node = None - if isinstance(curr, mparser.FunctionNode): + if isinstance(curr, FunctionNode): arg_node = curr.args - elif isinstance(curr, mparser.ArrayNode): + elif isinstance(curr, ArrayNode): arg_node = curr.args - elif isinstance(curr, mparser.IdNode): + elif isinstance(curr, IdNode): # Try to resolve the ID and append the node to the queue id = curr.value if id in self.assignments and self.assignments[id]: tmp_node = self.assignments[id][0] - if isinstance(tmp_node, (mparser.ArrayNode, mparser.IdNode, mparser.FunctionNode)): + if isinstance(tmp_node, (ArrayNode, IdNode, FunctionNode)): srcqueue += [tmp_node] - elif isinstance(curr, mparser.ArithmeticNode): + elif isinstance(curr, ArithmeticNode): srcqueue += [curr.left, curr.right] if arg_node is None: continue - elemetary_nodes = list(filter(lambda x: isinstance(x, (str, mparser.StringNode)), arg_node.arguments)) - srcqueue += list(filter(lambda x: isinstance(x, (mparser.FunctionNode, mparser.ArrayNode, mparser.IdNode, mparser.ArithmeticNode)), arg_node.arguments)) + elemetary_nodes = list(filter(lambda x: isinstance(x, (str, StringNode)), arg_node.arguments)) + srcqueue += list(filter(lambda x: isinstance(x, (FunctionNode, ArrayNode, IdNode, ArithmeticNode)), arg_node.arguments)) # Pop the first element if the function is a build target function - if isinstance(curr, mparser.FunctionNode) and curr.func_name in build_target_functions: + if isinstance(curr, FunctionNode) and curr.func_name in build_target_functions: elemetary_nodes.pop(0) if elemetary_nodes: source_nodes += [curr] @@ -233,7 +234,7 @@ class IntrospectionInterpreter(AstInterpreter): if 'target_type' not in kwargs: return target_type = kwargs.pop('target_type') - if isinstance(target_type, mparser.ElementaryNode): + if isinstance(target_type, ElementaryNode): target_type = target_type.value if target_type == 'executable': return self.build_target(node, args, kwargs, Executable) |