org.snapscript.tree.function.FunctionHandleAligner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.function;
import org.snapscript.core.type.index.ScopeType;
import org.snapscript.core.variable.Value;
public class FunctionHandleAligner {
private final Value value;
private final boolean constructor;
public FunctionHandleAligner(Value value, boolean constructor){
this.constructor = constructor;
this.value = value;
}
public Object[] align(Object... list) throws Exception {
if(constructor) {
Object object = value.getValue();
if(ScopeType.class.isInstance(object)) { // inject type parameter
Object[] arguments = new Object[list.length +1];
for(int i = 0; i < list.length; i++) {
arguments[i + 1] = list[i];
}
arguments[0] = object;
return arguments;
}
}
return list;
}
}