Reformat evaluator #1

This commit is contained in:
Bartłomiej Pluta
2019-07-04 17:57:12 +02:00
parent f0cbf37fe9
commit 34a0eda199
36 changed files with 470 additions and 270 deletions

View File

@@ -0,0 +1,24 @@
from smnp.error.function import IllegalArgumentException
from smnp.library.model import Function
from smnp.library.signature import signature, ofTypes
from smnp.type.model import Type
_signature = signature(ofTypes(Type.STRING))
def _function(env, parameter):
if parameter.value == "environment":
print(env)
return
elif parameter.value == "variables":
print(env.scopesToString())
return
elif parameter.value == "functions":
print(env.functionsToString())
return
elif parameter.value == "methods":
print(env.methodsToString())
return
raise IllegalArgumentException(f"Unknown parameter '{parameter.value}'")
function = Function(_signature, _function, 'debug')

View File

@@ -7,7 +7,7 @@ from smnp.type.model import Type
_signature = signature(ofTypes(Type.INTEGER))
def _function(env, value):
bpm = env.findVariable('bpm')
player.pause(value.value, bpm)
player.pause(value.value, bpm.value)
function = Function(_signature, _function, 'pause')

View File

@@ -8,7 +8,7 @@ _signature1 = varargSignature(ofTypes(Type.NOTE, Type.INTEGER))
def _function1(env, vararg):
notes = [arg.value for arg in vararg]
bpm = env.findVariable('bpm')
playNotes(notes, bpm)
playNotes(notes, bpm.value)
_signature2 = varargSignature(listOf(Type.NOTE, Type.INTEGER))

View File

@@ -18,6 +18,6 @@ def _function2(env, n, m, notes):
function = CombinedFunction(
'tuplet',
Function(_function1, _function1),
Function(_function2, _function2)
Function(_signature1, _function1),
Function(_signature2, _function2)
)