aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2019-01-22 12:33:12 -0500
committerXavier Claessens <xavier.claessens@collabora.com>2019-01-22 12:33:12 -0500
commit90d1f38d8e23667059ae9b32b2925f5e2a230881 (patch)
treecbb44bc43604e1dcc23b840bb5f7dd9afbcdc0da /mesonbuild/interpreterbase.py
parent72486afd08d66d6323c2113739dcfff74813058b (diff)
downloadmeson-90d1f38d8e23667059ae9b32b2925f5e2a230881.zip
meson-90d1f38d8e23667059ae9b32b2925f5e2a230881.tar.gz
meson-90d1f38d8e23667059ae9b32b2925f5e2a230881.tar.bz2
Interpreter: Set self.current_node during method/function calls
The current node is useful to pass as location kwarg to mlog.warning(). The node is not passed to InterpreterObject method arguments, and it's easier to have it on the object than passing it through argument everywhere.
Diffstat (limited to 'mesonbuild/interpreterbase.py')
-rw-r--r--mesonbuild/interpreterbase.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py
index 48c5220..afa4cd3 100644
--- a/mesonbuild/interpreterbase.py
+++ b/mesonbuild/interpreterbase.py
@@ -320,6 +320,9 @@ class BreakRequest(BaseException):
class InterpreterObject:
def __init__(self):
self.methods = {}
+ # Current node set during a method call. This can be used as location
+ # when printing a warning message during a method call.
+ self.current_node = None
def method_call(self, method_name, args, kwargs):
if method_name in self.methods:
@@ -366,6 +369,9 @@ class InterpreterBase:
self.variables = {}
self.argument_depth = 0
self.current_lineno = -1
+ # Current node set during a function call. This can be used as location
+ # when printing a warning message during a method call.
+ self.current_node = None
def load_root_meson_file(self):
mesonfile = os.path.join(self.source_root, self.subdir, environment.build_filename)
@@ -759,6 +765,7 @@ The result of this is undefined and will become a hard error in a future Meson r
if not getattr(func, 'no-args-flattening', False):
posargs = flatten(posargs)
+ self.current_node = node
return func(node, posargs, kwargs)
else:
self.unknown_function_called(func_name)
@@ -795,6 +802,7 @@ The result of this is undefined and will become a hard error in a future Meson r
return Disabler()
if method_name == 'extract_objects':
self.validate_extraction(obj.held_object)
+ obj.current_node = node
return obj.method_call(method_name, args, kwargs)
def bool_method_call(self, obj, method_name, args):