Method calls work now.

pull/15/head
Jussi Pakkanen 11 years ago
parent 967f0110a5
commit 163a31beef
  1. 8
      interpreter.py
  2. 8
      parsertest.py

@ -1054,7 +1054,7 @@ class Interpreter():
code = open(absname).read() code = open(absname).read()
assert(isinstance(code, str)) assert(isinstance(code, str))
try: try:
codeblock = mparser.build_ast(code) codeblock = mparser2.Parser(code).parse()
except coredata.MesonException as me: except coredata.MesonException as me:
me.file = buildfilename me.file = buildfilename
raise me raise me
@ -1273,16 +1273,16 @@ class Interpreter():
return templ return templ
def method_call(self, node): def method_call(self, node):
invokable = node.invokable invokable = node.source_object
if isinstance(invokable, mparser2.IdNode): if isinstance(invokable, mparser2.IdNode):
object_name = invokable.value object_name = invokable.value
obj = self.get_variable(object_name) obj = self.get_variable(object_name)
else: else:
obj = self.evaluate_statement(invokable) obj = self.evaluate_statement(invokable)
method_name = node.method_name.get_value() method_name = node.name
if method_name == 'extract_objects' and self.environment.coredata.unity: if method_name == 'extract_objects' and self.environment.coredata.unity:
raise InterpreterException('Single object files can not be extracted in Unity builds.') raise InterpreterException('Single object files can not be extracted in Unity builds.')
args = node.arguments args = node.args
if isinstance(obj, nodes.StringStatement): if isinstance(obj, nodes.StringStatement):
obj = obj.get_value() obj = obj.get_value()
if isinstance(obj, str): if isinstance(obj, str):

@ -243,10 +243,12 @@ class ArgumentNode():
self.order_error = False self.order_error = False
def prepend(self, statement): def prepend(self, statement):
self.arguments = [statement] + self.arguments if not isinstance(statement, EmptyNode):
self.arguments = [statement] + self.arguments
def append(self, statement): def append(self, statement):
self.arguments = self.arguments + [statement] if not isinstance(statement, EmptyNode):
self.arguments = self.arguments + [statement]
def set_kwarg(self, name, value): def set_kwarg(self, name, value):
if self.num_args() > 0: if self.num_args() > 0:
@ -405,7 +407,7 @@ class Parser:
a.set_kwarg(s.value, value) a.set_kwarg(s.value, value)
return a return a
a = ArgumentNode(self.current) a = ArgumentNode(self.current)
a.arguments.append(s) a.append(s)
return a return a
def method_call(self, source_object): def method_call(self, source_object):

Loading…
Cancel
Save