X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.scl.commands%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcommands%2Finternal%2Fchecker%2FFunctionCheckItem.java;fp=bundles%2Forg.simantics.scl.commands%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcommands%2Finternal%2Fchecker%2FFunctionCheckItem.java;h=756f639af3b16756a6f75555678b89b5e5557dd4;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/checker/FunctionCheckItem.java b/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/checker/FunctionCheckItem.java new file mode 100644 index 000000000..756f639af --- /dev/null +++ b/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/checker/FunctionCheckItem.java @@ -0,0 +1,33 @@ +package org.simantics.scl.commands.internal.checker; + +import java.util.List; + +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.runtime.function.Function; + +public class FunctionCheckItem implements CheckItem { + + Type parameterType; + CheckItem next; + + public FunctionCheckItem(Type parameterType, CheckItem next) { + this.parameterType = parameterType; + this.next = next; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public boolean check(Object check, Object[] parameters, int pos) { + if(pos == parameters.length) + return true; + Object nextCheck = ((Function)check).apply(parameters[pos]); + return next.check(nextCheck, parameters, pos+1); + } + + @Override + public void collectParameterTypes(List types) { + types.add(parameterType); + next.collectParameterTypes(types); + } + +}