Improve environment #2
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -9,3 +9,8 @@ class IllegalFunctionInvocationException(SmnpException):
|
||||
class FunctionNotFoundException(SmnpException):
|
||||
def __init__(self, function):
|
||||
self.msg = f"Function '{function}' not found"
|
||||
|
||||
|
||||
class MethodNotFoundException(SmnpException):
|
||||
def __init__(self, object, method):
|
||||
self.msg = f"Method '{method}' of type '{object}' not found"
|
||||
Reference in New Issue
Block a user