Reformat evaluator #1
This commit is contained in:
24
smnp/library/function/debug.py
Normal file
24
smnp/library/function/debug.py
Normal 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')
|
||||
@@ -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')
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user