Improve environment #2

This commit is contained in:
Bartłomiej Pluta
2019-07-04 12:02:46 +02:00
parent b60dedc769
commit f86055272e
2 changed files with 14 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
from smnp.error.function import FunctionNotFoundException
from smnp.error.function import FunctionNotFoundException, MethodNotFoundException
from smnp.error.runtime import RuntimeException
@@ -10,6 +10,14 @@ class Environment():
self.customFunctions = {}
self.callStack = [] #TODO remove
def invokeMethod(self, name, object, args):
for method in self.methods: # TODO to działa tylko dla wbudowanych funkcji
if method.name == name:
ret = method.call(self, [object, *args])
if ret is not None:
return ret
raise MethodNotFoundException(object.type, name) # TODO method not found
def invokeFunction(self, name, args):
for function in self.functions: # TODO to działa tylko dla wbudowanych funkcji
if function.name == name: