![JAR search and dependency download from the Maven repository](/logo.png)
org.snapscript.tree.function.ParameterList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.function;
import java.util.ArrayList;
import java.util.List;
import org.snapscript.core.Context;
import org.snapscript.core.Module;
import org.snapscript.core.Scope;
import org.snapscript.core.Type;
import org.snapscript.core.TypeLoader;
import org.snapscript.core.function.Parameter;
import org.snapscript.core.function.ParameterBuilder;
import org.snapscript.core.function.Signature;
public class ParameterList {
private VariableArgumentChecker checker;
private ParameterDeclaration[] list;
private ParameterBuilder builder;
private Signature signature;
public ParameterList(ParameterDeclaration... list) {
this.checker = new VariableArgumentChecker(list);
this.builder = new ParameterBuilder();
this.list = list;
}
public Signature create(Scope scope) throws Exception{
return create(scope, null);
}
public Signature create(Scope scope, String prefix) throws Exception{
Module module = scope.getModule();
if(signature == null) {
List parameters = new ArrayList();
if(prefix != null) {
Context context = module.getContext();
TypeLoader loader = context.getLoader();
Type constraint = loader.loadType(Type.class);
Parameter parameter = builder.create(constraint, prefix);
parameters.add(parameter);
}
boolean variable = checker.isVariable(scope);
for(int i = 0; i < list.length; i++) {
ParameterDeclaration declaration = list[i];
if(declaration != null) {
Parameter parameter = declaration.get(scope);
parameters.add(parameter);
}
}
signature = new Signature(parameters, module, null, variable);
}
return signature;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy