Create evaluator for access operator

This commit is contained in:
Bartłomiej Pluta
2019-07-12 19:40:37 +02:00
parent 94666aca79
commit a1273896e4
5 changed files with 73 additions and 42 deletions

View File

@@ -1,5 +1,4 @@
from smnp.ast.node.identifier import Identifier
from smnp.ast.node.invocation import FunctionCallNode
from smnp.ast.node.identifier import Identifier, FunctionCall
from smnp.error.runtime import RuntimeException
from smnp.runtime.evaluator import Evaluator
from smnp.runtime.evaluators.expression import expressionEvaluator
@@ -20,9 +19,9 @@ class AccessEvaluator(Evaluator):
except KeyError:
raise RuntimeException(f"Unknown property '{right.value}' of type '{left.type.name.lower()}'", right.pos)
if type(right) == FunctionCallNode:
if type(right) == FunctionCall:
try:
arguments = abstractIterableEvaluator(expressionEvaluator(True))(right.arguments, environment)
arguments = abstractIterableEvaluator(expressionEvaluator(doAssert=True))(right.arguments, environment)
return environment.invokeMethod(left, right.name.value, arguments)
except RuntimeException as e:
raise updatePos(e, right)