diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-30 01:53:37 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-30 01:53:37 +0300 |
commit | a52336b4294b72019587257d0848d42c0e2400fc (patch) | |
tree | 759f1f54b15242c207c0784fdc6cc255c53c4a42 | |
parent | 5e2278d6d4e2337c05b2f4e583dc8620b90e9add (diff) | |
download | meson-a52336b4294b72019587257d0848d42c0e2400fc.zip meson-a52336b4294b72019587257d0848d42c0e2400fc.tar.gz meson-a52336b4294b72019587257d0848d42c0e2400fc.tar.bz2 |
Can invoke methods on general statements and not just variable names.
-rw-r--r-- | interpreter.py | 8 | ||||
-rw-r--r-- | mparser.py | 2 | ||||
-rw-r--r-- | nodes.py | 4 | ||||
-rw-r--r-- | test cases/common/38 run program/meson.build | 3 |
4 files changed, 10 insertions, 7 deletions
diff --git a/interpreter.py b/interpreter.py index 8747801..f5c04e8 100644 --- a/interpreter.py +++ b/interpreter.py @@ -1107,10 +1107,14 @@ class Interpreter(): raise InterpreterException('Unknown method "%s" for a string.' % method_name) def method_call(self, node): - object_name = node.object_name.get_value() + invokable = node.invokable + if isinstance(invokable, nodes.AtomStatement): + object_name = invokable.get_value() + obj = self.get_variable(object_name) + else: + obj = self.evaluate_statement(invokable) method_name = node.method_name.get_value() args = node.arguments - obj = self.get_variable(object_name) if isinstance(obj, str): return self.string_method_call(obj, method_name) if not isinstance(obj, InterpreterObject): @@ -168,7 +168,7 @@ def p_statement_func_call(t): t[0] = nodes.FunctionCall(t[1], t[3], t[1].lineno()) def p_statement_method_call(t): - 'statement : expression DOT expression LPAREN args RPAREN' + 'statement : statement DOT expression LPAREN args RPAREN' t[0] = nodes.MethodCall(t[1], t[3], t[5], t[1].lineno()) def p_statement_if(t): @@ -141,9 +141,9 @@ class FunctionCall(Statement): return self.func_name.value class MethodCall(Statement): - def __init__(self, object_name, method_name, arguments, lineno): + def __init__(self, invokable, method_name, arguments, lineno): Statement.__init__(self, lineno) - self.object_name = object_name + self.invokable = invokable self.method_name = method_name self.arguments = arguments diff --git a/test cases/common/38 run program/meson.build b/test cases/common/38 run program/meson.build index 559f5cd..2c23985 100644 --- a/test cases/common/38 run program/meson.build +++ b/test cases/common/38 run program/meson.build @@ -7,8 +7,7 @@ if c.returncode() != 0 error('Executing echo failed.') endif -result = c.stdout() -result = result.strip() +result = c.stdout().strip() if result != correct error('Getting stdout failed.') |