diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-01-21 14:27:00 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-01-22 16:09:35 +0100 |
commit | f6339d6361c89f7b79cbf91e8eb56089f3c1a592 (patch) | |
tree | 06031f85ac53bff23799b09e5c69c0d139c124f3 /mesonbuild/ast | |
parent | 50bc0960e44a262906db3bde94c1daab7355d641 (diff) | |
download | meson-f6339d6361c89f7b79cbf91e8eb56089f3c1a592.zip meson-f6339d6361c89f7b79cbf91e8eb56089f3c1a592.tar.gz meson-f6339d6361c89f7b79cbf91e8eb56089f3c1a592.tar.bz2 |
Added support for assignments in the AST interpretor
Diffstat (limited to 'mesonbuild/ast')
-rw-r--r-- | mesonbuild/ast/interpreter.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index 28f1150..8893e9b 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 |