From 8c9c5199f9c2c08190e424ffcaed6d54b8c47184 Mon Sep 17 00:00:00 2001 From: Daniel Schulte Date: Wed, 10 Oct 2018 23:13:53 +0200 Subject: [PATCH] AstInterpreter: Stub out more functions This commit disables more functions inherited from InterpreterBase that we don't need for AST evaluation. --- mesonbuild/astinterpreter.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/mesonbuild/astinterpreter.py b/mesonbuild/astinterpreter.py index 686572bd2..a447a5597 100644 --- a/mesonbuild/astinterpreter.py +++ b/mesonbuild/astinterpreter.py @@ -18,7 +18,7 @@ from . import interpreterbase, mlog, mparser, mesonlib from . import environment -from .interpreterbase import InterpreterException, InvalidArguments +from .interpreterbase import InterpreterException, InvalidArguments, BreakRequest, ContinueRequest import os, sys @@ -105,7 +105,7 @@ class AstInterpreter(interpreterbase.InterpreterBase): return 0 def unknown_function_called(self, func_name): - mlog.warning('Unknown function called: ' + func_name) + pass def reduce_arguments(self, args): assert(isinstance(args, mparser.ArgumentNode)) @@ -113,6 +113,29 @@ class AstInterpreter(interpreterbase.InterpreterBase): raise InvalidArguments('All keyword arguments must be after positional arguments.') return args.arguments, args.kwargs + def evaluate_comparison(self, node): + return False + + def evaluate_foreach(self, node): + try: + self.evaluate_codeblock(node.block) + except ContinueRequest: + pass + except BreakRequest: + pass + + def evaluate_if(self, node): + for i in node.ifs: + self.evaluate_codeblock(i.block) + if not isinstance(node.elseblock, mparser.EmptyNode): + self.evaluate_codeblock(node.elseblock) + + def get_variable(self, varname): + return 0 + + def assignment(self, node): + pass + class RewriterInterpreter(AstInterpreter): def __init__(self, source_root, subdir): super().__init__(source_root, subdir)