Improve environment #1

This commit is contained in:
Bartłomiej Pluta
2019-07-04 11:43:07 +02:00
parent ce101df380
commit b60dedc769
16 changed files with 28 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
from smnp.error.function import FunctionNotFoundException
from smnp.error.runtime import RuntimeException
@@ -9,6 +10,15 @@ class Environment():
self.customFunctions = {}
self.callStack = [] #TODO remove
def invokeFunction(self, name, args):
for function in self.functions: # TODO to działa tylko dla wbudowanych funkcji
if function.name == name:
ret = function.call(self, args)
if ret is not None:
return ret
raise FunctionNotFoundException(name)
# TODO raise nie znaleziono funkcji
def findVariable(self, name, type=None, pos=None):
for scope in reversed(self.scopes):
if name in scope: