this.variables=variables;
}
SourceStore getElement(ParserVal val) throws UnknownConnectionException, TypeMismatchException{
if(val instanceof TemplateProvider){
return new SourceStore(createTree((TemplateProvider) val), StandardParameters.OUT.i);
}
if(val instanceof de.maramuse.soundcomp.parser.Number){
return new SourceStore(ConstStream.c(val.asDouble()), StandardParameters.OUT.i);
}
if(val instanceof ConnectionPoint){
ConnectionPoint cp=(ConnectionPoint)val;
String elName=cp.getElementName();
String coName=cp.getConnectionName();
NamedSource src=subprocesses.get(elName);
if(src==null)throw new IllegalArgumentException("Element "+elName+" not found");
Parameter param=src.outputsByName().get(coName);
if(param==null)throw new IllegalArgumentException("Output "+coName+" not found in element "+elName);
return new SourceStore(src, param.i);
}
if(val instanceof Element){ // a variable or an input?
String varName=val.getText();
Variable v=variables.get(varName);
if(v!=null)
return new SourceStore(v, StandardParameters.OUT.i);
SourceStore ret=process.getInputProxy(varName);
if(ret==null)throw new IllegalArgumentException(varName+" not found in element "+process.getAbstractName()+", should be an input or variable");
return ret;
}
throw new IllegalArgumentException("Illegal element "+val.getClass().getName()+" in formula");
}