Add support for evaluating BOOL and introduce basic logical operators as functions

This commit is contained in:
Bartłomiej Pluta
2019-07-10 14:08:28 +02:00
parent 9408c63e06
commit 578141c7b8
6 changed files with 23 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ def _function1(env, list, index):
raise RuntimeException(f"Attempt to access item which is outside the list", None)
_signature2 = signature(ofType(Type.MAP), ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.TYPE))
_signature2 = signature(ofType(Type.MAP), ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.BOOL, Type.TYPE))
def _function2(env, map, key):
try:
return map.value[key]

View File

@@ -4,7 +4,7 @@ from smnp.type.model import Type
from smnp.type.signature.matcher.list import listOfMatchers, listMatches
from smnp.type.signature.matcher.type import allTypes, ofTypes
_signature1 = varargSignature(listMatches(ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.TYPE), allTypes()))
_signature1 = varargSignature(listMatches(ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.BOOL, Type.TYPE), allTypes()))
def _function1(env, vararg):
map = {}
for entry in vararg:
@@ -14,7 +14,7 @@ def _function1(env, vararg):
return Type.map(map)
_signature2 = signature(listOfMatchers(listMatches(ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.TYPE), allTypes())))
_signature2 = signature(listOfMatchers(listMatches(ofTypes(Type.INTEGER, Type.STRING, Type.NOTE, Type.BOOL, Type.TYPE), allTypes())))
def _function2(env, list):
map = {}
for entry in list.value: