From f6339d6361c89f7b79cbf91e8eb56089f3c1a592 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Mon, 21 Jan 2019 14:27:00 +0100 Subject: [PATCH] Added support for assignments in the AST interpretor --- mesonbuild/ast/interpreter.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index 28f115039..8893e9b74 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -47,6 +47,7 @@ class AstInterpreter(interpreterbase.InterpreterBase): def __init__(self, source_root, subdir): super().__init__(source_root, subdir) self.visited_subdirs = {} + self.assignments = {} self.funcs.update({'project': self.func_do_nothing, 'test': self.func_do_nothing, 'benchmark': self.func_do_nothing, @@ -133,7 +134,11 @@ class AstInterpreter(interpreterbase.InterpreterBase): return 0 def evaluate_plusassign(self, node): - return 0 + assert(isinstance(node, mparser.PlusAssignmentNode)) + if node.var_name not in self.assignments: + self.assignments[node.var_name] = [] + self.assignments[node.var_name] += [node.value] # Save a reference to the value node + self.evaluate_statement(node.value) # Evaluate the value just in case def evaluate_indexing(self, node): return 0 @@ -168,7 +173,9 @@ class AstInterpreter(interpreterbase.InterpreterBase): return 0 def assignment(self, node): - pass + assert(isinstance(node, mparser.AssignmentNode)) + self.assignments[node.var_name] = [node.value] # Save a reference to the value node + self.evaluate_statement(node.value) # Evaluate the value just in case def flatten_args(self, args, include_unknown_args: bool = False): # Resolve mparser.ArrayNode if needed