}
return wc1;
}
public static WeaselParameterCompileReturn compileParamList(int line, String methodName, WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelper, WeaselTree func, List<WeaselGenericMethod2> methods) throws WeaselCompilerException {
WeaselCompilerReturn wcr;
WeaselInstructionList instructions = new WeaselInstructionList();
WeaselGenericMethod2 method;
if(func instanceof WeaselTreeLevel){
WeaselTreeLevel treeLevel = (WeaselTreeLevel) func;
if(treeLevel.levelPriority == 0){
int param=treeLevel.level.size();
Iterator<WeaselGenericMethod2> iterator = methods.iterator();
while(iterator.hasNext()){
if(iterator.next().getGenericParams().length!=param)
iterator.remove();
}
WeaselGenericClass expect = null;
if(methods.isEmpty())
throw new WeaselCompilerException(line, "No method %s found with %s params", param);
List<WeaselGenericClass> params = new ArrayList<WeaselGenericClass>();
for(int i=0; i<param; i++){
if(methods.size()==1)
expect = methods.get(0).getGenericParams()[i];
wcr = treeLevel.level.get(i).compile(compiler, compilerHelper, null, expect, null, false);
instructions.addAll(wcr.getInstructions());
params.add(wcr.getReturnType());
}
iterator = methods.iterator();
while(iterator.hasNext()){
WeaselGenericMethod2 m=iterator.next();
for(int i=0; i<param; i++){
if(params.get(i)!=null && !params.get(i).canCastTo(m.getGenericParams()[i]))
iterator.remove();
}
}
if(methods.isEmpty()){
throw new WeaselCompilerException(line, "No method %s found with for params %s", methodName, params);
}
if(methods.size()==1){
method = methods.get(0);
}else{
throw new WeaselCompilerException(line, "Not supported now");
}
return new WeaselParameterCompileReturn(instructions, method);
}
}
if(func==null){
method = null;
for(WeaselGenericMethod2 m:methods){
if(m.getGenericParams().length==0){
method = m;
break;
}
}
if(method==null){
throw new WeaselCompilerException(line, "No method %s found with no params", methodName);
}
}else{
Iterator<WeaselGenericMethod2> iterator = methods.iterator();
while(iterator.hasNext()){
if(iterator.next().getGenericParams().length!=1)
iterator.remove();
}
WeaselGenericClass expect = null;
if(methods.isEmpty())
throw new WeaselCompilerException(line, "No method %s found with one param", methodName);
if(methods.size()==1)
expect = methods.get(0).getGenericParams()[0];
wcr = func.compile(compiler, compilerHelper, null, expect, null, false);
instructions.addAll(wcr.getInstructions());
iterator = methods.iterator();
while(iterator.hasNext()){
WeaselGenericMethod2 m=iterator.next();
if(!wcr.getReturnType().canCastTo(m.getGenericParams()[0]))
iterator.remove();
}
if(methods.isEmpty()){
throw new WeaselCompilerException(line, "No method %s found with for param %s", methodName, wcr.getReturnType());
}
if(methods.size()==1){
method = methods.get(0);
}else{
throw new WeaselCompilerException(line, "Not supported now");